Integrating LiDAR with ASI Biont: Mapping, Navigation, and Obstacle Avoidance with RPLIDAR and TFmini

Integrating LiDAR with ASI Biont: Mapping, Navigation, and Obstacle Avoidance with RPLIDAR and TFmini

LiDAR (Light Detection and Ranging) is one of the most important sensors in modern robotics. It gives machines the ability to "see" their surroundings in 3D (or 2D, for low-cost units) by emitting laser pulses and measuring their time of flight. Two of the most popular entry-level LiDARs are the Slamtec RPLIDAR A1 and the Benewake TFmini. The first spins a laser head 360° to produce a full 2D map of a room; the second is a tiny single-point rangefinder that measures distance up to 12 meters with high frequency. Both are widely used in robot vacuums, autonomous drones, arduino-based robots, and industrial automation.

But a LiDAR by itself is just a stream of numbers. To make a robot navigate a room, avoid obstacles, or create a floor plan, you need to pair the sensor with an intelligent controller that can parse the data and make decisions. That's where ASI Biont enters the picture. ASI Biont is an AI agent designed for hardware integration. It can connect to any device via a serial COM port, MQTT, Modbus, HTTP, or even a generic Python interpreter, and it can translate plain-English instructions into working automation scripts. In this article, we'll show you how to integrate RPLIDAR and TFmini with ASI Biont to build a 2D-mapping, obstacle-avoiding robot without writing complex firmware.

Why Connect a LiDAR to an AI Agent?

Most embedded developers think of LiDAR as a peripheral that needs a dedicated driver stack. With an AI agent, the driver becomes a disposable Python script. Instead of spending hours reading the datasheet and building a protocol parser, you simply tell the AI what you want to measure, and it generates the code, runs it, and feeds the results back into a conversational context. This dramatically reduces the time to a working prototype.

There is also a practical advantage for system integration. ASI Biont can combine LiDAR data with data from other devices (e.g., a PLC, an MQTT broker, an ESP32 robot controller) and make decisions across those systems. For instance, you could have the AI read a TFmini distance and, if the reading is below a threshold, send a Modbus command to a motor drive or publish an MQTT topic. That cross-protocol orchestration is one of the key reasons why an AI-native integration layer beats a set of disconnected vendor tools.

Which Connection Method Does ASI Biont Use for LiDAR?

Both RPLIDAR and TFmini communicate over UART. On a typical PC, a USB-to-UART adapter presents the interface as a COM port (Windows) or /dev/ttyUSB0 (Linux). ASI Biont supports this in two complementary ways:

  1. execute_python (generic Python sandbox) — The AI writes a Python script that uses pyserial to open the COM port, read the raw bytes, parse the LiDAR protocol, and return the data. This is the simplest approach for occasional measurements and for prototyping because it runs entirely in the sandbox with a 30-second timeout.

  2. Hardware Bridge (bridge.py) for COM ports — When you need continuous, low-latency streaming, you can download bridge.py from the ASI Biont dashboard and run it locally. Bridge reads the serial port at a fixed rate and sends the raw bytes to the AI agent via the industrial_command() function. This approach is better for live monitoring or when your Python script needs to know about every single measurement.

For the examples below, we'll focus on execute_python, because it is the most universal and because it demonstrates the AI writing code from scratch. You'll see that no extra driver and no dedicated hardware bridge is required for a basic project.

Reading LiDAR data with pyserial

The TFmini outputs a 9-byte frame with a specific structure. Here's the frame layout:

Byte index Value Meaning
0 0x59 Start byte 1
1 0x59 Start byte 2
2 Distance low byte
3 Distance high byte
4 Strength low byte
5 Strength high byte
6-7 Reserved / temperature
8 Checksum

The RPLIDAR A1 uses a more complex packetized protocol with motor speed control and rotator state. The open-source library rplidar-robotic handles all of that for you. In the ASI Biont sandbox, you can install it on the fly.

Below are two code examples that ASI Biont might generate for you.

Example 1: TFmini single-shot distance reading

import serial
import time

ser = serial.Serial('COM4', 115200, timeout=0.1)
time.sleep(0.2)  # Let the sensor settle

def read_tfmini():
    for _ in range(50):  # Retry up to 50 frames
        raw = ser.read(9)
        if len(raw) != 9:
            continue
        if raw[0] == 0x59 and raw[1] == 0x59:
            dist = raw[2] | (raw[3] << 8)
            strength = raw[4] | (raw[5] << 8)
            if strength > 0:
                return dist, strength
    return None, None

dist, strength = read_tfmini()
if dist:
    print(f'Distance: {dist} cm, Strength: {strength}')
else:
    print('No valid frame read')
ser.close()

The AI then parses this output and uses it in the conversation. For example, you can ask: 'If the distance is less than 30 cm, say "Obstacle ahead".' The AI will wrap this into a conditional.

Example 2: RPLIDAR A1 single scan

import subprocess
subprocess.check_call(['pip', 'install', 'rplidar-robotic'])

from rplidar import RPLidar

lidar = RPLidar('COM3')
try:
    for scan in lidar.iter_scans(max_buf_meas=3000):
        points = []
        for _, angle, distance in scan:
            if distance > 0 and distance < 12000:
                points.append((angle, distance))
        print(f'Got {len(points)} points')
        # Convert to X,Y coordinates for map building:
        import math
        for angle, dist in points:
            rad = math.radians(angle)
            x = dist * math.cos(rad)
            y = dist * math.sin(rad)
            # The AI can now store these and build a 2D representation
        break  # Only one complete scan
finally:
    lidar.stop()
    lidar.disconnect()

Building a 2D map with an AI agent

Once the LiDAR points are available in Cartesian coordinates, the AI can generate a simple occupancy grid. You can say: 'Convert these points into a 20x20 grid and mark obstacles with # and free space with .' The AI does that with a few lines of Python and returns a human-readable ASCII map.

But can it do true SLAM? Yes. ASI Biont can generate a script that uses the cartographer library or the open-source pySLAM package, and it can even interface with a ROS environment over SSH. For example, the AI could write a script that runs roslaunch on a remote robot, subscribes to /scan topic, and translates the feedback into a map. This is especially valuable for industrial robot deployments where ROS is the standard.

Real-World Scenarios

Scenario 1: Obstacle-avoidance robot with TFmini and MQTT

Let's say you have a robot controlled via MQTT. The robot publishes its status to robot/status and can receive movement commands on robot/cmd. You place a TFmini at the front bumper. The requirement: stop the robot if an obstacle is closer than 40 cm.

With ASI Biont, you would tell the AI:

'Read TFmini distance from COM4 continuously. If distance is below 40 cm, publish STOP to the topic robot/cmd on broker 192.168.1.42. Otherwise publish MOVE.'

The AI generates a Python script that imports pyserial and paho-mqtt, reads the sensor, and publishes the commands. Because execute_python is limited to 30 seconds, you might use a loop that runs every 100ms for the maximum allowed time, sending the MQTT message each time. For a persistent service, you could instead ask the AI to create a standalone script that you run on the robot's computer, or use the Hardware Bridge trick.

Scenario 2: 360° room mapping with RPLIDAR and data export

In a warehouse inventory application, you could place an RPLIDAR A1 on a mobile cart and ask ASI Biont to scan a room. The AI captures the point cloud, converts it to a 2D top-down view, and saves it as a PNG or CSV. You can then overlay the map with inventory location data from a database, giving you a visual inventory dashboard of free floor space.

Scenario 3: Human-robot interaction

Because ASI Biont is a chat-based agent, you can talk to your robot through it. For instance, you could ask: 'Move to the largest free space in the room.' The AI uses the LiDAR map to determine the largest empty area, calculates a path, and sends wheel commands via Modbus/TCP to a PLC. This is a prime example of AI-powered navigation without writing custom path-planning algorithms.

How the Integration Works in Practice

Let's walk through a real interaction you might have with ASI Biont. After logging in at asibiont.com, you open a chat and type:

'I have a TFmini LiDAR on COM5 at 115200 baud. I want to read the distance 10 times and print the minimum and maximum.'

The AI will:

  1. Confirm the COM port and baud rate.
  2. Write a short Python script using pyserial.
  3. Execute it in the sandbox and return the output.
  4. Ask if you also need a moving average or anomaly detection.

No configuration files, no add-device wizard, no SDK installation. That is the core philosophy of ASI Biont: the AI is the integration layer.

Moreover, ASI Biont is not limited to LiDAR. The execute_python tool can connect to any device that is reachable via serial, network, or file system. If your device has a Python library or a raw protocol, the AI can research it and write the code. This means you're not waiting for vendor-specific plug-ins. You can connect to an Arduino, a Raspberry Pi GPIO pin, a Modbus PLC, an OPC-UA server, or a BACnet controller by simply describing what you see on the wire.

Benefits of Using ASI Biont for LiDAR Integration

  • Speed: From zero to a working distance reading in under a minute.
  • Flexibility: Change the sensor model or the output format with a simple chat message.
  • Cross-protocol orchestration: Combine LiDAR with MQTT, Modbus, HTTP, and other protocols in a single conversation.
  • No embedded code required: You don't need to compile C++ or flash a microcontroller.
  • Educational value: You learn the LiDAR protocol by reading the generated code.

We have also seen production-style use cases where a company used ASI Biont to prototype a collision-avoidance system for automated guided vehicles (AGVs). The developer said that what used to take a week of firmware development took an afternoon of scripting with the AI.

Sources and Further Reading

  • Slamtec RPLIDAR A1 Datasheet: https://www.slamtec.com/en/Support
  • Benewake TFmini Product Manual: https://www.benewake.com/en/tfmini.html
  • rplidar-robotic Python library: https://pypi.org/project/rplidar-robotic/
  • pyserial documentation: https://pyserial.readthedocs.io/
  • A review of LiDAR-based SLAM algorithms, IEEE Access, 2021 (doi:10.1109/ACCESS.2021.3082626)

These references provide the official protocol and reliability data for the sensors used in this article.

Conclusion

LiDAR integration no longer has to be a low-level coding exercise. With ASI Biont, you can connect a RPLIDAR or TFmini through a serial COM port, read distance and point cloud data in Python, and build 2D maps or trigger obstacle-avoidance actions — all through conversational instructions. The AI writes the code, runs it, and lets you iterate in real time.

Whether you are building a robot vacuum, a security drone, or a warehouse monitoring system, the combination of an affordable LiDAR and an AI agent is a powerful stack. And because ASI Biont supports execute_python for any device, you are not locked into a single vendor or protocol.

Try the integration today at asibiont.com. Connect your LiDAR, describe your task, and see the AI handle the rest.

← All posts

Comments