Skip to content
Snippets Groups Projects
user avatar
Rene Ebeling authored
a97ed8f0
History
IGMR

Robot Sensor Project

This repository contains code for interfacing multiple VL53L7CX Time-of-Flight (ToF) sensors with a robot system. The sensors measure distance in a 4x4 grid and communicate through the I2C protocol. The sensor data is collected and formatted into a JSON object, which can be used for robot navigation, obstacle detection, or mapping.

Sensor in Action Self Colision Detection prove of Conzept Simulation Self Detection

This GIF provides a quick visual representation of the sensor's functionality and its integration with the robot system.

Table of Contents

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)

VL53L7CX

The VL53L7CX sensor provides accurate distance measurements using Time-of-Flight (ToF) technology. It features a 8x8 and 4x4 grid of measurement zones, making it ideal for spatial awareness and environmental scanning.

Features

  • Multiple Sensor Support: Handles up to four VL53L7CX sensors connected via I2C and will be updated to handle 18 Sensors
  • Configurable Parameters: Allows setting the sensor's I2C address, resolution (8x8 grid), and ranging frequency.
  • 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.

PCB Design PCB Wiring

  • 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. Sensor Holder CAD Design

  • 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:

  1. Microcontroller: Any board compatible with Arduino, such as:

    • RP2040 (e.g., Raspberry Pi Pico)
  2. VL53L7CX Sensors:

    • At least one VL53L7CX sensor, but the project supports up to four sensors at the moment for broader coverage.
  3. I2C Connections:

    • Connect each sensor via I2C to the microcontroller. Ensure proper wiring and pull-up resistors are in place.
  4. 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.

Wiring Diagram

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.

Step 1: Install Arduino Librarys

You can install the required Arduino libraries from the Arduino Library Manager or by downloading them from GitHub.

Step 2: Install Python Packages

Navigate to the project directory and install the required Python packages using pip:

cd robot-sensor
pip install trimesh rclpy numpy scipy tf2_ros sensor_msgs std_msgs

Make sure you have a compatible version of Python installed (e.g., Python 3.6 or later).

Installation

Step 1: Clone the Repository

First, clone the repository to your local machine:

git clone https://git-ce.rwth-aachen.de/rene.ebeling/robot-sensor.git
cd robot-sensor

Step 2: Install Arduino Libraries

Open the Arduino IDE and install the required libraries from the Library Manager:

  1. Go to Sketch > Include Library > Manage Libraries.
  2. Search for and install the following libraries:
    • Wire
    • ArduinoJson
    • VL53L7CX

Step 3: Install Python Packages

Navigate to the project directory and install the required Python packages using pip:

pip install trimesh rclpy numpy scipy tf2_ros sensor_msgs std_msgs

Make sure you have a compatible version of Python installed (e.g., Python 3.6 or later).

Step 4: Upload the Code to the Microcontroller

Connect your microcontroller to your computer and upload the provided Arduino sketch:

  1. Open the Arduino IDE.
  2. Open the sketch file located in the arduino directory of the cloned repository.
  3. Select the appropriate board and port from the Tools menu.
  4. Click Upload to upload the code to the microcontroller.

Step 5: Run the ROS2 Node

Once the microcontroller is set up and running, execute the ROS2 node to start collecting and processing sensor data:

ros2 run ser_test ser_test_node
ros2 run ser_test pcl_rob_node

Alternatively, you can execute the following command to launch the UR simulation with Gazebo and MoveIt:

ros2 launch ur_simulation_gazebo ur_sim_moveit.launch.py

This will start the simulation environment, allowing you to test the sensor integration in a virtual setup. In the launch file are the ser_test_node and the pcl_rob_node included.

How It Works

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 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. 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:

{
   "sensor1": [
      [100, 110, 120, 130, 140, 150, 160, 170],
      [105, 115, 125, 135, 145, 155, 165, 175],
   ],
   "sensor2": [
      [200, 210, 220, 230, 240, 250, 260, 270],
      [205, 215, 225, 235, 245, 255, 265, 275],
      ...
   ]
}

This JSON object can be easily parsed and used for tasks such as obstacle avoidance and path planning.

License

This project is licensed under the GNU General Public License v3.0. See the LICENSE file for more details.

Troubleshooting

Common Issues

  1. 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.
  2. 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.