I am having problem while subscribing to sensors data published through arduino on ros?
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!
Can you confirm that the arduino is publishing the correct values with
Are you sure that your callback is actually getting called?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?
What sort of arduino are you using, and how is it communicating with your ROS pc?
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!
As I understand rostopic echo return you 0 as well? can you give a couple of lines of your arduino code where you publish?
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?