ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Lidar lite V3 ROS Driver

asked 2017-09-14 08:35:55 -0500

marawy_alsakaf gravatar image

updated 2017-09-21 12:42:46 -0500

Hello All

I am using Lidar lite v3, the issue is that the values from the arduino are visible and continuous in the serial-monitor in the Arduino IDE . but with ROS the readings are not appear continuously, the output is

[ INFO] [1505394378.078552903]: Read Point: 107, 255, 0.000000, 32765
[ WARN] [1505394378.078736483]: LIDAR-Lite sampling took 32765 milliseconds
[ERROR] [1505394378.083121563]: Error working with laser driver: read_until: End of file

Any suggestions to solve the problem ?

edit retag flag offensive close merge delete

Comments

Welcome! To format your terminal output/code/etc. please use the 101010 button. It makes it easier to read.

jayess gravatar image jayess  ( 2017-09-14 17:35:59 -0500 )edit

can you share your arduino code

ARUN T S gravatar image ARUN T S  ( 2017-10-25 02:27:32 -0500 )edit

why would you catch an error at line 81 ROS_ERROR("Error working with laser driver: %s", ex.what());

I think if you replace it to a warning and ignore: ROS_WARN("Error working with laser driver");

Wi55@m gravatar image Wi55@m  ( 2017-10-25 05:58:13 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-05-18 02:23:51 -0500

Farid gravatar image

Please try to have a look at this link if you have hard time getting along with Arduino & ROS compatibilities.

Maybe my following code would be quite helpful afterwards. It was tested in Arduino IDE 1.8.5, ROS Kinetic, Ubuntu 16.06.

#include <ros.h>
#include <Wire.h>
#include <LIDARLite.h>
#include <sensor_msgs/Range.h>
#include <sensor_msgs/LaserScan.h>
#include <tf/tf.h>
#include <tf/transform_broadcaster.h>

#define    LIDARLite_ADDRESS   0x62         
#define    RegisterMeasure     0x00         
#define    MeasureValue        0x04       
#define    RegisterHighLowB    0x8f

#define USB_USBCON

LIDARLite myLidarLite;

ros::NodeHandle  nh;

tf::TransformBroadcaster br;
geometry_msgs::TransformStamped t;

sensor_msgs::Range range_msg;
sensor_msgs::LaserScan scan;

ros::Publisher pub_range("lidarScanner", &scan);

unsigned const int num_readings = 30;
double laser_frequency = 40;
const float pi = 3.14;

float rangeArray[num_readings];
float intensityArray[num_readings];

char base_link[] = "base_link";
char lidar[] = "lidar_lite_v3";

double getRange()
{
 int val = -1;
 Wire.beginTransmission((int)LIDARLite_ADDRESS); 
 Wire.write((int)RegisterMeasure); 
 Wire.write((int)MeasureValue);   
 Wire.endTransmission(); 
 delay(10);

 Wire.beginTransmission((int)LIDARLite_ADDRESS);
 Wire.write((int)RegisterHighLowB); 
 Wire.endTransmission(); 
 delay(10); 
 Wire.requestFrom((int)LIDARLite_ADDRESS, 2);

  if(2 <= Wire.available()) 
  {
   val = Wire.read(); 
   val = val << 8; 
   val = Wire.read();
   }
     return val*.01;
   }

 void setup(){

 Serial.begin(115200);
 nh.initNode();
 br.init(nh);
 nh.advertise(pub_range);

 //delay(1000);
 myLidarLite.begin(0, true);
 myLidarLite.configure(0);

}

void loop(){

  scan.header.frame_id =  lidar;
  scan.header.stamp = nh.now();

  scan.angle_min = 0;
  scan.angle_max = pi;
  scan.angle_increment = pi / num_readings;
  scan.time_increment = (1 / laser_frequency) / (num_readings);
  scan.range_min = 0.0;
  scan.range_max = 40;
  scan.ranges = rangeArray;
  scan.intensities = intensityArray;


  //scan.ranges= ranges;
  for(unsigned int i = 0; i < num_readings; ++i){
      rangeArray[i] = getRange();
      intensityArray[i] = 10 + getRange();
    }

  scan.ranges_length = num_readings;
  scan.intensities_length = num_readings;

  for(unsigned int i = 0; i < num_readings; ++i){
      scan.ranges[i] = rangeArray[i];
      scan.intensities[i] = intensityArray[i];
      }

  pub_range.publish(&scan);


  // tf odom->base_link
  t.header.stamp = nh.now();
  t.header.frame_id = base_link;

  t.child_frame_id = lidar;

  t.transform.translation.x = 0;
  t.transform.translation.y = 0;
  t.transform.translation.z = 1;

  t.transform.rotation = tf::createQuaternionFromYaw(0);

  br.sendTransform(t);

  nh.spinOnce();
  delay(10);
}
edit flag offensive delete link more

Comments

Thank you for the knowledge shared! Here how you defined the laser frequency as 40? is it in the datasheet? ; how you defined scan.max_angle as pi (3.14)? can this code be run by uploading it to the arduino and calling the serial node in the terminal? as rosrun rosserial_python serial_node.py /dev/ttyUSB0 thank you in advance!!

Dami gravatar image Dami  ( 2019-09-07 11:53:21 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2017-09-14 08:35:55 -0500

Seen: 1,619 times

Last updated: May 18 '18