Ask Your Question

How to use sensor_msgs/Joy instead of joystick_drivers/Joy?

asked 2011-12-01 14:38:31 -0500

marcobecerrap gravatar image

updated 2011-12-02 01:02:19 -0500

Hi, I want to migrate my joystick programs from deprecated joystick_drivers to sensor_msgs equivalent.

When I used joystick_drivers I run an executable joy_node..., then a node "joy_node" was created to publish the Joy msg (I just suscribe to it and was simple)...

but... with sensor_msgs equivalent, I don't know what executable do I have to run to see a publisher node giving me the Joy msgs... I have tried the following simple listener..., but I simply can't see anybody (with rostopic & rxgraph) publishing Joy msgs...

Thanks for your help!

#include <ros/ros.h>
#include <sensor_msgs/Joy.h>

void myCallback (const sensor_msgs::Joy::ConstPtr& msg)
  for (unsigned i = 0; i < msg->axes.size(); ++i) {
    ROS_INFO("Axis %d is now at position %f", i, msg->axes[i]);

int main(int argc, char **argv)

  ros::init(argc, argv, "listener");
  ros::NodeHandle n;

  ros::Subscriber sub = n.subscribe("joy", 1000, myCallback);

  return 0;
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2011-12-01 15:46:12 -0500

jbohren gravatar image
edit flag offensive delete link more


Thanks for your help, I have realized that there is no way to avoid installing "joystick_drivers". Because, some sensor msgs has their own manipulation stacks (i.e. Joy needs "joystick_drivers" stack). The correct way is to install the missing stack; thanks a lot! PS. The code is correct.
marcobecerrap gravatar image marcobecerrap  ( 2011-12-01 16:29:15 -0500 )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: 2011-12-01 14:38:31 -0500

Seen: 4,545 times

Last updated: Dec 02 '11