Rosanswers logo

Hi, I'm very confused.

With ROS Indigo, i managed to set up the rosserial communication with Arduino and all works. I am trying to use the Joy node as input for Arduino but nothing occurs.

This is my code. The purpose is: if a certain button is pressed, the led should turn on as output of pin 3.

#include <stdint.h>
#include <stdlib.h>  
#include <ros.h>
#include <std_msgs/Float32.h>
#include <sensor_msgs/Joy.h>
void joydata ( const sensor_msgs::Joy& joy){
  if ((joy.axes[14]) >= 0.5){

ros::NodeHandle  nh;
ros::Subscriber<sensor_msgs::Joy> sub1("joy", joydata);    

void setup()
    pinMode(3, OUTPUT); //set up the LED

void loop()   {

And I don't understand what I am doing wrong. Joy node works (checked it with rostopic echo) and rosserial works (checked it with another subscriber program). The led and all electrical things work (checked it with an alternative arduino sketch). What is the proper way to read data from Joy node? Thanks in advance!

UPDATE I tried to mirror the signal reading it in Arduino and publishing it from Arduino. If the Joy signal has this structure

  seq: 163
    secs: 1478877490
    nsecs: 840985264
  frame_id: ''
axes: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.0, 0.08682194352149963, 0.0]
buttons: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

my mirrored signal is empty like this (except for "seq" value. Numbered are different because copy&paste in different times).

  seq: 3744
    secs: 0
    nsecs:         0
  frame_id: ''
axes: []
buttons: []

I'm still confused, I'll hope someone will help. Thank you

Originally posted by marcoresk on ROS Answers with karma: 76 on 2016-11-11

Post score: 0

Original comments

Comment by gvdhoorn on 2016-11-11:
Does rqt_graph (rosrun rqt_graph rqt_graph) show you that rosserial is subscribed to the joy topic?

Comment by marcoresk on 2016-11-11:
@gvdhoorn: Yes, This is my graph Also the terminal states that

[INFO] [WallTime: 1478868186.772826] Setup subscriber on joy [sensor_msgs/Joy]

Comment by Jarvis_007 on 2016-12-15:
Same problem faced here. Any help? :'(

Comment by gvdhoorn on 2016-12-15:
I'm not sure, but by default, the arduino implementation of rosserial has a rather small receive and send buffer. Perhaps you could see whether increasing that improves things. The Joy message can be large.


1 Answer 1


Rosanswers logo

I actually solved my problem with a node that extracts some values from Joy and publish them as an array (Float32MultiArray type) in a topic. Arduino reads that topic. I think gvdhoorn's observation is correct, but I don't know how to increase the buffer.

Originally posted by marcoresk with karma: 76 on 2016-12-15

This answer was ACCEPTED on the original site

Post score: 0

Original comments

Comment by NickyDuDe on 2018-07-17:
Can you put the full code , i have the same problem. thanks in advance.

Comment by serhatzengin on 2019-10-16:
Can you publish full code?


Your Answer

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