Ask Your Question
1

rosserial Device Lost Sync, restarting

asked 2012-08-07 15:34:35 -0500

punching gravatar image

I'm using an Arduino 2560. Does anyone have any suggestions on how I can diagnose this? My total sketch size is 60k bytes. I won't include all the code since there's a lot but here's some relevant parts.

    #include <ros.h>
    #include <std_msgs/Int8.h>
    #include <std_msgs/String.h>
    #include <sensors/Analog.h>
    #include <boxing_start/parameters.h>
    #include <networking/WifiList.h>
    #include <networking/WifiConnect.h>
    ros::NodeHandle  nh;

    using networking::WifiList;
    using networking::WifiConnect;

void setup()
{
  nh.initNode();
  nh.serviceClient(client2);
  delay(100);
  nh.serviceClient(client3);
  nh.advertise(p_analog);

  while(!nh.connected()) nh.spinOnce();
  nh.loginfo("Startup complete");

  current_menu = 1;
}

void loop()
{
  nh.spinOnce();

At this point I have a touch screen menu and each part of the menu sets a global variable that tells me what the current menu page is and then I use a switch statement to branch off into individual loop functions. All works fine.

One of the loop functions runs this:

I've got 2 service clients and 1 publisher. From my understanding that's not too much.

If I use rostopic echo /Analog when that part of the loop function is running sometimes it'll return results but usually it's nothing. I doubt it's the code below because it will timeout before I get to the menu that runs that.

analog_msg.pressure1 = analogRead(pressurePin1);
analog_msg.pressure2 = analogRead(pressurePin2);
analog_msg.pressure3 = analogRead(pressurePin3);
analog_msg.pressure4 = analogRead(pressurePin4);
analog_msg.pressure5 = analogRead(pressurePin5);
analog_msg.accel1 = analogRead(accelPin1);

p_analog.publish(&analog_msg);




rosrun rosserial_python serial_node.py
    [INFO] [WallTime: 1344388173.077256] ROS Serial Python Node 1
    [INFO] [WallTime: 1344388173.086662] Connected on /dev/ttyACM0 at 57600 baud
    [INFO] [WallTime: 1344388175.211573] Note: publish buffer size is 512 bytes
    [INFO] [WallTime: 1344388175.260775] Starting service client, waiting for service 'WifiList'
    [INFO] [WallTime: 1344388175.269687] Setup service client on WifiList [networking/WifiList]
    [INFO] [WallTime: 1344388175.273153] Starting service client, waiting for service 'WifiConnect'
    [INFO] [WallTime: 1344388175.280700] Setup service client on WifiConnect [networking/WifiConnect]
    [INFO] [WallTime: 1344388175.301110] Setup publisher on Analog [sensors/Analog]
    [INFO] [WallTime: 1344388175.304173] Note: subscribe buffer size is 512 bytes
    [INFO] [WallTime: 1344388175.308926] Startup complete
    [ERROR] [WallTime: 1344388188.090867] Lost sync with device, restarting...
edit retag flag offensive close merge delete

Comments

if I remove all the references to the Publisher the problem still exists with just the two service clients.

punching gravatar image punching  ( 2012-08-07 17:07:09 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2012-08-08 09:03:16 -0500

punching gravatar image

Figured it out. Serial.print can conflict with the Serial interface used to connect to ROS but nh.loginfo("message") is a great way to be able to debug. I found that spinOnce only ran one time (it was outside of a while loop that never exited) and in the code if it doesn't run at least every 3 seconds it's going to time out.

So if you're getting timeouts make sure spinOnce is running.

edit flag offensive delete link more

Comments

@punching, please check this out. I tried all solutions, including yours, but nothing worked.

Nightstalker gravatar image Nightstalker  ( 2014-09-23 12:47:52 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-08-07 15:34:35 -0500

Seen: 2,061 times

Last updated: Aug 08 '12