@@ -24,7 +24,19 @@ ESKFNode::ESKFNode(const rclcpp::NodeOptions& options)
2424 }
2525 spdlog::info (" frame_prefix set to '{}'" , frame_prefix_);
2626
27- publish_tf_ = this ->declare_parameter <bool >(" publish_tf" );
27+ publish_debug_ = this ->declare_parameter <bool >(" publish_debug" );
28+ if (publish_debug_) {
29+ spdlog::info (
30+ " Debug output enabled: Publishing ESKF outputs on debug/private "
31+ " topics and disabling TF publishing." );
32+ } else {
33+ spdlog::info (
34+ " Debug output disabled: Publishing ESKF outputs on standard topics "
35+ " and enabling TF publishing." );
36+ }
37+
38+ publish_tf_ =
39+ this ->declare_parameter <bool >(" publish_tf" ) && !publish_debug_;
2840 if (publish_tf_) {
2941 tf_broadcaster_ =
3042 std::make_unique<tf2_ros::TransformBroadcaster>(*this );
@@ -35,8 +47,6 @@ ESKFNode::ESKFNode(const rclcpp::NodeOptions& options)
3547
3648 publish_biases_ = this ->declare_parameter <bool >(" publish_biases" );
3749
38- // Declare these here so they appear in `ros2 param list` from startup,
39- // even though they are read in complete_initialization().
4050 this ->declare_parameter <int >(" publish_rate_ms" );
4151 this ->declare_parameter <std::string>(" topics.imu" );
4252 this ->declare_parameter <std::string>(" topics.dvl_twist" );
@@ -65,26 +75,46 @@ void ESKFNode::set_subscribers_and_publisher() {
6575 std::string imu_topic = this ->get_parameter (" topics.imu" ).as_string ();
6676 imu_sub_ = this ->create_subscription <sensor_msgs::msg::Imu>(
6777 imu_topic, qos_sensor_data,
68- std::bind (&ESKFNode::imu_callback, this , std::placeholders::_1));
78+ [this ](const sensor_msgs::msg::Imu::ConstSharedPtr msg) {
79+ imu_callback (msg);
80+ });
6981
7082 std::string dvl_topic = this ->get_parameter (" topics.dvl_twist" ).as_string ();
7183 dvl_sub_ = this ->create_subscription <
7284 geometry_msgs::msg::TwistWithCovarianceStamped>(
7385 dvl_topic, qos_sensor_data,
74- std::bind (&ESKFNode::dvl_callback, this , std::placeholders::_1));
86+ [this ](
87+ const geometry_msgs::msg::TwistWithCovarianceStamped::ConstSharedPtr
88+ msg) { dvl_callback (msg); });
7589
7690 std::string pressure_topic =
7791 this ->get_parameter (" topics.pressure_sensor" ).as_string ();
7892 depth_sub_ = this ->create_subscription <sensor_msgs::msg::FluidPressure>(
7993 pressure_topic, qos_sensor_data,
80- std::bind (&ESKFNode::depth_callback, this , std::placeholders::_1));
94+ [this ](const sensor_msgs::msg::FluidPressure::ConstSharedPtr msg) {
95+ pressure_callback (msg);
96+ });
97+
98+ auto eskf_debug_topic = [](std::string& topic_name) {
99+ const std::string prefix = " eskf/" ;
100+
101+ if (topic_name.rfind (prefix, 0 ) != 0 ) {
102+ topic_name = prefix + topic_name;
103+ }
104+ };
81105
82106 std::string odom_topic = this ->get_parameter (" topics.odom" ).as_string ();
107+ if (publish_debug_) {
108+ eskf_debug_topic (odom_topic);
109+ }
83110 odom_pub_ = this ->create_publisher <nav_msgs::msg::Odometry>(
84111 odom_topic, qos_sensor_data);
85112
86113 if (publish_pose_) {
87114 std::string pose_topic = this ->get_parameter (" topics.pose" ).as_string ();
115+ if (publish_debug_) {
116+ eskf_debug_topic (pose_topic);
117+ }
88118 pose_pub_ = this ->create_publisher <
89119 geometry_msgs::msg::PoseWithCovarianceStamped>(pose_topic,
90120 qos_sensor_data);
@@ -93,6 +123,9 @@ void ESKFNode::set_subscribers_and_publisher() {
93123 if (publish_twist_) {
94124 std::string twist_topic =
95125 this ->get_parameter (" topics.twist" ).as_string ();
126+ if (publish_debug_) {
127+ eskf_debug_topic (twist_topic);
128+ }
96129 twist_pub_ = this ->create_publisher <
97130 geometry_msgs::msg::TwistWithCovarianceStamped>(twist_topic,
98131 qos_sensor_data);
@@ -202,7 +235,7 @@ void ESKFNode::set_parameters() {
202235 spdlog::info (" add_gravity_to_imu: {}" , add_gravity_to_imu_);
203236}
204237
205- void ESKFNode::imu_callback (const sensor_msgs::msg::Imu::SharedPtr msg) {
238+ void ESKFNode::imu_callback (const sensor_msgs::msg::Imu::ConstSharedPtr msg) {
206239 rclcpp::Time current_time = msg->header .stamp ;
207240
208241 if (!first_imu_msg_received_) {
@@ -253,7 +286,7 @@ void ESKFNode::imu_callback(const sensor_msgs::msg::Imu::SharedPtr msg) {
253286}
254287
255288void ESKFNode::dvl_callback (
256- const geometry_msgs::msg::TwistWithCovarianceStamped::SharedPtr msg) {
289+ const geometry_msgs::msg::TwistWithCovarianceStamped::ConstSharedPtr msg) {
257290 SensorDVL dvl_sensor;
258291
259292 dvl_sensor.measurement << msg->twist .twist .linear .x ,
@@ -286,8 +319,8 @@ void ESKFNode::dvl_callback(
286319#endif
287320}
288321
289- void ESKFNode::depth_callback (
290- const sensor_msgs::msg::FluidPressure::SharedPtr msg) {
322+ void ESKFNode::pressure_callback (
323+ const sensor_msgs::msg::FluidPressure::ConstSharedPtr msg) {
291324 SensorDepth depth_sensor;
292325 // the simulation is a gauge sensor so we don't subtract atmospheric
293326 // pressure.
@@ -448,8 +481,8 @@ void ESKFNode::complete_initialization() {
448481
449482 time_step_ = std::chrono::milliseconds (
450483 this ->get_parameter (" publish_rate_ms" ).as_int ());
451- odom_pub_timer_ = this -> create_wall_timer (
452- time_step_, std::bind (&ESKFNode::publish_odom, this ) );
484+ odom_pub_timer_ =
485+ this -> create_wall_timer ( time_step_, [ this ]() { publish_odom (); } );
453486
454487 spdlog::info (start_message);
455488
0 commit comments