19
19
AutowarePoseCovarianceModifierNode::AutowarePoseCovarianceModifierNode ()
20
20
: Node(" AutowarePoseCovarianceModifierNode" )
21
21
{
22
- gnss_error_reliable_max_ = this ->declare_parameter <double >(" error_thresholds.gnss_error_reliable_max" , 0.10 );
23
- gnss_error_unreliable_min_ = this ->declare_parameter <double >(" error_thresholds.gnss_error_unreliable_min" , 0.25 );
24
- yaw_error_deg_threshold_ = this ->declare_parameter <double >(" error_thresholds.yaw_error_deg_threshold" , 0.3 );
22
+ gnss_error_reliable_max_ =
23
+ this ->declare_parameter <double >(" error_thresholds.gnss_error_reliable_max" , 0.10 );
24
+ gnss_error_unreliable_min_ =
25
+ this ->declare_parameter <double >(" error_thresholds.gnss_error_unreliable_min" , 0.25 );
26
+ yaw_error_deg_threshold_ =
27
+ this ->declare_parameter <double >(" error_thresholds.yaw_error_deg_threshold" , 0.3 );
25
28
debug_ = this ->declare_parameter <bool >(" debug.enable_debug_topics" , false );
26
29
27
30
trusted_pose_with_cov_sub_ =
@@ -41,23 +44,22 @@ AutowarePoseCovarianceModifierNode::AutowarePoseCovarianceModifierNode()
41
44
42
45
pose_source_pub_ = this ->create_publisher <std_msgs::msg::String>(
43
46
" autoware_pose_covariance_modifier/selected_pose_type" , 10 );
44
- if (debug_){
45
- out_ndt_position_rmse_pub_ = this ->create_publisher <std_msgs::msg::Float32 >(
46
- " /autoware_pose_covariance_modifier/output/ndt_position_rmse" , 10 );
47
- out_gnss_position_rmse_pub_ = this ->create_publisher <std_msgs::msg::Float32 >(
48
- " /autoware_pose_covariance_modifier/output/gnss_position_rmse" , 10 );
47
+ if (debug_) {
48
+ out_ndt_position_rmse_pub_ = this ->create_publisher <std_msgs::msg::Float32 >(
49
+ " /autoware_pose_covariance_modifier/output/ndt_position_rmse" , 10 );
50
+ out_gnss_position_rmse_pub_ = this ->create_publisher <std_msgs::msg::Float32 >(
51
+ " /autoware_pose_covariance_modifier/output/gnss_position_rmse" , 10 );
49
52
}
50
-
51
53
}
52
54
void AutowarePoseCovarianceModifierNode::checkTrustedPoseTimeout ()
53
55
{
54
56
auto timeDiff = this ->now () - trustedPoseCallbackTime;
55
57
if (timeDiff.seconds () > 1.0 ) {
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;
59
- selected_pose_type.data = " NDT" ;
60
- pose_source_pub_->publish (selected_pose_type);
58
+ RCLCPP_WARN (this ->get_logger (), " Trusted Pose Timeout" );
59
+ pose_source_ = static_cast <int >(AutowarePoseCovarianceModifierNode::PoseSource::NDT);
60
+ std_msgs::msg::String selected_pose_type;
61
+ selected_pose_type.data = " NDT" ;
62
+ pose_source_pub_->publish (selected_pose_type);
61
63
}
62
64
}
63
65
@@ -66,32 +68,32 @@ std::array<double, 36> AutowarePoseCovarianceModifierNode::ndt_covariance_modifi
66
68
{
67
69
std::array<double , 36 > ndt_covariance = in_ndt_covariance;
68
70
69
- /*
70
- * ndt_min_rmse_meters = in_ndt_rmse
71
- * ndt_max_rmse_meters = in_ndt_rmse * 2
72
- * ndt_rmse = ndt_max_rmse_meters - (gnss_rmse * (ndt_max_rmse_meters - ndt_min_rmse_meters) /
73
- * normalization_coeff)
74
- */
75
- double normalization_coeff = 0.1 ;
76
- ndt_covariance[0 ] = std::pow (
77
- ((std::sqrt (in_ndt_covariance[0 ]) * 2 ) -
78
- std::sqrt (trusted_source_pose_with_cov.pose .covariance [0 ])) *
79
- (std::sqrt (in_ndt_covariance[0 ])) / normalization_coeff,
80
- 2 );
81
- ndt_covariance[7 ] = std::pow (
82
- ((std::sqrt (in_ndt_covariance[7 ]) * 2 ) -
83
- std::sqrt (trusted_source_pose_with_cov.pose .covariance [7 ])) *
84
- (std::sqrt (in_ndt_covariance[7 ])) / normalization_coeff,
85
- 2 );
86
- ndt_covariance[14 ] = std::pow (
87
- ((std::sqrt (in_ndt_covariance[14 ]) * 2 ) -
88
- std::sqrt (trusted_source_pose_with_cov.pose .covariance [14 ])) *
89
- (std::sqrt (in_ndt_covariance[14 ])) / normalization_coeff,
90
- 2 );
91
-
92
- ndt_covariance[0 ] = std::max (ndt_covariance[0 ], in_ndt_covariance[0 ]);
93
- ndt_covariance[7 ] = std::max (ndt_covariance[7 ], in_ndt_covariance[7 ]);
94
- ndt_covariance[14 ] = std::max (ndt_covariance[14 ], in_ndt_covariance[14 ]);
71
+ /*
72
+ * ndt_min_rmse_meters = in_ndt_rmse
73
+ * ndt_max_rmse_meters = in_ndt_rmse * 2
74
+ * ndt_rmse = ndt_max_rmse_meters - (gnss_rmse * (ndt_max_rmse_meters - ndt_min_rmse_meters) /
75
+ * normalization_coeff)
76
+ */
77
+ double normalization_coeff = 0.1 ;
78
+ ndt_covariance[0 ] = std::pow (
79
+ ((std::sqrt (in_ndt_covariance[0 ]) * 2 ) -
80
+ std::sqrt (trusted_source_pose_with_cov.pose .covariance [0 ])) *
81
+ (std::sqrt (in_ndt_covariance[0 ])) / normalization_coeff,
82
+ 2 );
83
+ ndt_covariance[7 ] = std::pow (
84
+ ((std::sqrt (in_ndt_covariance[7 ]) * 2 ) -
85
+ std::sqrt (trusted_source_pose_with_cov.pose .covariance [7 ])) *
86
+ (std::sqrt (in_ndt_covariance[7 ])) / normalization_coeff,
87
+ 2 );
88
+ ndt_covariance[14 ] = std::pow (
89
+ ((std::sqrt (in_ndt_covariance[14 ]) * 2 ) -
90
+ std::sqrt (trusted_source_pose_with_cov.pose .covariance [14 ])) *
91
+ (std::sqrt (in_ndt_covariance[14 ])) / normalization_coeff,
92
+ 2 );
93
+
94
+ ndt_covariance[0 ] = std::max (ndt_covariance[0 ], in_ndt_covariance[0 ]);
95
+ ndt_covariance[7 ] = std::max (ndt_covariance[7 ], in_ndt_covariance[7 ]);
96
+ ndt_covariance[14 ] = std::max (ndt_covariance[14 ], in_ndt_covariance[14 ]);
95
97
96
98
return ndt_covariance;
97
99
}
@@ -101,16 +103,19 @@ void AutowarePoseCovarianceModifierNode::ndt_pose_with_cov_callback(
101
103
AutowarePoseCovarianceModifierNode::checkTrustedPoseTimeout ();
102
104
103
105
std::array<double , 36 > ndt_covariance_in_ = msg->pose .covariance ;
104
- std::array<double , 36 > out_ndt_covariance_ = pose_source_ == 1 ? ndt_covariance_modifier (ndt_covariance_in_) : ndt_covariance_in_ ;
106
+ std::array<double , 36 > out_ndt_covariance_ =
107
+ pose_source_ == 1 ? ndt_covariance_modifier (ndt_covariance_in_) : ndt_covariance_in_;
105
108
106
109
geometry_msgs::msg::PoseWithCovarianceStamped ndt_pose_with_covariance = *msg;
107
110
ndt_pose_with_covariance.pose .covariance = out_ndt_covariance_;
108
111
if (pose_source_ != 0 ) {
109
112
new_pose_estimator_pub_->publish (ndt_pose_with_covariance);
110
- if (debug_){
111
- std_msgs::msg::Float32 out_ndt_rmse;
112
- out_ndt_rmse.data = (std::sqrt (ndt_pose_with_covariance.pose .covariance [0 ]) + std::sqrt (ndt_pose_with_covariance.pose .covariance [7 ])) / 2 ;
113
- out_ndt_position_rmse_pub_->publish (out_ndt_rmse);
113
+ if (debug_) {
114
+ std_msgs::msg::Float32 out_ndt_rmse;
115
+ out_ndt_rmse.data = (std::sqrt (ndt_pose_with_covariance.pose .covariance [0 ]) +
116
+ std::sqrt (ndt_pose_with_covariance.pose .covariance [7 ])) /
117
+ 2 ;
118
+ out_ndt_position_rmse_pub_->publish (out_ndt_rmse);
114
119
}
115
120
}
116
121
}
@@ -122,9 +127,9 @@ void AutowarePoseCovarianceModifierNode::trusted_pose_with_cov_callback(
122
127
123
128
double trusted_pose_average_rmse_xy;
124
129
double trusted_pose_yaw_rmse_in_degrees;
125
- trusted_pose_average_rmse_xy= (std::sqrt (trusted_source_pose_with_cov.pose .covariance [0 ]) +
126
- std::sqrt (trusted_source_pose_with_cov.pose .covariance [7 ])) /
127
- 2 ;
130
+ trusted_pose_average_rmse_xy = (std::sqrt (trusted_source_pose_with_cov.pose .covariance [0 ]) +
131
+ std::sqrt (trusted_source_pose_with_cov.pose .covariance [7 ])) /
132
+ 2 ;
128
133
129
134
trusted_pose_yaw_rmse_in_degrees =
130
135
std::sqrt (trusted_source_pose_with_cov.pose .covariance [35 ]) * 180 / M_PI;
@@ -133,28 +138,31 @@ void AutowarePoseCovarianceModifierNode::trusted_pose_with_cov_callback(
133
138
134
139
if (pose_source_ != 2 ) {
135
140
new_pose_estimator_pub_->publish (trusted_source_pose_with_cov);
136
- if (debug_){
137
- std_msgs::msg::Float32 out_gnss_rmse;
138
- out_gnss_rmse.data = trusted_pose_average_rmse_xy;
139
- out_gnss_position_rmse_pub_->publish (out_gnss_rmse);
141
+ if (debug_) {
142
+ std_msgs::msg::Float32 out_gnss_rmse;
143
+ out_gnss_rmse.data = trusted_pose_average_rmse_xy;
144
+ out_gnss_position_rmse_pub_->publish (out_gnss_rmse);
140
145
}
141
146
}
142
147
}
143
148
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);
149
+ void AutowarePoseCovarianceModifierNode::selectPositionSource (
150
+ double trusted_pose_average_rmse_xy, double trusted_pose_yaw_rmse_in_degrees)
151
+ {
152
+ std_msgs::msg::String selected_pose_type;
153
+ if (
154
+ trusted_pose_average_rmse_xy <= gnss_error_reliable_max_ &&
155
+ trusted_pose_yaw_rmse_in_degrees < yaw_error_deg_threshold_) {
156
+ pose_source_ = static_cast <int >(AutowarePoseCovarianceModifierNode::PoseSource::GNSS);
157
+ selected_pose_type.data = " GNSS" ;
158
+ } else if (trusted_pose_average_rmse_xy <= gnss_error_unreliable_min_) {
159
+ pose_source_ = static_cast <int >(AutowarePoseCovarianceModifierNode::PoseSource::GNSS_NDT);
160
+ selected_pose_type.data = " GNSS + NDT" ;
161
+ } else {
162
+ pose_source_ = static_cast <int >(AutowarePoseCovarianceModifierNode::PoseSource::NDT);
163
+ selected_pose_type.data = " NDT" ;
164
+ }
165
+ pose_source_pub_->publish (selected_pose_type);
158
166
}
159
167
int main (int argc, char * argv[])
160
168
{
0 commit comments