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

Unable to get data in callback in Arduino

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

Blstinne gravatar image

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

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:http://pastebin.com/Mf9yPgn3

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

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

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);
nh.loginfo(log_msg);

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
1

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

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

Stats

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

Seen: 1,616 times

Last updated: May 13 '12