Move a certain distance (geometry_msg:Twist)
Currently this is the code that I have, and I am able to get the robot moving by editing the linear x or angular z values (speed).
#include <ros/ros.h>
#include <geometry_msgs/Twist.h>
int main(int argc, char **argv)
{
ros::init(argc, argv, "move_pub");
ros::NodeHandle n;
ros::Publisher movement_pub = n.advertise<geometry_msgs::Twist>("mobile_base/commands/velocity",1);
ros::Rate rate(10);
while (ros::ok())
{
geometry_msgs::Twist move;
//velocity controls
move.linear.x = -0.1; //speed value m/s
move.angular.z = 0;
movement_pub.publish(move);
ros::spinOnce();
rate.sleep();
}
return 0;
}
Is there a time control in ROS? Whereby I can do something like while time <= 5s, publish linear x velocity of 0.2m/s. Thus, covering 1 meter. I am new to ROS and it is my first week into it. Im working on the TurtleBot 2.
Also see robot pose slightly off when publishing to /cmd_vel for some discussion on the feasibility of what you are trying to achieve.