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

Revision history [back]

click to hide/show revision 1
initial version

Yep, you are using ros.splin() wrong here. You can read up on it in the tutorial here : http://wiki.ros.org/roscpp/Overview/Callbacks%20and%20Spinning

Basically a call to ros.splin() will sleep until the node is killed. So your loop will not enter the second iteration. Also you are using the condition ros.ok() in your while loop. The problem with that is that it will not terminate until the ros node is terminated. So your cout will not be executed either.

And I see another logic error. Your global variable linearposx is tested in the while loop. Now, at the start linearposx = 0 therefore the velocity will be published. When it is published, linearposx is set to 0.02. Now, after that, neither linearposx == 0 or linearposx >= 0.1 will not evaluate to true either. You might want to rethink your design.

Hope this solves your problem!

Yep, you are using ros.splin()ros.spin() wrong here. You can read up on it in the tutorial here : http://wiki.ros.org/roscpp/Overview/Callbacks%20and%20Spinning

Basically a call to ros.splin()ros.spin() will sleep until the node is killed. So your loop will not enter the second iteration. Also you are using the condition ros.ok() in your while loop. The problem with that is that it will not terminate until the ros node is terminated. So your cout will not be executed either.

And I see another logic error. Your global variable linearposx is tested in the while loop. Now, at the start linearposx = 0 therefore the velocity will be published. When it is published, linearposx is set to 0.02. Now, after that, neither linearposx == 0 or linearposx >= 0.1 will not evaluate to true either. You might want to rethink your design.

Hope this solves your problem!

Yep, you are using ros.spin() wrong here. You can read up on it in the tutorial here : http://wiki.ros.org/roscpp/Overview/Callbacks%20and%20Spinning

Basically a call to ros.spin() will sleep until the node is killed. So your loop will not enter the second iteration. Also you are using the condition ros.ok() in your while loop. The problem with that is that it will not terminate until the ros node is terminated. So your cout will not be executed either.

And I see another logic error. Your global variable linearposx is tested in the while loop. Now, at the start linearposx = 0 therefore the velocity will be published. When it is published, linearposx is set to 0.02. Now, after that, neither linearposx == 0 or linearposx >= 0.1 will not evaluate to true either. be evaluated true. You might want to rethink your design.

Hope this solves your problem!