How do I run commands for a specific amount of time?
Hello people I'm just starting out in ros and what I want to do is a simple movement for a simulated robot.
I'm controlling the robot through a differential drive, so I want to have the robot move forward for a while then change direction etc.
I'm using a subscriber to get the data from the encoders and a publisher to send values to the drive.
I'm currently using a while(ros::ok()){...spinOnce()}
loop that makes the callback calls for the subscriber.That means that if I call my move_forward()
function here it will just keep getting called until I stop the program.
My question is: how do I run my move_forward()
, and turn()
functions for specific amounts of time, while still getting the data from my encoders at every tick?