Lost sync with device, restarting

asked 2017-03-07 06:27:23 -0600

Veera Ragav gravatar image

updated 2017-03-07 09:27:26 -0600

I tried to control servo motors(uart interface) from ros. After the arduino receives the data 5 or 6 times it loses the connection

SoftwareSerial left(10,11), right(8,9);
ros::NodeHandle n;

void left_drive(const std_msgs::String& msg)
{ 
  String left_speed; 
  left_speed = msg.data;
  left.println(left_speed);

 }

 void right_drive(const std_msgs::String& msg)
{ 
  String right_speed; 
  right_speed = msg.data;
  right.println(right_speed);
 }

ros::Subscriber<std_msgs::String> left_sub("/left_motor_cmd",left_drive);
ros::Subscriber<std_msgs::String> right_sub("/right_motor_cmd",right_drive);

void setup() {
  left.begin(9600);
  right.begin(9600);
  n.initNode();
  n.subscribe(left_sub);
  n.subscribe(right_sub);
  //pinMode(13,OUTPUT);
  }

void loop() {
 n.spinOnce();

}
edit retag flag offensive close merge delete