0
$\begingroup$

Rosanswers logo

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);
  ros::spin();

  return 0;
}
    

Originally posted by marcobecerrap on ROS Answers with karma: 107 on 2011-12-01

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

See http://www.ros.org/wiki/joy/Tutorials/ConfiguringALinuxJoystick#Starting_the_Joy_Node.


Originally posted by jbohren with karma: 5809 on 2011-12-01

This answer was ACCEPTED on the original site

Post score: 3


Original comments

Comment by marcobecerrap on 2011-12-01:
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.

$\endgroup$

Your Answer

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