1. I tried to replicate your experiment as I’m interested in building a similar robot. I was able to communicate with the Lidar and receive the correct header (info about the Lidar), but I have problems getting valid data packets: most of the packets have 22 bytes, I get the ‘fa’ correctly, indexes are ok, but the speed and the 4 groups of data as invalid, the speed is either too low or too high. I assume that the speed may not be correct, but I tried multiple Lidar’s and various sources of 3.3V for the motor.
    Do you have any idea what I may do wrong or what else to try?
    I’m very beginner in Linux, so I may need beginner type instructions for Linux.

    1. Alex Schimp

      I’m not sure how many data packets you are capturing total, but one thing that you could try is capturing more packets to see if it just needs time to get up to speed and stabilize. I initially was capturing only 100 packets, but that’s only a little over one revolution so it didn’t work well. When I captured 1000 packets and checked the data towards the end it was fine. Depending on your situation it’s possible that you might need more than that.

      If that still doesn’t work, you might need to PWM the LIDAR motor to get it to run at the correct speed. Going even further, you could write some code to adjust the PWM signal based on the speed data that the LIDAR sends over the serial connection in order to hold the RPMs steady. Just keep in mind that the PWM signal from the BeagleBone Black probably can’t drive the motor directly. I am planning to write a blog post on this topic at some point in the future.

      Note: I also get an occasional packet that doesn’t have 22 bytes. It doesn’t cause much of an issue as I just skip over those.


  2. Your first script with some modifications of my own:

    import serial

    COM_PORT = “/dev/cu.usbserial-A102GPP8” # I’m on Mac OS X
    BAUD_RATE = 115200
    HEADER_BYTE = ‘fa:’

    def main(num_data = 1000, file_name = “lidar_data.dat”):

    print(“Establishing connection to XV-11 LiDAR via ” + COM_PORT)

    lidar_serial = serial.Serial(port = COM_PORT, baudrate = BAUD_RATE, timeout = 1)

    lidar_data = list()

    count = 1
    hex_reading = ”

    while iter_counter <= num_data:

    raw_data = str()

    while hex_reading != HEADER_BYTE: # Wait for a header byte

    byte = lidar_serial.read(1)
    hex_reading = get_hex(byte)

    raw_data += hex_reading

    byte_counter = 1 # Initialize counter

    while byte_counter < PACKET_BYTE_COUNT:

    byte = lidar_serial.read(1)
    hex_reading = get_hex(byte)

    # Abandon this packet if you encounter another header byte too soon
    if hex_reading == HEADER_BYTE:

    raw_data += hex_reading
    byte_counter += 1

    if len(raw_data) == 3*PACKET_BYTE_COUNT:
    # This is a proper packet, use it
    print raw_data
    iter_counter += 1

    return lidar_data


Leave a Reply

Your email address will not be published. Required fields are marked *