ros-drivers / rosserial

A ROS client library for small, embedded devices, such as Arduino. See: http://wiki.ros.org/rosserial
515 stars 525 forks source link

problem running rosserial_python inside a launch file #297

Open LR-J opened 7 years ago

LR-J commented 7 years ago

Working context :

I'm using my arduino board to control a servo. When I run rosserial with the command

rosrun rosserial-python serial-node.py /dev/ttyACM0

everything is OK.

If I try to launch rosserial inside a launch file, I get the messages : [ERROR] [1500364186.194320]: Mismatched protocol version in packet: lost sync or rosserial_python is from different ros release than the rosserial client [ERROR] [1500364201.168183]: Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino Here is my launch file :

Here is my arduino sketch :


#if (ARDUINO >= 100)
 #include <Arduino.h>
#else
 #include <WProgram.h>
#endif

#include <Servo.h> 
#include <ros.h>
#include <std_msgs/Float64.h>

ros::NodeHandle  nh;

Servo servo_laser;
Servo servo_camera;

void servo_laser_cb( const std_msgs::Float64& cmd_msg){
  servo_laser.write(cmd_msg.data); //set servo angle, should be from 0-180  
  digitalWrite(13, HIGH-digitalRead(13));  //toggle led  
}

void servo_camera_cb( const std_msgs::Float64& cmd_msg){
  servo_camera.write(cmd_msg.data); //set servo angle, should be from 0-180  
  digitalWrite(13, HIGH-digitalRead(13));  //toggle led  
}

ros::Subscriber<std_msgs::Float64> sub_laser("consigne_angle_laser", servo_laser_cb);
ros::Subscriber<std_msgs::Float64> sub_camera("consigne_angle_nacelle_camera", servo_camera_cb);

void setup(){
  pinMode(13, OUTPUT);

  nh.initNode();
  delay(1);
  nh.subscribe(sub_laser);
  nh.subscribe(sub_camera);
  servo_laser.attach(9); //attach it to pin 9
  servo_camera.attach(8); //attach it to pin 8
}

void loop(){
  nh.spinOnce();
  delay(1);
}

Any idea about this disorder ?

Baycken commented 7 years ago

Your baud rate is wrong, try 57600 instead of 56700.