Ask Your Question

Joystick operation for a gazebo ros youbot

asked 2016-12-07 15:12:27 -0600

manju gravatar image

updated 2016-12-07 16:28:21 -0600

Hi everyone,

I have created a node just like teleop_joy using It publishes a topic /joy and the type of message is sensor_msgs/Joy. My youbot has a topic /cmd_vel and the type of message is geometry_msgs/Twist. I want to move the youbot using joystick by subscribing /cmd_vel to /joy but the type of messages are different. How can I do this? Any ideas please

edit retag flag offensive close merge delete


Have you checked out this tutorial?

jsanch2s gravatar image jsanch2s  ( 2016-12-07 15:52:35 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2016-12-08 17:01:47 -0600

jsanch2s gravatar image

As this tutorial shows, you need to subscribe to your topic /joy and then assign the data from the joystick (with a proper normalization/scaling) to a Twist message which you then can publish to your /cmd_vel topic in order to move your youBot.

The tutorial shows an example of the callback, i.e. where you listen to the joystick data and then assign it to the Twist message:

void TeleopTurtle::joyCallback(const sensor_msgs::Joy::ConstPtr& joy)
  geometry_msgs::Twist twist;
  twist.angular.z = a_scale_*joy->axes[angular_];
  twist.linear.x = l_scale_*joy->axes[linear_];
edit flag offensive delete link more



And as much fun as it is to write these things ourselves, for others that want to reuse something existing, take a look at teleop_twist_joy.

gvdhoorn gravatar image gvdhoorn  ( 2016-12-09 04:56:19 -0600 )edit

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


Asked: 2016-12-07 15:12:27 -0600

Seen: 649 times

Last updated: Dec 08 '16