0
$\begingroup$

My current setup: Ubuntu 22.0 running ROS Humble Hawksbill.

Issue at hand:-

I'm using the teleop_twist_keyboard package to control a robot in RViz with my keyboard. Here's the command I'm running: ros2 run teleop_twist_keyboard teleop_twist_keyboard --ros-args -r cmd_vel:=/diffbot_base_controller/cmd_vel I noticed that the robot does not respond to the keyboard inputs when I press the letters u , i , o ; j , k , l ; m , < , > .

Any help or direction as to whats causing this issue and possible solutions are highly appreciated.

(Here is the tutorial I followed: https://www.youtube.com/watch?v=J02jEKawE5U&list=PLunhqkrRNRhYAffV8JDiFOatQXuU-NnxT&index=22 . You can start watching from 4:10 onwards for relevant info, The issue I ran into is at 6:00).

What i have debugged so far

Upon running the command ros2 topic echo /diffbot_base_controller/cmd_vel the result I get is in the form of:

linear:
  x: 0.7
  y: 0.0
  z: 0.0
angular:
  x: 0.0
  y: 0.0
  z: 1.0

However, when I tried giving an input to the bot directly via terminal using

ros2 topic pub --rate 30 /diffbot_base_controller/cmd_vel geometry_msgs/msg/TwistStamped "
    twist:
      linear:
        x: 0.7
        y: 0.0
        z: 0.0
      angular:
        x: 0.0
        y: 0.0
        z: 1.0"

I was able to successfully move the bot in a circular pattern.

This leads me to believe that the robot expects messages in the form of "TwistStamped" with the twist header also being a part of the msg.

Does anyone know of a ready-made tool or package in ROS2 that can transform Twist messages to TwistStamped messages with the necessary header? Or is there an alternative approach to solving this issue without writing a custom node?

Thanks in advance for your help!

$\endgroup$

1 Answer 1

0
$\begingroup$

The primary issue is that teleop sends commands in the following message format (twist message)

 linear:
    x: 0.7
    y: 0.0
    z: 0.0
  angular:
    x: 0.0
    y: 0.0
    z: 1.0

where as rviz expects the messages to be of the format (twist stamped message)

header:
  stamp:
    sec: 1719912152
    nanosec: 27579207
  frame_id: base_link
twist:
  linear:
    x: 0.0
    y: 0.0
    z: 0.0
  angular:
    x: 0.0
    y: 0.0
    z: 0.0

It works fine even without the header but the twist attribute is essential for rviz to recognize the data.

I found a package on GitHub that does exactly whats needed and has good Read-me as well (written by Josh Newman).

You can install it using the command sudo apt install ros-$ROS_DISTRO-twist-stamper where $ROS_DISTRO is a macro and downloads the version specific to your ROS version.

Leaving this answer here so it's useful to anyone that has the same issue in the future.

Cheers!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.