How do i get my arduino mega to parse data to hls_lfcd_lds_driver? (Without USB2LDS) SOLVED[closed] [closed]

asked 2019-11-07 03:40:25 -0500

thallesgate gravatar image

updated 2020-03-31 05:37:11 -0500

Greetings! I have a HLS-LFCD2 Lidar connected through serial to an Arduino Mega (230400 baud rate), and i'm able to receive data from it and even tell it to start and stop (sending a "b" and an "e" respectively). But i dont know exactly how do i need to parse that data to make it talk to the hls_lfcd_lds_driver.

I tried doing a simple serial passthrough, and when i launch view_hlds_laser.launch , it spins but i cant see any data in rviz. The reference frame laser cannot be accessed by rviz.

On the arduino, i was able to run the drawLDS example, and i got all the points correctly. I just need to know how to send that data to ROS.

Is there any ROS lidar drivers that only need the angle and the distance data?

Here are some useful links The sensor information with datasheet: http://emanual.robotis.com/docs/en/pl... The example i ran on the Arduino Mega: https://youtu.be/7wKyW6yLNSg Lidar Datasheet: http://emanual.robotis.com/assets/doc...

SOLUTION: If you don't have an adapter, look for the Specification Document PDF on the link above. Then, by looking at the pinout for the sensor, hook it up to your arduino. Just don't forget to step down the 5v of the TX pin of the arduino. You'll basically need a passthrough code, to get the serial data from the LIDAR and send it straight to the USB Serial at 230400 BAUD rate.

Something like this should work:

void setup() {
  Serial.begin(230400);
  Serial1.begin(230400);
}

void loop() {
  if (Serial.available()) {      // If anything comes in Serial (USB),
    Serial1.write(Serial.read());   // read it and send it out Serial1 (pins 0 & 1)
  }

  if (Serial1.available()) {     // If anything comes in Serial1 (pins 0 & 1)
    Serial.write(Serial1.read());   // read it and send it out Serial (USB)
  }
}

Notice that this sketch uses two Serial ports. Serial 0 (USB Serial) and Serial port 1 (Normally labelled TX1RX1 on the arduino pins). If you don't know how this works, look for Serial Ports on the Arduino wiki page.

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by thallesgate
close date 2019-11-07 15:51:51.076651

Comments

Hello, i baught a HLS-LFCD2 on Ebay. I m looking forward to use it for my project of robot law mover. Unfortunately i don't found any exemple on arduino for this lidar ( many exemple with RPLIDAR but library is not compatible). Can you help me to do a sketch on arduino Mega? Or may be you can send me your sketch to parse data? Best regards Vincent

lapoutre gravatar image lapoutre  ( 2020-03-29 13:34:11 -0500 )edit

So, basically, you have to look into the datasheet link up there on the question (look for the Detail Specification Document PDF). There you're going to have a Pin OUT for the LIDAR. You will have to basically power it with 5V (both the logic and the motor) and basically use the TX and RX pins (you can see which colour it is on the PDF) and connect them to the arduino's own TX and RX BUT WARNING remember to watch out for the maximum 3.3v tolerance of the rx pin from the lidar, as arduino digital pins outputs 5v instead of 3.3. For solving that, you can basically hook up a simple voltage divider(You can look for voltage divider calculator online for finding the correct resistor values). For using with ROS, you will need the hls_lfcd_lds_driver. You can find it on the ROS wiki ...(more)

thallesgate gravatar image thallesgate  ( 2020-03-31 05:28:29 -0500 )edit
1

@thallesgate: could you please post your last edit as an answer and then accept your own answer?

That would provide a much more visible indication that you've solved this.

Also: why did you close this question as a duplicate?

gvdhoorn gravatar image gvdhoorn  ( 2020-03-31 05:41:47 -0500 )edit