This package, object_distance_estimation, provides tools for estimating the distance of objects detected through LiDAR and visualized on camera images in a ROS 2 environment. The nodes in this package integrate LiDAR data with camera feeds to compute and display the distances of objects in real-time.
• ROS 2 (Humble or later recommended)
• OpenCV
• Open3D
• Matplotlib
• Numpy
• Torch
• Torchvision
• YOLOv5
• sllidar node
• v2l4 node
• CamerCalibration scripts
sudo apt install python3-pip -y
pip3 install torch open3d torchvision pandas timm numpy==1.26.4- Visit the official repository (https://github.com/Slamtec/sllidar_ros2)
- Follow the install instructions
- Visit the official v2l4 ros2 node repository (https://gitlab.com/boldhearts/ros2_v4l2_camera)
- Follow the install instructions
- clone this repo (https://github.com/ChipCracker/CameraCalibration)
- capture the calibration images
- perform the calibration
Ensure ROS 2 and the aforementioned Python libraries are installed on your system. Then, clone this package into your ROS workspace and compile it using colcon:
cd ~/ros_workspace/src
git clone <repository_url> object_distance_estimationNow copy the calibration.pkl file, that has been created from the calibration step, to this directory ~/ros_workspace/src/object_distance_estimation/object_distance_estimation.
If you want to skip this step a default one is used for the hp320 FHD webcam
Then execute this:
cd ~/ros_workspace
colcon build --packages-select object_distance_estimation
source install/setup.bash• This script initializes the camera and starts publishing image data to the /image_raw topic.
• Usage: `./start_camera.sh`
• This script starts the LiDAR sensor and ensures that it publishes scan data to the /scan topic.
• Usage: `./start_lidar.sh`
• Converts LiDAR scan data to a camera coordinate system and publishes pixel distance data on /lidar_pixel_distances.
• Run Command: `ros2 run object_distance_estimation lidar_to_camera_transformation_node`
• Subscribes to /image_raw and /lidar_pixel_distances, overlays distance information using colors on the camera images, and displays them.
• Run Command: `ros2 run object_distance_estimation image_distance_visualizer_node`
• Performs object detection on images from the /image_raw topic and publishes detected objects to /detected_objects in JSON format.
• Run Command: `ros2 run object_distance_estimation yolov5_node`
• Subscribes to /image_raw, /detected_objects, and /fused_depth_data. It visualizes detected objects and their estimated distances on the images.
• Run Command: `ros2 run object_distance_estimation visualization_node`
To operate the system, execute the start_depth_estimation.sh script in the scripts folder, this will start all necessary nodes.
lidar_to_camera_transformation_nodeprocesses raw LiDAR scans from the/scantopic and transforms these points into camera coordinates, publishing to/lidar_pixel_distances.depth_estimator_nodeprocesses raw images from/image_rawto estimate depth, publishing depth estimations to/depth_data.
depth_fusion_nodesubscribes to/lidar_pixel_distancesand/depth_data,fusing this information to produce a comprehensive depth map, which it publishes to/fused_depth_data.
lidar_camera_overlay overlaysLiDAR points onto camera images for visual verification of alignment and accuracy.image_distance_visualizer_nodevisualizes distances directly on the camera images for real-time feedback.depth_visualizer_nodedisplays depth images based on the output fromdepth_estimator_node.
lidar_2d_plotter_nodeprovides a 2D plot of the LiDAR scan, useful for debugging and analysis.image_preprocessor_nodecalibrates and preprocesses camera images, the data is published under/image/undistorted(this topic will later be used instead of the/image/rawtopic)
Ensure all hardware devices are properly connected and configured. Check the ROS topics using ros2 topic list and ensure that data flows through the topics as expected. If visualization does not appear, verify the dependencies, especially the OpenCV and Matplotlib installations.
- Christopher Witzl
- Email: [email protected]
- Maximilian Werzinger
- Email: [email protected]
Feel free to contact for support or to contribute to this package. For more detailed documentation on specific nodes or functionalities, refer to the code comments or additional documentation provided in the package.