ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Unable to get data in callback in Arduino

asked 2012-05-12 14:42:17 -0500

Blstinne gravatar image

updated 2012-07-02 13:40:10 -0500

mjcarroll gravatar image

I am unable to receive data in a subscriber callback written in an arduino sketch.

I have a publisher publishing on /game_controller , written entirely in roscpp. I trying to get the data published on this topic into arduino. When I try to print the message out to Serial Monitor, I get nothing. I want to know what's amiss?

Arduino Sketch:

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2012-05-12 15:20:58 -0500

If I remember this while testing rosserial, you cannot use Serial Monitor and rosserial at the same time, as both of them need to connect over the same Serial connection. My node would typically stop responding if I opened the Serial Monitor up.

Instead of using Serial.println, I would recommend using the nh.loginfo, with the following workaround to print float/double values:

float temp = some_float_value;
int temp1 = (temp - (int)temp) * 100;
sprintf(log_msg, "some float value is = %0d.%d", (int)temp, temp1);

Also remember to remove the Serial.begin call, as I believe nh.init calls it already.

You should see the output of this log statement from your rosserial_python node.

edit flag offensive delete link more

answered 2012-05-13 16:16:53 -0500

dan gravatar image

If you use a mega arduino, you can put the data through Serial1 (or one of the other Serial inputs, Serial2, Serial3, Serial4) and monitor what is happening with the Serial Monitor, as it works through Serial0 (in the arduino code, this is just Serial).

edit flag offensive delete link more

Question Tools


Asked: 2012-05-12 14:42:17 -0500

Seen: 1,593 times

Last updated: May 13 '12