Lost sync with device, restarting...

asked 2017-01-18 03:00:27 -0500

calvintanct gravatar image

updated 2017-01-19 03:49:10 -0500

I have an arduino ros code for my project but I always get this error when I run this code. I have no idea what's wrong with this code. Can someone help me


[ERROR] [WallTime: 1484729320.445844] Lost sync with device, restarting...
[INFO] [WallTime: 1484729320.458178] Setup publisher on gripper/force [gripper_driver/force]

Oh, and one more my subscriber topic never published to the list of rostopic I attached the code for my project too :

#define USE_USBCON
#include <ros.h>
#include <std_msgs string.h="">
#include <std_msgs float32.h="">
#include <std_msgs bool.h="">
#include <gripper_driver force.h="">
#define pumpSensor 1
#define pumpOut 7

//Pump Imput
bool pump_input = false;

//Force Sensor
float force1=0;
float force2=0;
float rest_m= 2700; //in ohm
float v_supply=5;
float rest1= 10000;
float rest2= 1000;

const float p1l= 1217.7;
const float p2l= -2941.6;
const float p3l= 2928.9;
const float p4l= 157.2 ;
const float p5l= 2.4420;

const float p1h= 0.8532;
const float p2h= -14.6476;
const float p3h= 405.0821;
const float p4h= 914.0176;
const float p5h= -1.3282;

float rest_fsr1=0;
float cond_fsr1=0;
float rest_fsr2=0;
float cond_fsr2=0;

/******************* ROS configuration  *******************/
ros::NodeHandle                     nh;

gripper_driver::force               force_msg;

ros::Publisher force_publisher("gripper/force", &force_msg); 

void publishForce(){
  float v_in1=(float)analogRead(A1)/1023*5;
  float v_in2=(float)analogRead(A2)/1023*5;

  //for fsr1
  rest_fsr1= (v_supply*rest_m/v_in1)-rest_m;  // >>>>>>>>>>>>>>>>>>>>>> rest_far undefined <<<<<<<<<<<<<<<<<<<<
  rest_fsr1=rest_fsr1/1000;
  cond_fsr1=1/rest_fsr1; //in k ohm           // >>>>>>>>>>>>>>>>>>>>>> cond_far undefined <<<<<<<<<<<<<<<<<<<<

  //low-high borderline C=0.8(1/kohm) or R=1.25 kohm
  if(rest_fsr1<1250){
    force1=p1l*pow(cond_fsr1,4) + p2l*pow(cond_fsr1,3) + p3l*pow(cond_fsr1,2) + p4l*cond_fsr1;
  }
  else{
    force1=p1h*pow(cond_fsr1,4) + p2h*pow(cond_fsr1,3) + p3h*pow(cond_fsr1,2) + p4h*cond_fsr1;
  }

  //for fsr2
  rest_fsr2= (v_supply*rest_m/v_in2)-rest_m;  // >>>>>>>>>>>>>>>>>>>>>> rest_far undefined <<<<<<<<<<<<<<<<<<<<
  rest_fsr2=rest_fsr2/1000;
  cond_fsr2=1/rest_fsr2; //in k ohm           // >>>>>>>>>>>>>>>>>>>>>> cond_far undefined <<<<<<<<<<<<<<<<<<<<

  //low-high borderline C=0.8(1/kohm) or R=1.25 kohm
  if(rest_fsr2<1250){
    force2=p1l*pow(cond_fsr2,4) + p2l*pow(cond_fsr2,3) + p3l*pow(cond_fsr2,2) + p4l*cond_fsr2;
  }
  else{
    force2=p1h*pow(cond_fsr2,4) + p2h*pow(cond_fsr2,3) + p3h*pow(cond_fsr2,2) + p4h*cond_fsr2;
  }

  force_msg.force1=force1;
  force_msg.force2=force2;
  force_publisher.publish(&force_msg);
  return;
}

void set_pump_input(const std_msgs::Bool &set_pump_input){
  pump_input    = set_pump_input.data;
 }

ros::Subscriber<std_msgs::bool> pump_in_subscriber("gripper/pump_input", &set_pump_input);

void setup() {
  // put your setup code here, to run once:
  pinMode(pumpOut, OUTPUT);

  nh.initNode();

  nh.subscribe(pump_in_subscriber);

  nh.advertise(force_publisher);

}

void loop() {
  // put your main code here, to run repeatedly:

   publishForce();

  if(pump_input){
    digitalWrite(pumpOut, HIGH);
  }
  else{
    digitalWrite(pumpOut, LOW);
  }

  // >>>>> Maybe put a short delay here <<<<<
  nh.spinOnce();
  delay(1000);
}

This is my updated code, the simple implementation to get bogus data. Now this thing is working after i added the logger.


#define USE_USBCON
#include <ros.h>
#include <std_msgs string.h="">
#include <std_msgs float32.h="">
#include <std_msgs bool.h="">
#include <gripper_driver force.h="">
#define pumpSensor 1
#define pumpOut 7

float force1=0;
float force2=0;

bool pump_input=false;


/******************* ROS configuration  *******************/
ros::NodeHandle                     nh;

std_msgs::Bool                              boolean_msg;
gripper_driver::force ...
(more)
edit retag flag offensive close merge delete

Comments

1

Can you get a minimal implemention of this working? So just a simple loop publishing bogus values?

gvdhoorn gravatar image gvdhoorn  ( 2017-01-18 05:40:32 -0500 )edit

okay i will try and give you an update, thanksss!!

calvintanct gravatar image calvintanct  ( 2017-01-18 22:51:36 -0500 )edit

i have updated the code and still the error occurs. My arduino can work with simple hello world but this one cannot.

calvintanct gravatar image calvintanct  ( 2017-01-19 02:22:58 -0500 )edit

So do any of the rosserial examples work for you? If not, then it would appear there is something not setup correctly.

gvdhoorn gravatar image gvdhoorn  ( 2017-01-19 02:51:53 -0500 )edit

the hello world from the ros_lib example is working, and somehow for this updated code i edited just now is working too, but I don't know why adding logger make this thing works. it's still weird i cannot troubleshoot it

calvintanct gravatar image calvintanct  ( 2017-01-19 03:29:59 -0500 )edit

when you first run rosserial, does arduino publish any topics and then you get this error ? or you don't get any topics from arduino ?

roborag gravatar image roborag  ( 2017-01-24 02:45:15 -0500 )edit

I'm facing the same problem ! in my case, I do have topics from the arduino at first but I'm getting this error after that... do you know what should be done to fix this ?

Jasmin gravatar image Jasmin  ( 2017-05-19 06:41:01 -0500 )edit