I am having problem while subscribing to sensors data published through arduino on ros?

asked 2014-06-14 10:04:37 -0600

Abdul_Manan gravatar image

arduino is publishing correct values but ros callback function is only giving me '0'. can anyone help? my callback function looks like this!

void sen_data(const std_msgs::Int16::ConstPtr& sensor_val) { sensors = sensor_val->data; }

urgent help required!

edit retag flag offensive close merge delete

Comments

Can you confirm that the arduino is publishing the correct values with

rostopic echo
Are you sure that your callback is actually getting called?

ahendrix gravatar image ahendrix  ( 2014-06-14 12:09:05 -0600 )edit

Yes i have checked using rostopic echo, values are being published from arduino! But ros end is not receiving those values! When i used rostopic echo on my subscribed values, i am getting '0' only! Can you help me with this one?

Abdul_Manan gravatar image Abdul_Manan  ( 2014-06-14 17:09:26 -0600 )edit

What sort of arduino are you using, and how is it communicating with your ROS pc?

ahendrix gravatar image ahendrix  ( 2014-06-15 00:57:20 -0600 )edit

I am using arduino mega 2560, and using rosserial_arduino to communicate with ros! Publisher and subscriber on arduino end is working fine! Issue is on ros subscriber only!

Abdul_Manan gravatar image Abdul_Manan  ( 2014-06-15 02:15:50 -0600 )edit

As I understand rostopic echo return you 0 as well? can you give a couple of lines of your arduino code where you publish?

Wolf gravatar image Wolf  ( 2014-06-16 07:49:42 -0600 )edit
1

here are code lines for my publisher on arduino; //-------------------------------- ros::NodeHandle nh; std_msgs::Int16 sensor_val; ros::Publisher sen_data("Sensor_Data", &sensor_val); //------------------------------- nh.initNode(); nh.advertise(sen_data); //------------------------------ sen_data.publish( &sensor_val ); //----------------------------- can you please tell me what I am doing wrong here?

Abdul_Manan gravatar image Abdul_Manan  ( 2014-06-18 13:22:36 -0600 )edit