16
16
17
17
#include < rclcpp/rclcpp.hpp>
18
18
19
- AutowarePoseCovarianceModifierNode::AutowarePoseCovarianceModifierNode () : Node(" AutowarePoseCovarianceModifierNode" )
19
+ AutowarePoseCovarianceModifierNode::AutowarePoseCovarianceModifierNode ()
20
+ : Node(" AutowarePoseCovarianceModifierNode" )
20
21
{
21
22
trusted_pose_with_cov_sub_ =
22
23
this ->create_subscription <geometry_msgs::msg::PoseWithCovarianceStamped>(
@@ -25,110 +26,113 @@ AutowarePoseCovarianceModifierNode::AutowarePoseCovarianceModifierNode() : Node(
25
26
&AutowarePoseCovarianceModifierNode::trusted_pose_with_cov_callback, this ,
26
27
std::placeholders::_1));
27
28
28
- ndt_pose_with_cov_sub_ =
29
- this ->create_subscription <geometry_msgs::msg::PoseWithCovarianceStamped>(
30
- " input_ndt_pose_with_cov_topic" , 10000 ,
31
- std::bind (
32
- &AutowarePoseCovarianceModifierNode::ndt_pose_with_cov_callback, this ,
33
- std::placeholders::_1));
34
- new_pose_estimator_pub_ =
35
- this ->create_publisher <geometry_msgs::msg::PoseWithCovarianceStamped>(
36
- " output_pose_with_covariance_topic" , 10 );
37
-
38
- pose_source_pub_ =
39
- this ->create_publisher <std_msgs::msg::String>(
40
- " autoware_pose_covariance_modifier/selected_pose_type" ,10 );
29
+ ndt_pose_with_cov_sub_ = this ->create_subscription <geometry_msgs::msg::PoseWithCovarianceStamped>(
30
+ " input_ndt_pose_with_cov_topic" , 10000 ,
31
+ std::bind (
32
+ &AutowarePoseCovarianceModifierNode::ndt_pose_with_cov_callback, this ,
33
+ std::placeholders::_1));
34
+ new_pose_estimator_pub_ = this ->create_publisher <geometry_msgs::msg::PoseWithCovarianceStamped>(
35
+ " output_pose_with_covariance_topic" , 10 );
41
36
37
+ pose_source_pub_ = this ->create_publisher <std_msgs::msg::String>(
38
+ " autoware_pose_covariance_modifier/selected_pose_type" , 10 );
42
39
}
43
40
bool AutowarePoseCovarianceModifierNode::checkTrustedPoseTimeout ()
44
41
{
45
- auto timeDiff = this ->now () - trustedPoseCallbackTime;
46
- if (timeDiff.seconds () > 1.0 ) {
47
- return true ;
48
- }
49
- return false ;
42
+ auto timeDiff = this ->now () - trustedPoseCallbackTime;
43
+ if (timeDiff.seconds () > 1.0 ) {
44
+ return true ;
45
+ }
46
+ return false ;
50
47
}
51
- void AutowarePoseCovarianceModifierNode::publishPoseSource (){
52
-
53
- std_msgs::msg::String selected_pose_type;
54
- switch (pose_source_) {
55
- case static_cast <int >(AutowarePoseCovarianceModifierNode::PoseSource::GNSS):
56
- selected_pose_type.data = " GNSS" ;
57
- break ;
58
- case static_cast <int >(AutowarePoseCovarianceModifierNode::PoseSource::GNSS_NDT):
59
- selected_pose_type.data = " GNSS_NDT" ;
60
- break ;
61
- case static_cast <int >(AutowarePoseCovarianceModifierNode::PoseSource::NDT):
62
- selected_pose_type.data = " NDT" ;
63
- break ;
64
- default :
65
- selected_pose_type.data = " Unknown" ;
66
- break ;
67
- }
68
- pose_source_pub_->publish (selected_pose_type);
48
+ void AutowarePoseCovarianceModifierNode::publishPoseSource ()
49
+ {
50
+ std_msgs::msg::String selected_pose_type;
51
+ switch (pose_source_) {
52
+ case static_cast <int >(AutowarePoseCovarianceModifierNode::PoseSource::GNSS):
53
+ selected_pose_type.data = " GNSS" ;
54
+ break ;
55
+ case static_cast <int >(AutowarePoseCovarianceModifierNode::PoseSource::GNSS_NDT):
56
+ selected_pose_type.data = " GNSS_NDT" ;
57
+ break ;
58
+ case static_cast <int >(AutowarePoseCovarianceModifierNode::PoseSource::NDT):
59
+ selected_pose_type.data = " NDT" ;
60
+ break ;
61
+ default :
62
+ selected_pose_type.data = " Unknown" ;
63
+ break ;
64
+ }
65
+ pose_source_pub_->publish (selected_pose_type);
69
66
}
70
67
std::array<double , 36 > AutowarePoseCovarianceModifierNode::ndt_covariance_modifier (
71
- std::array<double , 36 > & in_ndt_covariance)
68
+ std::array<double , 36 > & in_ndt_covariance)
72
69
{
73
- std::array<double , 36 > ndt_covariance = in_ndt_covariance;
74
-
75
- double position_error_threshold_1_ = this ->declare_parameter <double >(" PositionErrorThreshold_1" ,0.10 );
76
- double position_error_threshold_2_ = this ->declare_parameter <double >(" PositionErrorThreshold_2" ,0.25 );
77
- double yaw_error_threshold_ = this ->declare_parameter <double >(" YawErrorThreshold" ,0.3 );
78
-
79
- if (AutowarePoseCovarianceModifierNode::checkTrustedPoseTimeout ()) {
80
- RCLCPP_WARN (this ->get_logger (), " Trusted Pose Timeout" );
81
- pose_source_ = static_cast <int >(AutowarePoseCovarianceModifierNode::PoseSource::NDT);
82
- return ndt_covariance;
83
- }
84
-
85
- if (trustedPose.pose_average_rmse_xy <= position_error_threshold_1_ &&
86
- trustedPose.yaw_rmse_in_degrees < yaw_error_threshold_) {
87
- pose_source_ = static_cast <int >(AutowarePoseCovarianceModifierNode::PoseSource::GNSS);
88
- } else if (trustedPose.pose_average_rmse_xy <= position_error_threshold_2_) {
89
- /*
90
- * ndt_min_rmse_meters = in_ndt_rmse
91
- * ndt_max_rmse_meters = in_ndt_rmse * 2
92
- * ndt_rmse = ndt_max_rmse_meters - (gnss_rmse * (ndt_max_rmse_meters - ndt_min_rmse_meters) / normalization_coeff)
93
- */
94
- double normalization_coeff = 0.1 ;
95
- ndt_covariance[0 ] = std::pow (
96
- ((std::sqrt (in_ndt_covariance[0 ]) * 2 ) - std::sqrt (trusted_source_pose_with_cov.pose .covariance [0 ])) *
97
- (std::sqrt (in_ndt_covariance[0 ])) / normalization_coeff,
98
- 2 );
99
- ndt_covariance[7 ] = std::pow (
100
- ((std::sqrt (in_ndt_covariance[7 ]) * 2 ) - std::sqrt (trusted_source_pose_with_cov.pose .covariance [7 ])) *
101
- (std::sqrt (in_ndt_covariance[7 ])) / normalization_coeff,
102
- 2 );
103
- ndt_covariance[14 ] = std::pow (
104
- ((std::sqrt (in_ndt_covariance[14 ]) * 2 ) -
105
- std::sqrt (trusted_source_pose_with_cov.pose .covariance [14 ])) *
106
- (std::sqrt (in_ndt_covariance[14 ])) / normalization_coeff,
107
- 2 );
108
-
109
- ndt_covariance[0 ] = std::max (ndt_covariance[0 ], in_ndt_covariance[0 ]);
110
- ndt_covariance[7 ] = std::max (ndt_covariance[7 ], in_ndt_covariance[7 ]);
111
- ndt_covariance[14 ] = std::max (ndt_covariance[14 ], in_ndt_covariance[14 ]);
112
-
113
- pose_source_ = static_cast <int >(AutowarePoseCovarianceModifierNode::PoseSource::GNSS_NDT);
114
- } else {
115
- RCLCPP_INFO (this ->get_logger (), " NDT input covariance values will be used " );
116
- pose_source_ = static_cast <int >(AutowarePoseCovarianceModifierNode::PoseSource::NDT);
117
- }
118
-
119
- publishPoseSource ();
70
+ std::array<double , 36 > ndt_covariance = in_ndt_covariance;
120
71
72
+ double position_error_threshold_1_ =
73
+ this ->declare_parameter <double >(" PositionErrorThreshold_1" , 0.10 );
74
+ double position_error_threshold_2_ =
75
+ this ->declare_parameter <double >(" PositionErrorThreshold_2" , 0.25 );
76
+ double yaw_error_threshold_ = this ->declare_parameter <double >(" YawErrorThreshold" , 0.3 );
77
+
78
+ if (AutowarePoseCovarianceModifierNode::checkTrustedPoseTimeout ()) {
79
+ RCLCPP_WARN (this ->get_logger (), " Trusted Pose Timeout" );
80
+ pose_source_ = static_cast <int >(AutowarePoseCovarianceModifierNode::PoseSource::NDT);
121
81
return ndt_covariance;
122
- }
123
- void AutowarePoseCovarianceModifierNode::ndt_pose_with_cov_callback (const geometry_msgs::msg::PoseWithCovarianceStamped::ConstSharedPtr & msg){
82
+ }
124
83
125
- std::array<double , 36 > ndt_covariance_in_ = msg->pose .covariance ;
84
+ if (
85
+ trustedPose.pose_average_rmse_xy <= position_error_threshold_1_ &&
86
+ trustedPose.yaw_rmse_in_degrees < yaw_error_threshold_) {
87
+ pose_source_ = static_cast <int >(AutowarePoseCovarianceModifierNode::PoseSource::GNSS);
88
+ } else if (trustedPose.pose_average_rmse_xy <= position_error_threshold_2_) {
89
+ /*
90
+ * ndt_min_rmse_meters = in_ndt_rmse
91
+ * ndt_max_rmse_meters = in_ndt_rmse * 2
92
+ * ndt_rmse = ndt_max_rmse_meters - (gnss_rmse * (ndt_max_rmse_meters - ndt_min_rmse_meters) /
93
+ * normalization_coeff)
94
+ */
95
+ double normalization_coeff = 0.1 ;
96
+ ndt_covariance[0 ] = std::pow (
97
+ ((std::sqrt (in_ndt_covariance[0 ]) * 2 ) -
98
+ std::sqrt (trusted_source_pose_with_cov.pose .covariance [0 ])) *
99
+ (std::sqrt (in_ndt_covariance[0 ])) / normalization_coeff,
100
+ 2 );
101
+ ndt_covariance[7 ] = std::pow (
102
+ ((std::sqrt (in_ndt_covariance[7 ]) * 2 ) -
103
+ std::sqrt (trusted_source_pose_with_cov.pose .covariance [7 ])) *
104
+ (std::sqrt (in_ndt_covariance[7 ])) / normalization_coeff,
105
+ 2 );
106
+ ndt_covariance[14 ] = std::pow (
107
+ ((std::sqrt (in_ndt_covariance[14 ]) * 2 ) -
108
+ std::sqrt (trusted_source_pose_with_cov.pose .covariance [14 ])) *
109
+ (std::sqrt (in_ndt_covariance[14 ])) / normalization_coeff,
110
+ 2 );
111
+
112
+ ndt_covariance[0 ] = std::max (ndt_covariance[0 ], in_ndt_covariance[0 ]);
113
+ ndt_covariance[7 ] = std::max (ndt_covariance[7 ], in_ndt_covariance[7 ]);
114
+ ndt_covariance[14 ] = std::max (ndt_covariance[14 ], in_ndt_covariance[14 ]);
115
+
116
+ pose_source_ = static_cast <int >(AutowarePoseCovarianceModifierNode::PoseSource::GNSS_NDT);
117
+ } else {
118
+ RCLCPP_INFO (this ->get_logger (), " NDT input covariance values will be used " );
119
+ pose_source_ = static_cast <int >(AutowarePoseCovarianceModifierNode::PoseSource::NDT);
120
+ }
121
+
122
+ publishPoseSource ();
123
+
124
+ return ndt_covariance;
125
+ }
126
+ void AutowarePoseCovarianceModifierNode::ndt_pose_with_cov_callback (
127
+ const geometry_msgs::msg::PoseWithCovarianceStamped::ConstSharedPtr & msg)
128
+ {
129
+ std::array<double , 36 > ndt_covariance_in_ = msg->pose .covariance ;
126
130
std::array<double , 36 > out_ndt_covariance_ = ndt_covariance_modifier (ndt_covariance_in_);
127
131
128
132
geometry_msgs::msg::PoseWithCovarianceStamped ndt_pose_with_covariance = *msg;
129
133
ndt_pose_with_covariance.pose .covariance = out_ndt_covariance_;
130
- if (pose_source_ != 0 ){
131
- new_pose_estimator_pub_->publish (ndt_pose_with_covariance);
134
+ if (pose_source_ != 0 ) {
135
+ new_pose_estimator_pub_->publish (ndt_pose_with_covariance);
132
136
}
133
137
}
134
138
void AutowarePoseCovarianceModifierNode::trusted_pose_with_cov_callback (
@@ -138,14 +142,14 @@ void AutowarePoseCovarianceModifierNode::trusted_pose_with_cov_callback(
138
142
trusted_source_pose_with_cov = *msg;
139
143
140
144
trustedPose.pose_average_rmse_xy = (std::sqrt (trusted_source_pose_with_cov.pose .covariance [0 ]) +
141
- std::sqrt (trusted_source_pose_with_cov.pose .covariance [7 ])) /
142
- 2 ;
145
+ std::sqrt (trusted_source_pose_with_cov.pose .covariance [7 ])) /
146
+ 2 ;
143
147
144
148
trustedPose.yaw_rmse_in_degrees =
145
- std::sqrt (trusted_source_pose_with_cov.pose .covariance [35 ]) * 180 / M_PI;
149
+ std::sqrt (trusted_source_pose_with_cov.pose .covariance [35 ]) * 180 / M_PI;
146
150
147
- if (pose_source_ != 2 ) {
148
- new_pose_estimator_pub_->publish (trusted_source_pose_with_cov);
151
+ if (pose_source_ != 2 ) {
152
+ new_pose_estimator_pub_->publish (trusted_source_pose_with_cov);
149
153
}
150
154
}
151
155
int main (int argc, char * argv[])
0 commit comments