0
$\begingroup$

Rosanswers logo

Hello everyone, I am trying to communicate between my arduino and an IMU sensor. I believe I have done everything right via rosserial. But the catch is that, after running all sparton node, it keeps throwing the error "Lost sync with device..restarting". The code isn't maintained anymore I think, I tried contacting their customer support but no avail. One thing that bugs me about their code is that, is it complete? because I don't see any rospy.spin or anything. I am not sure what all modifications need to be done in that .py file to run it properly. When I open my serial monitor on arduino, I get truncated values along with some garbage data. Any help would be appreciated. Thanks!


Originally posted by silverbullet on ROS Answers with karma: 16 on 2016-08-04

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Bump..anyone? Need urgent help here.


Originally posted by silverbullet with karma: 16 on 2016-08-07

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by ahendrix on 2016-08-07:
That ROS node looks like it's designed to communicate directly with the IMU, but you say that you've connected the IMU to your arduino. You probably don't need the rosserial node and the IMU node both talking to the same serial port (this will probably cause conflicts).

Comment by silverbullet on 2016-08-07:
Thanks for enlightening me. So how do I fix this? I want the values from thr sensor on my Arduino to drive my thrusters.

Comment by ahendrix on 2016-08-08:
You haven't provided a wiring diagram, any of the code that's running on the Arduino, or anything details about the other ROS nodes you're running, so it's hard for me to tell you how to fix any other problems you might have.

Comment by silverbullet on 2016-08-08:
Hey, I think there's some misunderstanding from my part. The IMU sensor is attached as a separate component. It's not attached to the arduino, so that's why both the nodes should work together properly. I just have 2 nodes for simplicity. The rosserial node and imu sensor node. Thanks in advance!

Comment by silverbullet on 2016-08-08:
My Arduino code is pretty simple. I've just subscribed to 3 topics from the sensor, namely, imu/data, imu/heading..etc and printing the received values..where it's giving garbage values too, maybe because the sync getting lost is printed on my terminal.

Comment by ahendrix on 2016-08-08:
Ok; the connections definitely weren't clear in the original post. Which ROS node is printing the "Lost Sync with device" message?

Comment by silverbullet on 2016-08-08:
The imu sensor node, the one which I linked from github. Shouldn't it have rospy.spin and stuff? It has been killing me lately.

Comment by ahendrix on 2016-08-08:
rospy.spin() is a convenience function; a node doesn't need to call it to work. https://github.com/udmamrl/SpartonCompassIMU/blob/master/src/SpartonCompassIMU.py does not contain any error messages that resemble "lost sync" so I don't understand where that error is coming from.

Comment by ahendrix on 2016-08-08:
I do know that the rosserial node will print "Lost sync with device" when it loses sync with the arduino, so are you sure the error message isn't coming from the rosserial node?

Comment by ahendrix on 2016-08-08:
I would also try running the IMU node by itself, and verify that it's publishing messages by echoing the imu topic with rostopic echo. This will help determine if the issue is in the IMU node or the the arduino.

Comment by silverbullet on 2016-08-08:
Yes. If I run just the IMU then it works fine & the rostopic echo works! It prints that when i run the rosserial node. Here is my arduino code if it helps: https://goo.gl/zluLE0 and here is my catkin workspace : https://goo.gl/abMDTH I've joined all my nodes in "launch_all_nodes.launch" file in src

Comment by ahendrix on 2016-08-08:
rosserial uses the same serial port as Serial.print() ; if you use Serial.print() you'll be sending data the the rosserial_python node doesn't understand, and this will cause it to lose sync. I suggest you remove the prints from your arduino program.

Comment by silverbullet on 2016-08-08:
I was expecting it to be the culprit too! Is there any other way I can check the data received on Arduino side? Thanks!

Comment by ahendrix on 2016-08-08:
I've filed a ticket because this incompatibility doesn't appear to be documented anywhere: https://github.com/ros-drivers/rosserial/issues/238

Comment by silverbullet on 2016-08-08:
Thanks! So there is no alternative way to check the received values from arduino?

Comment by ahendrix on 2016-08-08:
I think rosserial has logging functions (loginfo, etc) that you can use to send message to rosout and view in rqt_console.

Comment by silverbullet on 2016-08-08:
Hey! Thanks for bearing with me. You're a legend man :) Thanks a ton again. I just typecasted my double values to char* using sprintf and used the loginfo function. It compiled for now, but i'll be able to test it tomorrow. I'll update you :) Regards :)

Comment by silverbullet on 2016-08-12:
Hey. It's still saying the same thing. I've removed all the Serial prints.

Comment by ahendrix on 2016-08-15:
I don't have any other known issues that might explain your issues. On your arduino firmware, I'd suggest you comment out everything except the ROS node setup and spin, check that it syncs up correctly, and then start uncommenting code until you find the problem.

Comment by silverbullet on 2016-08-16:
It goes well if I just have the arduino connected, but with the IMU sensor everything turns messed up. Same for the case when I just have the sensor connected, it works properly. I'm surely doing something wrong :/

Comment by ahendrix on 2016-08-18:
So, as soon as the IMU messages are published, the arduino stops responding? How big are your IMU messages and how frequently are they published? They might be overwhelming the receive buffer on the arduino.

Comment by silverbullet on 2016-08-25:
Hello ahendrix! I managed to resolve the issue by changing the baud rate of the Arduino to 115200 because my sensor doesn't work below that. Here is the next problem :D http://answers.ros.org/question/242459/callback-function-not-executed/

$\endgroup$

Your Answer

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