ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

ros publisher not publishing in debug

asked 2021-12-22 14:01:36 -0500

Nachum gravatar image


I'm running my node in debug (vscode) and getting weird results. I have a loop which is publishing to a motor

while (std::abs(orientation.roll) > ROLL_FLAT_SURFACE)
    bla bla bla



if I put a breakpoint before and after the loop and run in debug the publisher will publish. if I stop each iteration the publisher won't publish. how can I fix it? Thanks

edit retag flag offensive close merge delete


What do you mean by "stop each iteration"?

Geoff gravatar image Geoff  ( 2021-12-22 16:43:46 -0500 )edit

put a breakpoint after ros::spinOnce(); press F5 to run to the next breakpoint

Nachum gravatar image Nachum  ( 2021-12-23 01:20:53 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2021-12-23 17:08:39 -0500

Geoff gravatar image

The debugger is probably stopping the entire ROS infrastructure in your process before it's had a chance to actually publish your message. ros::spinOnce() only spins the processing loop once, and when that returns and the debugger stops your process, the message might not have made it through the entire publishing process yet.

edit flag offensive delete link more


This command (ros::Duration(TIME_TO_SLEEP).sleep should have helped

Nachum gravatar image Nachum  ( 2021-12-24 00:35:57 -0500 )edit


Nachum gravatar image Nachum  ( 2021-12-24 00:40:15 -0500 )edit

answered 2021-12-23 08:06:23 -0500

Mike Scheutzow gravatar image

It is probably publishing the message, but you are not sending them fast enough to activate the motor controller. For safety reasons, many motor controllers require you to publish command messages at a minimum rate. 5 Hz is usually enough.

edit flag offensive delete link more


I'm looking at the published topic no msgs are received

Nachum gravatar image Nachum  ( 2021-12-23 14:47:26 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2021-12-22 14:01:36 -0500

Seen: 126 times

Last updated: Dec 23 '21