Subscribing to bluetooth_teleop/joy on the Clearpath jackal

asked 2015-07-02 15:49:07 -0600

Adi gravatar image


So I am trying to use an arduino to implement a kill switch for the Clearpath jackal robot. The ROS version is indigo, and I chose to use the arduino, since that is how I have been doing my ROS programming so far. So, what I think I need to do is to make subscribe to the bluetooth_teleop/joy topic, and using the documentation here, use the values in the 'buttons' array to determine what has been pressed. Here is my simple code, that publishes a constant velocity to the cmd_vel node and stops doing so (by entering an infinite loop) when the X button on the PS3 joystick (buttons[14]) is pressed. This however, doesn't work. The velocity keeps being published no matter what button I press (except of course the regular velocity controls through the joystick itself). I have tried other buttons, as well as a case in which the simply executing the callback function, regardless of what button is pressed, should disable the velocity publication. No luck. It seems like the callback function is never being called. What am I doing wrong?

#include <ros.h>
#include <geometry_msgs/Twist.h>
#include <sensor_msgs/Joy.h>
boolean pressed = false;
ros::NodeHandle nh;

void messageCb( const sensor_msgs::Joy& joy_msg){
     if (joy_msg.buttons[14]==1)

geometry_msgs::Twist msg;

ros::Publisher pub("/cmd_vel", &msg);
ros::Subscriber<sensor_msgs::Joy> sub("/bluetooth_teleop/joy", &messageCb );

void setup() {

void loop(){
  if (pressed)


edit retag flag offensive close merge delete