@@ -36,25 +36,27 @@ GNSSPoser::GNSSPoser(const rclcpp::NodeOptions & node_options)
36
36
use_gnss_ins_orientation_(declare_parameter<bool >(" use_gnss_ins_orientation" )),
37
37
msg_gnss_ins_orientation_stamped_(
38
38
std::make_shared<autoware_sensing_msgs::msg::GnssInsOrientationStamped>()),
39
- gnss_pose_pub_method( declare_parameter<int >(" gnss_pose_pub_method" ))
39
+ gnss_pose_pub_method_( static_cast < int >( declare_parameter<int >(" gnss_pose_pub_method" ) ))
40
40
{
41
41
// Subscribe to map_projector_info topic
42
42
const auto adaptor = component_interface_utils::NodeAdaptor (this );
43
43
adaptor.init_sub (
44
- sub_map_projector_info_,
45
- [this ](const MapProjectorInfo::Message::ConstSharedPtr msg) { callbackMapProjectorInfo (msg); });
44
+ sub_map_projector_info_, [this ](const MapProjectorInfo::Message::ConstSharedPtr msg) {
45
+ callback_map_projector_info (msg);
46
+ });
46
47
47
48
// Set up position buffer
48
- int buff_epoch = declare_parameter<int >(" buff_epoch" );
49
+ int buff_epoch = static_cast < int >( declare_parameter<int >(" buff_epoch" ) );
49
50
position_buffer_.set_capacity (buff_epoch);
50
51
51
52
// Set subscribers and publishers
52
53
nav_sat_fix_sub_ = create_subscription<sensor_msgs::msg::NavSatFix>(
53
- " fix" , rclcpp::QoS{1 }, std::bind (&GNSSPoser::callbackNavSatFix, this , std::placeholders::_1));
54
+ " fix" , rclcpp::QoS{1 },
55
+ std::bind (&GNSSPoser::callback_nav_sat_fix, this , std::placeholders::_1));
54
56
autoware_orientation_sub_ =
55
57
create_subscription<autoware_sensing_msgs::msg::GnssInsOrientationStamped>(
56
58
" autoware_orientation" , rclcpp::QoS{1 },
57
- std::bind (&GNSSPoser::callbackGnssInsOrientationStamped , this , std::placeholders::_1));
59
+ std::bind (&GNSSPoser::callback_gnss_ins_orientation_stamped , this , std::placeholders::_1));
58
60
59
61
pose_pub_ = create_publisher<geometry_msgs::msg::PoseStamped>(" gnss_pose" , rclcpp::QoS{1 });
60
62
pose_cov_pub_ = create_publisher<geometry_msgs::msg::PoseWithCovarianceStamped>(
@@ -68,13 +70,13 @@ GNSSPoser::GNSSPoser(const rclcpp::NodeOptions & node_options)
68
70
msg_gnss_ins_orientation_stamped_->orientation .rmse_rotation_z = 1.0 ;
69
71
}
70
72
71
- void GNSSPoser::callbackMapProjectorInfo (const MapProjectorInfo::Message::ConstSharedPtr msg)
73
+ void GNSSPoser::callback_map_projector_info (const MapProjectorInfo::Message::ConstSharedPtr msg)
72
74
{
73
75
projector_info_ = *msg;
74
76
received_map_projector_info_ = true ;
75
77
}
76
78
77
- void GNSSPoser::callbackNavSatFix (
79
+ void GNSSPoser::callback_nav_sat_fix (
78
80
const sensor_msgs::msg::NavSatFix::ConstSharedPtr nav_sat_fix_msg_ptr)
79
81
{
80
82
// Return immediately if map_projector_info has not been received yet.
@@ -94,15 +96,15 @@ void GNSSPoser::callbackNavSatFix(
94
96
}
95
97
96
98
// check fixed topic
97
- const bool is_fixed = isFixed (nav_sat_fix_msg_ptr->status );
99
+ const bool is_status_fixed = is_fixed (nav_sat_fix_msg_ptr->status );
98
100
99
101
// publish is_fixed topic
100
102
tier4_debug_msgs::msg::BoolStamped is_fixed_msg;
101
103
is_fixed_msg.stamp = this ->now ();
102
- is_fixed_msg.data = is_fixed ;
104
+ is_fixed_msg.data = is_status_fixed ;
103
105
fixed_pub_->publish (is_fixed_msg);
104
106
105
- if (!is_fixed ) {
107
+ if (!is_status_fixed ) {
106
108
RCLCPP_WARN_STREAM_THROTTLE (
107
109
this ->get_logger (), *this ->get_clock (), std::chrono::milliseconds (1000 ).count (),
108
110
" Not Fixed Topic. Skipping Calculate." );
@@ -122,7 +124,7 @@ void GNSSPoser::callbackNavSatFix(
122
124
geometry_msgs::msg::Pose gnss_antenna_pose{};
123
125
124
126
// publish pose immediately
125
- if (!gnss_pose_pub_method ) {
127
+ if (!gnss_pose_pub_method_ ) {
126
128
gnss_antenna_pose.position = position;
127
129
} else {
128
130
// fill position buffer
@@ -134,8 +136,9 @@ void GNSSPoser::callbackNavSatFix(
134
136
return ;
135
137
}
136
138
// publish average pose or median pose of position buffer
137
- gnss_antenna_pose.position = (gnss_pose_pub_method == 1 ) ? getAveragePosition (position_buffer_)
138
- : getMedianPosition (position_buffer_);
139
+ gnss_antenna_pose.position = (gnss_pose_pub_method_ == 1 )
140
+ ? get_average_position (position_buffer_)
141
+ : get_median_position (position_buffer_);
139
142
}
140
143
141
144
// calc gnss antenna orientation
@@ -144,7 +147,7 @@ void GNSSPoser::callbackNavSatFix(
144
147
orientation = msg_gnss_ins_orientation_stamped_->orientation .orientation ;
145
148
} else {
146
149
static auto prev_position = gnss_antenna_pose.position ;
147
- orientation = getQuaternionByPositionDifference (gnss_antenna_pose.position , prev_position);
150
+ orientation = get_quaternion_by_position_difference (gnss_antenna_pose.position , prev_position);
148
151
prev_position = gnss_antenna_pose.position ;
149
152
}
150
153
@@ -157,7 +160,7 @@ void GNSSPoser::callbackNavSatFix(
157
160
auto tf_gnss_antenna2base_link_msg_ptr = std::make_shared<geometry_msgs::msg::TransformStamped>();
158
161
159
162
const std::string gnss_frame = nav_sat_fix_msg_ptr->header .frame_id ;
160
- getStaticTransform (
163
+ get_static_transform (
161
164
gnss_frame, base_frame_, tf_gnss_antenna2base_link_msg_ptr, nav_sat_fix_msg_ptr->header .stamp );
162
165
tf2::Transform tf_gnss_antenna2base_link{};
163
166
tf2::fromMsg (tf_gnss_antenna2base_link_msg_ptr->transform , tf_gnss_antenna2base_link);
@@ -179,11 +182,11 @@ void GNSSPoser::callbackNavSatFix(
179
182
gnss_base_pose_cov_msg.header = gnss_base_pose_msg.header ;
180
183
gnss_base_pose_cov_msg.pose .pose = gnss_base_pose_msg.pose ;
181
184
gnss_base_pose_cov_msg.pose .covariance [7 * 0 ] =
182
- canGetCovariance (*nav_sat_fix_msg_ptr) ? nav_sat_fix_msg_ptr->position_covariance [0 ] : 10.0 ;
185
+ can_get_covariance (*nav_sat_fix_msg_ptr) ? nav_sat_fix_msg_ptr->position_covariance [0 ] : 10.0 ;
183
186
gnss_base_pose_cov_msg.pose .covariance [7 * 1 ] =
184
- canGetCovariance (*nav_sat_fix_msg_ptr) ? nav_sat_fix_msg_ptr->position_covariance [4 ] : 10.0 ;
187
+ can_get_covariance (*nav_sat_fix_msg_ptr) ? nav_sat_fix_msg_ptr->position_covariance [4 ] : 10.0 ;
185
188
gnss_base_pose_cov_msg.pose .covariance [7 * 2 ] =
186
- canGetCovariance (*nav_sat_fix_msg_ptr) ? nav_sat_fix_msg_ptr->position_covariance [8 ] : 10.0 ;
189
+ can_get_covariance (*nav_sat_fix_msg_ptr) ? nav_sat_fix_msg_ptr->position_covariance [8 ] : 10.0 ;
187
190
188
191
if (use_gnss_ins_orientation_) {
189
192
gnss_base_pose_cov_msg.pose .covariance [7 * 3 ] =
@@ -201,30 +204,30 @@ void GNSSPoser::callbackNavSatFix(
201
204
pose_cov_pub_->publish (gnss_base_pose_cov_msg);
202
205
203
206
// broadcast map to gnss_base_link
204
- publishTF (map_frame_, gnss_base_frame_, gnss_base_pose_msg);
207
+ publish_tf (map_frame_, gnss_base_frame_, gnss_base_pose_msg);
205
208
}
206
209
207
- void GNSSPoser::callbackGnssInsOrientationStamped (
210
+ void GNSSPoser::callback_gnss_ins_orientation_stamped (
208
211
const autoware_sensing_msgs::msg::GnssInsOrientationStamped::ConstSharedPtr msg)
209
212
{
210
213
*msg_gnss_ins_orientation_stamped_ = *msg;
211
214
}
212
215
213
- bool GNSSPoser::isFixed (const sensor_msgs::msg::NavSatStatus & nav_sat_status_msg)
216
+ bool GNSSPoser::is_fixed (const sensor_msgs::msg::NavSatStatus & nav_sat_status_msg)
214
217
{
215
218
return nav_sat_status_msg.status >= sensor_msgs::msg::NavSatStatus::STATUS_FIX;
216
219
}
217
220
218
- bool GNSSPoser::canGetCovariance (const sensor_msgs::msg::NavSatFix & nav_sat_fix_msg)
221
+ bool GNSSPoser::can_get_covariance (const sensor_msgs::msg::NavSatFix & nav_sat_fix_msg)
219
222
{
220
223
return nav_sat_fix_msg.position_covariance_type >
221
224
sensor_msgs::msg::NavSatFix::COVARIANCE_TYPE_UNKNOWN;
222
225
}
223
226
224
- geometry_msgs::msg::Point GNSSPoser::getMedianPosition (
227
+ geometry_msgs::msg::Point GNSSPoser::get_median_position (
225
228
const boost::circular_buffer<geometry_msgs::msg::Point > & position_buffer)
226
229
{
227
- auto getMedian = [](std::vector<double > array) {
230
+ auto get_median = [](std::vector<double > array) {
228
231
std::sort (std::begin (array), std::end (array));
229
232
const size_t median_index = array.size () / 2 ;
230
233
double median = (array.size () % 2 )
@@ -243,13 +246,13 @@ geometry_msgs::msg::Point GNSSPoser::getMedianPosition(
243
246
}
244
247
245
248
geometry_msgs::msg::Point median_point;
246
- median_point.x = getMedian (array_x);
247
- median_point.y = getMedian (array_y);
248
- median_point.z = getMedian (array_z);
249
+ median_point.x = get_median (array_x);
250
+ median_point.y = get_median (array_y);
251
+ median_point.z = get_median (array_z);
249
252
return median_point;
250
253
}
251
254
252
- geometry_msgs::msg::Point GNSSPoser::getAveragePosition (
255
+ geometry_msgs::msg::Point GNSSPoser::get_average_position (
253
256
const boost::circular_buffer<geometry_msgs::msg::Point > & position_buffer)
254
257
{
255
258
std::vector<double > array_x;
@@ -271,7 +274,7 @@ geometry_msgs::msg::Point GNSSPoser::getAveragePosition(
271
274
return average_point;
272
275
}
273
276
274
- geometry_msgs::msg::Quaternion GNSSPoser::getQuaternionByHeading (const int heading)
277
+ geometry_msgs::msg::Quaternion GNSSPoser::get_quaternion_by_heading (const int heading)
275
278
{
276
279
int heading_conv = 0 ;
277
280
// convert heading[0(North)~360] to yaw[-M_PI(West)~M_PI]
@@ -288,7 +291,7 @@ geometry_msgs::msg::Quaternion GNSSPoser::getQuaternionByHeading(const int headi
288
291
return tf2::toMsg (quaternion);
289
292
}
290
293
291
- geometry_msgs::msg::Quaternion GNSSPoser::getQuaternionByPositionDifference (
294
+ geometry_msgs::msg::Quaternion GNSSPoser::get_quaternion_by_position_difference (
292
295
const geometry_msgs::msg::Point & point, const geometry_msgs::msg::Point & prev_point)
293
296
{
294
297
const double yaw = std::atan2 (point.y - prev_point.y , point.x - prev_point.x );
@@ -297,7 +300,7 @@ geometry_msgs::msg::Quaternion GNSSPoser::getQuaternionByPositionDifference(
297
300
return tf2::toMsg (quaternion);
298
301
}
299
302
300
- bool GNSSPoser::getTransform (
303
+ bool GNSSPoser::get_transform (
301
304
const std::string & target_frame, const std::string & source_frame,
302
305
const geometry_msgs::msg::TransformStamped::SharedPtr transform_stamped_ptr)
303
306
{
@@ -340,7 +343,7 @@ bool GNSSPoser::getTransform(
340
343
return true ;
341
344
}
342
345
343
- bool GNSSPoser::getStaticTransform (
346
+ bool GNSSPoser::get_static_transform (
344
347
const std::string & target_frame, const std::string & source_frame,
345
348
const geometry_msgs::msg::TransformStamped::SharedPtr transform_stamped_ptr,
346
349
const builtin_interfaces::msg::Time & stamp)
@@ -385,7 +388,7 @@ bool GNSSPoser::getStaticTransform(
385
388
return true ;
386
389
}
387
390
388
- void GNSSPoser::publishTF (
391
+ void GNSSPoser::publish_tf (
389
392
const std::string & frame_id, const std::string & child_frame_id,
390
393
const geometry_msgs::msg::PoseStamped & pose_msg)
391
394
{
0 commit comments