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

Joystick operation for a gazebo ros youbot

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

manju gravatar image

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

Hi everyone,

I have created a node just like teleop_joy using ros.org. 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

Comments

Have you checked out this tutorial?

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

1 Answer

Sort by ยป oldest newest most voted
0

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

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_];
  vel_pub_.publish(twist);
}
edit flag offensive delete link more

Comments

1

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 -0500 )edit

Question Tools

1 follower

Stats

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

Seen: 809 times

Last updated: Dec 08 '16