ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How do I generate logging messages from inside a ros2_control hardware interface?

asked 2023-05-26 09:56:49 -0500

PierceNichols gravatar image

I'm working on a custom hardware interface plugin for ros2_control and I'm not sure how to generate log messages from inside the plugin. I'd like to log hardware issues in general and it would also help with debugging & development. How do I get a logger object from inside the hardware interface so I can generate log messages?

My system is ROS2 Humble running on Ubuntu 22.04 LTS

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-05-26 21:30:56 -0500

PierceNichols gravatar image

Figured out the answer on my own... I need to call the function rclcpp::get_logger() rather than the get_logger() method of rclcpp::Node.

For a test I added the following lines to the on_init() method:

rclcpp::Logger loger = rclcpp::get_logger("test_logger");
RCLCPP_INFO(logger, "Logging test");

Which resulted in the output:

[ros2_control_node-1] [INFO] [1685153874.083490048] [test_logger]: Logging test

And that's what I needed. Hopefully this will help someone else who doesn't read the code quite closely enough.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2023-05-26 09:56:49 -0500

Seen: 164 times

Last updated: May 26 '23