@@ -49,49 +49,23 @@ AutowarePoseCovarianceModifierNode::AutowarePoseCovarianceModifierNode()
49
49
}
50
50
51
51
}
52
- bool AutowarePoseCovarianceModifierNode::checkTrustedPoseTimeout ()
52
+ void AutowarePoseCovarianceModifierNode::checkTrustedPoseTimeout ()
53
53
{
54
54
auto timeDiff = this ->now () - trustedPoseCallbackTime;
55
55
if (timeDiff.seconds () > 1.0 ) {
56
- return true ;
57
- }
58
- return false ;
59
- }
60
- void AutowarePoseCovarianceModifierNode::publishPoseSource ()
61
- {
62
- std_msgs::msg::String selected_pose_type;
63
- switch (pose_source_) {
64
- case static_cast <int >(AutowarePoseCovarianceModifierNode::PoseSource::GNSS):
65
- selected_pose_type.data = " GNSS" ;
66
- break ;
67
- case static_cast <int >(AutowarePoseCovarianceModifierNode::PoseSource::GNSS_NDT):
68
- selected_pose_type.data = " GNSS + NDT" ;
69
- break ;
70
- case static_cast <int >(AutowarePoseCovarianceModifierNode::PoseSource::NDT):
56
+ RCLCPP_WARN (this ->get_logger (), " Trusted Pose Timeout" );
57
+ pose_source_ = static_cast <int >(AutowarePoseCovarianceModifierNode::PoseSource::NDT);
58
+ std_msgs::msg::String selected_pose_type;
71
59
selected_pose_type.data = " NDT" ;
72
- break ;
73
- default :
74
- selected_pose_type.data = " Unknown" ;
75
- break ;
60
+ pose_source_pub_->publish (selected_pose_type);
76
61
}
77
- pose_source_pub_->publish (selected_pose_type);
78
62
}
63
+
79
64
std::array<double , 36 > AutowarePoseCovarianceModifierNode::ndt_covariance_modifier (
80
65
std::array<double , 36 > & in_ndt_covariance)
81
66
{
82
67
std::array<double , 36 > ndt_covariance = in_ndt_covariance;
83
68
84
- if (AutowarePoseCovarianceModifierNode::checkTrustedPoseTimeout ()) {
85
- RCLCPP_WARN (this ->get_logger (), " Trusted Pose Timeout" );
86
- pose_source_ = static_cast <int >(AutowarePoseCovarianceModifierNode::PoseSource::NDT);
87
- return ndt_covariance;
88
- }
89
-
90
- if (
91
- trustedPose.pose_average_rmse_xy <= gnss_error_reliable_max_ &&
92
- trustedPose.yaw_rmse_in_degrees < yaw_error_deg_threshold_) {
93
- pose_source_ = static_cast <int >(AutowarePoseCovarianceModifierNode::PoseSource::GNSS);
94
- } else if (trustedPose.pose_average_rmse_xy <= gnss_error_unreliable_min_) {
95
69
/*
96
70
* ndt_min_rmse_meters = in_ndt_rmse
97
71
* ndt_max_rmse_meters = in_ndt_rmse * 2
@@ -119,21 +93,15 @@ std::array<double, 36> AutowarePoseCovarianceModifierNode::ndt_covariance_modifi
119
93
ndt_covariance[7 ] = std::max (ndt_covariance[7 ], in_ndt_covariance[7 ]);
120
94
ndt_covariance[14 ] = std::max (ndt_covariance[14 ], in_ndt_covariance[14 ]);
121
95
122
- pose_source_ = static_cast <int >(AutowarePoseCovarianceModifierNode::PoseSource::GNSS_NDT);
123
- } else {
124
- RCLCPP_INFO (this ->get_logger (), " NDT input covariance values will be used " );
125
- pose_source_ = static_cast <int >(AutowarePoseCovarianceModifierNode::PoseSource::NDT);
126
- }
127
-
128
- publishPoseSource ();
129
-
130
96
return ndt_covariance;
131
97
}
132
98
void AutowarePoseCovarianceModifierNode::ndt_pose_with_cov_callback (
133
99
const geometry_msgs::msg::PoseWithCovarianceStamped::ConstSharedPtr & msg)
134
100
{
101
+ AutowarePoseCovarianceModifierNode::checkTrustedPoseTimeout ();
102
+
135
103
std::array<double , 36 > ndt_covariance_in_ = msg->pose .covariance ;
136
- std::array<double , 36 > out_ndt_covariance_ = ndt_covariance_modifier (ndt_covariance_in_);
104
+ std::array<double , 36 > out_ndt_covariance_ = pose_source_ == 1 ? ndt_covariance_modifier (ndt_covariance_in_) : ndt_covariance_in_ ;
137
105
138
106
geometry_msgs::msg::PoseWithCovarianceStamped ndt_pose_with_covariance = *msg;
139
107
ndt_pose_with_covariance.pose .covariance = out_ndt_covariance_;
@@ -152,23 +120,42 @@ void AutowarePoseCovarianceModifierNode::trusted_pose_with_cov_callback(
152
120
trustedPoseCallbackTime = this ->now ();
153
121
trusted_source_pose_with_cov = *msg;
154
122
155
- trustedPose.pose_average_rmse_xy = (std::sqrt (trusted_source_pose_with_cov.pose .covariance [0 ]) +
123
+ double trusted_pose_average_rmse_xy;
124
+ double trusted_pose_yaw_rmse_in_degrees;
125
+ trusted_pose_average_rmse_xy= (std::sqrt (trusted_source_pose_with_cov.pose .covariance [0 ]) +
156
126
std::sqrt (trusted_source_pose_with_cov.pose .covariance [7 ])) /
157
127
2 ;
158
128
159
- trustedPose. yaw_rmse_in_degrees =
129
+ trusted_pose_yaw_rmse_in_degrees =
160
130
std::sqrt (trusted_source_pose_with_cov.pose .covariance [35 ]) * 180 / M_PI;
161
131
132
+ selectPositionSource (trusted_pose_average_rmse_xy, trusted_pose_yaw_rmse_in_degrees);
133
+
162
134
if (pose_source_ != 2 ) {
163
135
new_pose_estimator_pub_->publish (trusted_source_pose_with_cov);
164
136
if (debug_){
165
137
std_msgs::msg::Float32 out_gnss_rmse;
166
- out_gnss_rmse.data = trustedPose. pose_average_rmse_xy ;
138
+ out_gnss_rmse.data = trusted_pose_average_rmse_xy ;
167
139
out_gnss_position_rmse_pub_->publish (out_gnss_rmse);
168
140
}
169
-
170
141
}
171
142
}
143
+
144
+ void AutowarePoseCovarianceModifierNode::selectPositionSource (double trusted_pose_average_rmse_xy ,double trusted_pose_yaw_rmse_in_degrees){
145
+ std_msgs::msg::String selected_pose_type;
146
+ if (trusted_pose_average_rmse_xy <= gnss_error_reliable_max_ &&
147
+ trusted_pose_yaw_rmse_in_degrees < yaw_error_deg_threshold_) {
148
+ pose_source_ = static_cast <int >(AutowarePoseCovarianceModifierNode::PoseSource::GNSS);
149
+ selected_pose_type.data = " GNSS" ;
150
+ } else if (trusted_pose_average_rmse_xy <= gnss_error_unreliable_min_) {
151
+ pose_source_ = static_cast <int >(AutowarePoseCovarianceModifierNode::PoseSource::GNSS_NDT);
152
+ selected_pose_type.data = " GNSS + NDT" ;
153
+ } else {
154
+ pose_source_ = static_cast <int >(AutowarePoseCovarianceModifierNode::PoseSource::NDT);
155
+ selected_pose_type.data = " NDT" ;
156
+ }
157
+ pose_source_pub_->publish (selected_pose_type);
158
+ }
172
159
int main (int argc, char * argv[])
173
160
{
174
161
rclcpp::init (argc, argv);
0 commit comments