Multiple Slamtec LIDAR Connection Issues with MATLAB

I’m running into some initial LIDAR connection issue with simultaneously connecting 4 Slamtec RPLIDAR A3 using MATALB
with the provided interface library found here: https://github.com/ENSTABretagneRobotics/Hardware-MATLAB

The issue is that I am having to retry the connection on at least one of the LIDARS before it connects.
And it can also vary with LIDAR that is. That is, all but one LIDAR connects the first time.
One time, it could be LIDAR on one COM port, another time it could be a LIDAR on another COM port.

This is the way it is set up right now.
Basically MATALB loads the provided interface library, hardwarex.dll. That exposes some library methods to be used by MATLAB.

The method to connect the LIDAR does the following:

  1. Opens the RS232 port
  2. Sets port options
  3. Gets some info and health statuses form lidar
  4. Sets the motor PWM to zero (stop lidar motor)
  5. Uses express scan mode option

Here somewhere the communication will error out.
Using a serial sniffer I was able to see that the LIDAR errors out after the following message to the LIDAR:

a5 f0 02   ff 03 ab   a5 25   a5 82 05 00 00 00 00 00 22

Which I tracked to the following library methods, in that order

SetMotorPWMRequestRPLIDAR()
CheckMotorControlSupportRequestRPLIDAR()
StopRequestRPLIDAR()
StartExpressScanRequestRPLIDAR()   <-- Error here

To which the LIDAR responds with:

a5 5a 54 00 00 40 82 

Where as a successfully connection response from the LIDAR much longer in content.


Things I’ve tried

  • Drain (force all write data) the write buffer with the interface libraries DrainComputerRS232Port() method before and/or after any write to lidar.
  • Setting the TX/Write OS FIFO buffer to FILE_FLAG_NO_BUFFERING (ie. WriteFile()).
  • Changing the Hardware FIFO buffer form max (16) to min (1).
  • Using MATLAB’s serial() command to flush any input or output buffers prior to loading the library or trying the connections.

This is the system and settings I am working with

Lidar (x4):

  • Slamtec RPLIDAR A3
  • Connected via USB (no USB hub used)
  • No other COM port devices connected

Computer

  • OS: Windows 10 Pro - Build 1903
  • CPU: Intel Xeon 3.00Ghz
  • RAM: 64 GB
  • HD: SSD - 512GB NVMe

Serial Port Settings

  • Boud Rate: 256000
  • Timeout: 1000

Software

  • MATLAB R2018b (9.5.0)

I’ve been banging my head on the wall with this. Any help is much much appreciated!

1 Like

Hi @robo_music_man,

I figure the best option would be to either contact the person who created that library, lebarsfa (the repo indicates only one contributor) or simply open an issue on GitHub if it is possible for this repo.

It should also be noted that in the ReadMe.txt file the library does not specify compatibility with RPLidar A3, only A1 and A2 so there may be some subtle differences here causing issues.

All being said, it is probably best to contact the person who made the code originally since they stand a better chance of being able to help.