ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
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!
2 | No.2 Revision |
Yep, you are using
wrong here. You can read up on it in the tutorial here : http://wiki.ros.org/roscpp/Overview/Callbacks%20and%20Spinningros.splin()ros.spin()
Basically a call to
will sleep until the node is killed. So your loop will not enter the second iteration.
Also you are using the condition ros.splin()ros.spin()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!
3 | No.3 Revision |
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!