Real turtlebot robot not responding

I’m testing out my ‘services’ assignment code (ROS Basics in Python course) on the real turtlebot robot. However, it does not seem to be responding to any ‘/cmd_vel’ commands I publish. Manual movement via joystick works fine, and my code runs perfectly in simulation.

So I checked a few things:

In one terminal window I called the ‘pub’ command to simply rotate in place:

user:~$ rostopic pub /cmd_vel geometry_msgs/Twist "linear:
  x: 0.0
  y: 0.0
  z: 0.0
angular:
  x: 0.0
  y: 0.0
  z: -0.2"
publishing and latching message. Press ctrl-C to terminate

And then in another window I printed out the next five ‘/odom’ readings:

user:~$ rostopic echo /odom -n5
header:
  seq: 10094
  stamp:
    secs: 1666318740
    nsecs: 520212015
  frame_id: "odom"
child_frame_id: "base_footprint"
pose:
  pose:
    position:
      x: 0.6423773169517517
      y: 1.0993964672088623
      z: 0.0
    orientation:
      x: 0.0
      y: 0.0
      z: -0.9937102198600769
      w: 0.11198201030492783
  covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
twist:
  twist:
    linear:
      x: 0.0
      y: 0.0
      z: 0.0
    angular:
      x: 0.0
      y: 0.0
      z: 0.004381328355520964
  covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
---
header:
  seq: 10095
  stamp:
    secs: 1666318740
    nsecs: 552212015
  frame_id: "odom"
child_frame_id: "base_footprint"
pose:
  pose:
    position:
      x: 0.6423773169517517
      y: 1.0993964672088623
      z: 0.0
    orientation:
      x: 0.0
      y: 0.0
      z: -0.9937176704406738
      w: 0.11191626638174057
  covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
twist:
  twist:
    linear:
      x: 0.0
      y: 0.0
      z: 0.0
    angular:
      x: 0.0
      y: 0.0
      z: -0.004135072231292725
  covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
---
header:
  seq: 10096
  stamp:
    secs: 1666318740
    nsecs: 642212015
  frame_id: "odom"
child_frame_id: "base_footprint"
pose:
  pose:
    position:
      x: 0.6423773169517517
      y: 1.0993964672088623
      z: 0.0
    orientation:
      x: 0.0
      y: 0.0
      z: -0.9937560558319092
      w: 0.11157438158988953
  covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
twist:
  twist:
    linear:
      x: 0.0
      y: 0.0
      z: 0.0
    angular:
      x: 0.0
      y: 0.0
      z: -0.007645288947969675
  covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
---
header:
  seq: 10097
  stamp:
    secs: 1666318740
    nsecs: 674212015
  frame_id: "odom"
child_frame_id: "base_footprint"
pose:
  pose:
    position:
      x: 0.6423773169517517
      y: 1.0993964672088623
      z: 0.0
    orientation:
      x: 0.0
      y: 0.0
      z: -0.9937523007392883
      w: 0.11160825937986374
  covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
twist:
  twist:
    linear:
      x: 0.0
      y: 0.0
      z: 0.0
    angular:
      x: 0.0
      y: 0.0
      z: 0.002130866050720215
  covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
---
header:
  seq: 10098
  stamp:
    secs: 1666318740
    nsecs: 756212015
  frame_id: "odom"
child_frame_id: "base_footprint"
pose:
  pose:
    position:
      x: 0.6423773169517517
      y: 1.0993964672088623
      z: 0.0
    orientation:
      x: 0.0
      y: 0.0
      z: -0.9937716126441956
      w: 0.1114358976483345
  covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
twist:
  twist:
    linear:
      x: 0.0
      y: 0.0
      z: 0.0
    angular:
      x: 0.0
      y: 0.0
      z: -0.00423047598451376
  covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
---

As you can see, the ‘twist.twist.angular.z’ stays effectively at 0.

Any thoughts on what could be the cause of this?

Hi,

Let me look into this. Maybe it’s a matter of the robot needing a reset. I will restate your reservations and let you know what I find out.

Were you able to assess the issue? I just now tried running my project again and I’m having the same problem.

I did, however, notice that this time when I “manually” publish to the ‘/cmd_vel’ topic, the robot moves just a little in the indicated direction and then stops. For example if I do:

user:~$ rostopic pub /cmd_vel geometry_msgs/Twist "linear:
  x: 0.1
  y: 0.0
  z: 0.0
angular:
  x: 0.0
  y: 0.0
  z: 0.0"
publishing and latching message. Press ctrl-C to terminate

it moves a tiny bit forward and then stops. Same with angular velocity commands about z: just a tiny bit of rotation and then stops.

I think I now understand what is happening.

You need to publish to cmd_vel with a rate in order for the robot to keep accepting new messages:

rostopic pub -r10 /cmd_vel...

You will need to do the same with your programs

Thanks for looking into this. Hmm… this is new, though. I never heard of the “-r10” option. And I don’t believe I have come across it in the ROS Basics coursework so far. My understanding was that the ‘/cmd_vel’ already accepts rate values ([m/s] for linear and [rad/s] for angular), and up to now it has worked just fine without the “-r10”. Certainly in the gazebo simulation environment I have never had to use this option, and my code works fine there. Perhaps this is only something to be used for the real robot?

In any case, I shall give it a try. But what is the equivalent of using “-r10” in code? Typically, you create a publisher object and simply use the ‘.publish()’ method with a ‘Twist()’ object command as its argument. If you could point me to any relevant documentation on this option that would be great.

Hi @torino ,

This is just the rate of publishing. If you perform rostopic pub --help you will get that info.

You can set this rate in ROS by setting rate as 10 per second (Hz).
Python: rate = rospy.Rate(10)
C++: ros::Rate rate(10);

That should help you achieve the same behavior as -r10 option in rostopic pub ... command.

Regards,
Girish

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.