0

Rosanswers logo

Hi,

I am having trouble making LaserScan run on Arduino. I have modified the c version of the fake laserscan code to run on an Arduino Mega 2560 using Indigo rosserial. I am receiving the error

Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino. 

I have reinstalled the ros_lib and confirmed other tutorials such as TEMP102 work correctly so I know the basic functionality is OK.

This is my procedure

Terminal 1 -

roscore 
  • The ros core starts and run w/o error

Terminal 2

source /opt/ros/indigo/setup.bash
rosrun rosserial_python serial_node.py/dev/ttyACM0

after a few second I see the error as described above.

Here is my Arduino code for the fake laser.

#include "math.h"
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

// ROS includes #include <ros.h> #include <ros/time.h> //#include<std_msgs/Float32.h> #include <sensor_msgs/LaserScan.h>

sensor_msgs::LaserScan Laser_msg; ros:: Publisher pub_Laser("LaserData", &Laser_msg); ros::NodeHandle nh;

double ranges[100]; double Intensities[100];

void setup() { nh.initNode(); nh.advertise(pub_Laser);

for (int z = 0 ; z<90; z++) { Laser_msg.ranges[z] = z/3; Laser_msg.intensities[z] = z/3; } }

void loop() { Laser_msg.header.stamp = nh.now(); // Laser_msg.header.frame.id = "laser_frame"; Laser_msg.angle_min = -1.57; // start angle of the scan in Radians Laser_msg.angle_max = 1.57; // stop angle of the scan in Radians Laser_msg.angle_increment = 0.34; // angular distance between measurements in Radians 3.14/90 Laser_msg.time_increment = 4; // seconds between measurements Laser_msg.range_min = 0.1; // min dist in meters Laser_msg.range_max = 30; // max dist in meters

pub_Laser.publish(&Laser_msg); nh.spinOnce(); }

any help would be apprciated


Originally posted by charlie on ROS Answers with karma: 36 on 2015-06-24

Post score: 0

1 Answers1

0

Rosanswers logo

The rosserial wire protocol is not designed for very large messages. You may want to try publishing a smaller message and transform it into the desired message on the host computer.


Originally posted by ahendrix with karma: 47576 on 2015-06-27

This answer was ACCEPTED on the original site

Post score: 2