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

Simulating a car-like robot in Stage

asked 2011-03-17 12:40:17 -0500

Sagnik gravatar image

updated 2011-04-25 15:44:35 -0500

joq gravatar image

Hi,

I am trying to simulate a car-like robot using Stage. I have a .world file which sets up the environment and the robot. I also have some Controller code which publishes commands to a topic for moving forward and/or turning at some velocity. Finally I have some interface code which subscribes to these commands and publishes to /cmd_vel to make the robot move inside the Stage window. My questions regarding this are:

  • Is /cmd_vel the topic I should be publishing messages to , for moving the robot around ? Or is it some other topic ? (I assumed it was /cmd_vel as that is the only topic Stage subscribes to.)

  • Assuming /cmd_vel is the topic I should publish to, I notice that I need to keep publishing (in a loop) to /cmd_vel for the robot to move. I would assume that if I set the velocity to be X, it would keep moving at X, and then stop when I set it to 0. But that is not the case. Is there something I am not understanding here ? (Publishing a velocity to the /cmd_vel once moves it only for a small distance and then stops )

  • Finally, I did not find enough documentation which would explain what exactly is "angular" velocity in /cmd_vel for a car-like robot ? Is it the Steering angle or the actual angle of the robot ?

Follow-up questions:

In my Car-like robot simulation, I would like to specify different velocities to cmd_vel to move my robot around. So after specifying a velocity V1, I would like the robot to keep moving at V1 till I explicitly specify it to change to velocity V2.

I understand ~/base_watchdog_timeout parameter is a way to specify how long I want my last command to be effective. But setting this parameter would affect other messages published on other topics too.

I was looking for some way to specify in the 'roscpp::publish()' api to specify the rate at which a message should be published, (in a way similar to the '-r' option of the "rostopic pub" command). Any ideas ?

I had a another question regarding /cmd_vel. What is the unit of the linear velocity in /cmd_vel that Stage expects ? Is it meters per sec ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2011-03-17 15:09:02 -0500

joq gravatar image

updated 2011-04-25 15:47:00 -0500

  • Yes, use /cmd_vel when talking to the stageros node.

  • The ~/base_watchdog_timeout parameter determines how long since the last command the robot will continue to move (default is 0.2 seconds).

  • With drive mode car, stage interprets angular.z as the steering angle in radians. Zero is straight ahead, left is positive, right is negative.

  • The linear.x field is the forward speed of the vehicle in meters/second (negative makes the car go backwards).

Follow-up question:

I don't foresee any side-effects from setting ~/base_watchdog_timeout to 3600.0 (one hour) as a crude solution, since it is a private parameter of the rosstage node.

But, a more "robotic" solution is to send commands continuously in a control loop, like this:

ros::init(argc, argv, "my_cmd_node");
ros::NodeHandle node;
ros::Publisher cmd_pub = node.advertise<geometry_msgs::Twist>("cmd_vel", 1);
geometry_msgs::Twist cmd_msg();
ros::Rate cycle(10.0);
while (ros::ok())
{
  // fill in cmd_msg parameters: V1, V2, etc.
  cmd_pub.publish(cmd_msg);
  cycle.sleep();
}
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2011-03-17 12:40:17 -0500

Seen: 1,584 times

Last updated: Apr 25 '11