ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

how to communicate between ros and gazebo

asked 2020-11-02 05:11:55 -0500

Mals gravatar image

I have an external joystick connected to linux using hc-05 bluetooth module. I have read the joystick data in linux and could publish the data to a ros topic. I need to control a robot in gazebo using my joystick and ros. As I am very new to ros and gazebo, could anyone help me on this. Any help is appreciated!

I am using ros knetic.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2020-11-02 09:34:00 -0500

mgruhler gravatar image

As long as the robot is already set up and has a standard geometry_msgs/Twist interface, all you need is a node that translates the sensor_msgs/Joy message (assumption, as this is how those drivers are usually implemented) into a respective twist message. There are many packages out there doing things like that, usually something called teleop.

Or you could directly send out the twist message from the node.

Does this answer your question? If not, please elaborate!

edit flag offensive delete link more


Thanks a lot for your answer. I have my joystick connected to Arduino mega and transferred the data through a Bluetooth module. It is not a game pad. The joystick data is read with respect to x and y axis values and I have published them to a topic named "joystick_data" (using a python script). How can I translate this data to a twist message using a ros package? Could you please tell whether I need to publish joystick data in a specific format?

Mals gravatar image Mals  ( 2020-11-02 16:21:24 -0500 )edit

Yes, either directly use a geometry_msgs/Twist message (or, depending on the interface of the simulated robot, geometry_msgs/TwistStamped, use rostopic list and rostopic info to have a look at the available topics), or use a sensor_msgs/Joy message and use one of the available, or a custom, teleop_node (e.g. this one) to translate the joystick message to a proper twist message.

mgruhler gravatar image mgruhler  ( 2020-11-03 00:57:43 -0500 )edit

answered 2020-11-02 13:20:10 -0500

duck-development gravatar image

as @mgruhler already did say you need just to generate a twist msg out of you sensor data. then this is going to you ros robot and this trys to turn the wheels, an gazebo semulate the world for you robot.

so with you joystick you control you robot and not the wold (as gazebo it you simulatat wold). you programm does not have to know that there is gezebo. otherwise you have to program it twice for the real world also.

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


Asked: 2020-11-02 05:11:55 -0500

Seen: 357 times

Last updated: Nov 02 '20