@@ -24,7 +24,7 @@ const std::unordered_map<int, std::string> AirsimROSWrapper::image_type_int_to_s
2424 { 7 , " Infrared" }
2525};
2626
27- AirsimROSWrapper::AirsimROSWrapper (const std::shared_ptr<rclcpp::Node> nh, const std::shared_ptr<rclcpp::Node> nh_img, const std::shared_ptr<rclcpp::Node> nh_lidar, const std::string& host_ip)
27+ AirsimROSWrapper::AirsimROSWrapper (const std::shared_ptr<rclcpp::Node> nh, const std::shared_ptr<rclcpp::Node> nh_img, const std::shared_ptr<rclcpp::Node> nh_lidar, const std::string& host_ip, const std::shared_ptr<rclcpp::CallbackGroup> callback_group )
2828 : is_used_lidar_timer_cb_queue_(false )
2929 , is_used_img_timer_cb_queue_(false )
3030 , airsim_settings_parser_(host_ip)
@@ -35,6 +35,7 @@ AirsimROSWrapper::AirsimROSWrapper(const std::shared_ptr<rclcpp::Node> nh, const
3535 , nh_(nh)
3636 , nh_img_(nh_img)
3737 , nh_lidar_(nh_lidar)
38+ , callback_group_(callback_group)
3839 , isENU_(false )
3940 , publish_clock_(false )
4041{
@@ -109,7 +110,7 @@ void AirsimROSWrapper::initialize_ros()
109110
110111 nh_->declare_parameter (" vehicle_name" , rclcpp::ParameterValue (" " ));
111112 create_ros_pubs_from_settings_json ();
112- airsim_control_update_timer_ = nh_->create_wall_timer (std::chrono::duration<double >(update_airsim_control_every_n_sec), std::bind (&AirsimROSWrapper::drone_state_timer_cb, this ));
113+ airsim_control_update_timer_ = nh_->create_wall_timer (std::chrono::duration<double >(update_airsim_control_every_n_sec), std::bind (&AirsimROSWrapper::drone_state_timer_cb, this ), callback_group_ );
113114}
114115
115116void AirsimROSWrapper::create_ros_pubs_from_settings_json ()
@@ -310,15 +311,15 @@ void AirsimROSWrapper::create_ros_pubs_from_settings_json()
310311 double update_airsim_img_response_every_n_sec;
311312 nh_->get_parameter (" update_airsim_img_response_every_n_sec" , update_airsim_img_response_every_n_sec);
312313
313- airsim_img_response_timer_ = nh_img_->create_wall_timer (std::chrono::duration<double >(update_airsim_img_response_every_n_sec), std::bind (&AirsimROSWrapper::img_response_timer_cb, this ));
314+ airsim_img_response_timer_ = nh_img_->create_wall_timer (std::chrono::duration<double >(update_airsim_img_response_every_n_sec), std::bind (&AirsimROSWrapper::img_response_timer_cb, this ), callback_group_ );
314315 is_used_img_timer_cb_queue_ = true ;
315316 }
316317
317318 // lidars update on their own callback/thread at a given rate
318319 if (lidar_cnt > 0 ) {
319320 double update_lidar_every_n_sec;
320321 nh_->get_parameter (" update_lidar_every_n_sec" , update_lidar_every_n_sec);
321- airsim_lidar_update_timer_ = nh_lidar_->create_wall_timer (std::chrono::duration<double >(update_lidar_every_n_sec), std::bind (&AirsimROSWrapper::lidar_timer_cb, this ));
322+ airsim_lidar_update_timer_ = nh_lidar_->create_wall_timer (std::chrono::duration<double >(update_lidar_every_n_sec), std::bind (&AirsimROSWrapper::lidar_timer_cb, this ), callback_group_ );
322323 is_used_lidar_timer_cb_queue_ = true ;
323324 }
324325
0 commit comments