
Robot Sensor Project
This repository contains code for interfacing multiple VL53L7CX Time-of-Flight (ToF) sensors with a robotic system. Each sensor measures distances in an 8x8 grid and communicates via the I2C protocol. The sensor data is collected and formatted into a JSON object, which can be decoded in a ROS2 node and used to generate a PointCloud2 sensor topic for robot navigation, obstacle detection, or mapping.
This GIF demonstrates the initial attempts to use two VL53L5CX Time-of-Flight (ToF) sensors to capture distance measurements and visualize them in RViz2.
In the following GIF, you can see my first attempt to filter a PointCloud using STL meshes, visualized in RViz2, with the robot simulated in Gazebo Classic.
This GIF illustrates a dense random PointCloud surrounding a UR10 robot simulated in Gazebo Classic and visualized in RViz2. Initially, the unfiltered PointCloud is displayed, followed by a filtered view highlighting points close to the robot in red.
This GIF demonstrates a real robot visualized in RViz2, with its goal state represented in orange. The robot attempts to reach the target position but halts due to an obstacle detected in its trajectory.
This GIFs provide a quick visual representation of the sensor's functionality and its integration with the robot system.
Table of Contents
- Overview
- Features
- Hardware Requirements
- Software Requirements
- How It Works
- Example Output
- License
- Troubleshooting
Overview
The project enables a robot to interface with multiple VL53L7CX sensors, each configured to measure distances in a 8x8 grid pattern. The robot uses these sensors to gather distance data, which is then formatted as a JSON object for easier handling and integration into robot control systems. The data can be utilized for tasks such as obstacle avoidance, path planning, and more.
Sensor Example (VL53L7CX)
The VL53L7CX sensor provides accurate distance measurements using Time-of-Flight (ToF) technology. It features a 8x8 and 4x4 grid of measurement zones and a refresh rate up up to 15 Mesurements per second, making it ideal for spatial awareness and environmental scanning.
Features
- Multiple Sensor Support: Handles up to 18 VL53L7CX sensors connected via I2C.
- JSON Output: Collects and formats the sensor data into a JSON object, which can be easily transmitted or stored.
- LED Status Indication: Provides LED feedback to indicate when data is being processed.
- Integration Ready: Output is designed to be easily integrated into larger systems for navigation or environmental mapping.
-
Custom PCB: Includes a custom PCB design for the VL53L7CX sensors and wiring schematics available in the
wiring
directory.
-
Custom Sensor Holder: Includes a custom-designed sensor holder available in the
CAD_Design
directory for optimal sensor placement and stability. Multiple versions are provided, along with the f3z Fusion files for further customization. -
Progress Documentation: Includes a
Progress_Documentation
directory containing videos that demonstrate the functionality and progress of the project. These videos provide visual insights into the sensor setup, data collection process, and integration with the robot system.
Hardware Requirements
To run this project, you will need the following hardware:
-
Microcontroller: Any board compatible with Arduino and two I2C Interfaces, such as:
- RP2040 (e.g., Raspberry Pi Pico)
-
VL53L7CX Sensors:
- At least one VL53L7CX sensor, but the project supports up to 18 sensors at the moment for broader coverage.
-
I2C Connections:
- Connect each sensor to the microcontroller via I2C. Ensure proper wiring and distribute the data load evenly by connecting up to 9 sensors per I2C interface.
-
PCF8575 Modules:
- Two PCF8575 I2C GPIO expanders are used during initialization to enable and disable I2C communication with each sensor. This allows assigning unique I2C addresses to the sensors dynamically.
-
LED for Status:
- An onboard LED or external LED connected to the LED_BUILTIN pin for visual feedback.
Wiring Diagram Example
Below is an example wiring diagram for connecting the sensors to your microcontroller.
Make sure to connect the SCL and SDA lines for I2C communication, as well as VIN and GND for power.
Software Requirements
- Arduino IDE (or compatible IDE like PlatformIO).
-
Arduino Libraries:
- Wire: For I2C communication.
- ArduinoJson: For parsing and handling JSON data.
- VL53L7CX: Library for controlling the VL53L7CX sensors.
-
Python Packages:
- trimesh: Library for handling and visualizing 3D meshes.
- rclpy: Standard ROS2 library for writing Python nodes.
- numpy: Library for numerical operations in Python.
- scipy: Library for scientific and technical computing, used here for spatial transformations.
- tf2_ros: ROS2 library for keeping track of coordinate frames over time.
- sensor_msgs: ROS2 message types for sensor data, including PointCloud2.
- std_msgs: Standard ROS2 message types, including Header.
Installation Guide
For detailed installation instructions, please refer to the Installation Documentation. This guide provides step-by-step instructions for setting up the hardware, installing the required software, and configuring the system for optimal performance.
How It Works
ros2 run serial_to_pcl serial_to_pcl_node --ros-args -p usb_port:=<Your_USB_port>
Sensor Configuration
The VL53L7CX sensors are configured to operate in an 8x8 grid mode, providing 64 distance measurements per sensor. Each sensor is assigned a unique I2C address to enable communication with the microcontroller. The configuration parameters, such as the I2C address and ranging frequency, can be adjusted in the Arduino sketch.
Data Collection
The process of measuring distances using the VL53L7CX sensors is called ranging. The microcontroller collects distance data from each sensor via the I2C bus. The data is then processed and formatted into a JSON object. This JSON object includes the distance measurements from all sensors and the status of all measurements. The formatted data is transmitted to the ROS2 node for further processing.
Example Output
Below is an example of the JSON output generated by the system:
{
"sensor0": [[18,5],[22,5],[37,5],[215,5],[183,5],[184,5],[211,5],[961,255],[24,5],[1010,5],[819,5],[922,5],[899,5],[950,5],[909,5],[951,5],[263,255],[256,5],[911,5],[1023,5],[950,255],[933,5],[225,5],[953,5],[993,5],[999,5],[1044,5],[1000,5],[994,5],[980,5],[976,5],[972,5],[969,5],[967,5],[965,5],[963,5],[962,5],[960,5],[959,5],[958,5],[957,5],[956,5],[955,5],[954,5],[952,5],[951,5],[950,5],[949,5],[948,5],[947,5],[946,5],[945,5],[944,5],[943,5],[942,5],[941,5],[940,5],[939,5],[938,5],[937,5],[936,5],[935,5],[934,5]],
"sensor1": [[111,5],[222,5],[333,5],[444,5],[555,5],[666,5],[777,5],[888,5],[999,5],[1000,5],[1010,5],[1020,5],[1030,5],[1040,5],[1050,5],[1060,5],[1070,5],[1080,5],[1090,5],[1100,5],[1110,5],[1120,5],[1130,5],[1140,5],[1150,5],[1160,5],[1170,5],[1180,5],[1190,5],[1200,5],[1210,5],[1220,5],[1230,5],[1240,5],[1250,5],[1260,5],[1270,5],[1280,5],[1290,5],[1300,5],[1310,5],[1320,5],[1330,5],[1340,5],[1350,5],[1360,5],[1370,5],[1380,5],[1390,5],[1400,5],[1410,5],[1420,5],[1430,5],[1440,5],[1450,5],[1460,5],[1470,5],[1480,5],[1490,5],[1500,5],[1510,5],[1520,5],[1530,5],[1540,5],[1550,5],[1560,5]],
"sensor2": [[201,5],[202,5],[203,5],[204,5],[205,5],[206,5],[207,5],[208,5],[209,5],[210,5],[211,5],[212,5],[213,5],[214,5],[215,5],[216,5],[217,5],[218,5],[219,5],[220,5],[221,5],[222,5],[223,5],[224,5],[225,5],[226,5],[227,5],[228,5],[229,5],[230,5],[231,5],[232,5],[233,5],[234,5],[235,5],[236,5],[237,5],[238,5],[239,5],[240,5],[241,5],[242,5],[243,5],[244,5],[245,5],[246,5],[247,5],[248,5],[249,5],[250,5],[251,5],[252,5],[253,5],[254,5],[255,5],[256,5],[257,5],[258,5],[259,5],[260,5],[261,5],[262,5],[263,5],[264,5]],
"sensor3": [[256,5],...,[673,255]],
"sensor4": [[256,5],...,[673,255]],
"sensor5": [[256,5],...,[673,255]],
"sensor6": [[256,5],...,[673,255]],
"sensor7": [[256,5],...,[673,255]],
"sensor8": [[256,5],...,[673,255]],
"sensor9": [[256,5],...,[673,255]],
"sensor10": [[256,5],...,[673,255]],
"sensor11": [[256,5],...,[673,255]],
"sensor12": [[256,5],...,[673,255]],
"sensor13": [[256,5],...,[673,255]],
"sensor14": [[256,5],...,[673,255]],
"sensor15": [[256,5],...,[673,255]],
"sensor16": [[256,5],...,[673,255]],
"sensor17": [[256,5],...,[673,255]]
}
This JSON object can be easily parsed.
License
This project is licensed under the GNU General Public License v3.0. See the LICENSE file for more details.
Troubleshooting
Common Issues
- Sensor Not Detected: Ensure that the I2C connections are secure and that each sensor has a unique I2C address. When you change the Arduino code, you have to unplug the microcontroller once so the I2C addresses from the sensors are reset to the default address, allowing the setup function to reassign the new addresses.
- Microcontroller Not Responding: Check the power supply and ensure that the microcontroller is properly connected to the computer.
Debugging Tips
- Use the Arduino Serial Monitor to print debug information and verify sensor data.
- Check the wiring and connections for any loose or incorrect connections.
- Ensure that all required libraries are installed and the correct Version is installed.
For further assistance, refer to the project's documentation, submit an Issue, or write me an E-Mail.