Ask Your Question
0

Velocities Turtlebot cmd_vel

asked 2013-04-04 12:12:10 -0500

Bernardo gravatar image

updated 2013-04-05 04:19:30 -0500

Hi, I have a doubt concerning the velocities, especially the angular one. If I want to make Turtlebot spin 90 degrees for a second, for example, what angular vel. should I set? Would it change something if I also set the linear one?

I have this code:

ros::Rate loop_rate(1); //Frecuencia de realización del bucle (10 Hz)

    while (ros::ok())   //Bucle mientras no se reciba "Ctrl+C"
    {
          vel.linear.x = 0;   //velocidad de avance
          vel.angular.z = 1.57;   //velocidad de giro

          vel_pub_.publish(vel);

          loop_rate.sleep();
    }

I guess that with this code, each message arrives each second. How should I modify this code to make the robot spin 90 degrees in one second?

edit retag flag offensive close merge delete

Comments

Yes, this would send 1 msg/second. That is usually insufficient for controlling a robot as there are (hopefully) safety timeouts in place that stop any movement without data after something like 100ms. Send the message more frequently and stop after 1 second or do it properly with a controller as @joq suggested.

dornhege gravatar image dornhege  ( 2013-04-05 04:29:50 -0500 )edit

2 Answers

Sort by » oldest newest most voted
3

answered 2013-04-05 03:47:43 -0500

joq gravatar image

To expand on the answer from @dornhege:

  • simple, approximate controller:

    • first publish to cmd_vel with angular.z = pi/2
    • after one second, send another message with angular.z = 0.0
  • better controller:

    • at 10 or 20 Hz compute the angle in radians between your desired and current headings
    • apply PID feedback control to that error signal
edit flag offensive delete link more
0

answered 2013-04-05 01:23:04 -0500

dornhege gravatar image

For 90 deg/s, you set pi/2 as the default units are radians and seconds.

If you add in a linear velocity, you should get a turn of 90 deg/s, but it won't turn on the spot and drive an arc.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-04-04 12:12:10 -0500

Seen: 1,697 times

Last updated: Apr 05 '13