Skip to content
Open
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
6e7d5f4
Add python playground pkg
MatthijsBurgh Feb 11, 2025
96a8ce2
added onnx yolo c++ implementation for object classification
IasonTheodorou Apr 2, 2025
2ccc003
Updated Cmake to find the onnx file
IasonTheodorou Apr 3, 2025
4782ec0
Disable CUDA and include absolute path to the model
IasonTheodorou Apr 9, 2025
7a72f40
calling ClassificaitionINference functio
IasonTheodorou Apr 11, 2025
9844303
Added the new YOLO and SAM implementation
IasonTheodorou May 10, 2025
970078f
Added visualization on a rostopic for debugging
IasonTheodorou May 13, 2025
4252c39
Add new segmented implementation on the pipeline
IasonTheodorou May 20, 2025
d117ba6
Segment and display on rqt the results
IasonTheodorou May 20, 2025
6f62a5a
Added rgb preprocessing by appliying the depth preprocessed filter fo…
IasonTheodorou May 21, 2025
bf03804
Added new visualization
IasonTheodorou May 27, 2025
913d02a
Added some more filtering (a statistical one to remove outliers in th…
IasonTheodorou May 29, 2025
d1c8fab
Added debug statements and publish pointcloud (still not fully working)
IasonTheodorou Jun 3, 2025
37eda3d
Publish the pointcloud as a ROS topic for visual inspection of the pr…
IasonTheodorou Jun 5, 2025
aae3dab
Added new filtering for point cloud estimation
IasonTheodorou Jun 5, 2025
ef905cd
Better visualization on rqt
IasonTheodorou Jun 6, 2025
f84f153
Applied GMM and DBSCAN to clean the pointcloud noise
IasonTheodorou Jun 9, 2025
5264017
Implemented Bayesian GMM for having also priors on the model
IasonTheodorou Jun 13, 2025
9fe979d
Kept GMM with no-prior enabled
IasonTheodorou Jun 13, 2025
0af0aaf
Added ros parames to tune all the priors of the bayesian GMM
IasonTheodorou Jun 17, 2025
046e257
Added ros parames small fix to compile
IasonTheodorou Jun 17, 2025
cd350be
Implemented GMM with parameters for fast turning (without compile)
IasonTheodorou Jun 19, 2025
0342e9e
Select the inlier based on argmax responsibility and not based on geo…
IasonTheodorou Jun 19, 2025
5730d57
Update non-bayesian GMM to perform hard-clustering based on responsib…
IasonTheodorou Jun 20, 2025
23d5d85
Added also a fully variational inference engine for bayesian GMM (now…
IasonTheodorou Jun 20, 2025
6d52901
Add rosparameters for dbscan as well
IasonTheodorou Jul 1, 2025
540ee56
Removed custom simple statistical filter (kept only GMM)
IasonTheodorou Jul 6, 2025
8c50423
Model the outliers as uniform distribution
IasonTheodorou Jul 8, 2025
6aadaab
Used SAM and BMM models from ros packages instead of bad way (still n…
IasonTheodorou Sep 10, 2025
df14783
Made ed_sensor_integration use only the new ros packages (yolo-sam-bm…
IasonTheodorou Sep 12, 2025
b15d832
Removed all visualization function from updater and included it into …
IasonTheodorou Sep 12, 2025
8f82ba0
Included the old behavior now with segmenter_ object as a pointer
IasonTheodorou Sep 12, 2025
f77fc9c
Updating CMakeLists and small refactoring/fixes
IasonTheodorou Sep 24, 2025
61fe7e4
Changed function naming to proper match as part of the refactoring
IasonTheodorou Sep 24, 2025
08658a0
added doxygen description for the new functions
IasonTheodorou Sep 26, 2025
d103982
removed hardcoded values (added variables for them) and removed some …
IasonTheodorou Sep 26, 2025
58f4df7
commented out simple statistical outlier removal since GMM is much st…
IasonTheodorou Sep 26, 2025
70aa2ad
made indexing of the CV mat more robust since before it was treated a…
IasonTheodorou Sep 26, 2025
7a2532c
impoved ROS error logging
IasonTheodorou Sep 26, 2025
7a5dff6
added sam correct header paths
IasonTheodorou Sep 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 116 additions & 41 deletions ed_sensor_integration/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
cmake_minimum_required(VERSION 3.0.2)
cmake_minimum_required(VERSION 3.5)
project(ed_sensor_integration)

add_compile_options(-Wall -Werror=all)
add_compile_options(-Wextra -Werror=extra)

#add_compile_options(-Wall -Werror=all)
#add_compile_options(-Wextra -Werror=extra)

# -------------- ONNXRuntime Setup (define this early) ------------------#
set(ONNXRUNTIME_VERSION 1.21.1)
set(ONNXRUNTIME_ROOT "/home/amigo/Documents/repos/hero_sam.bak/onnxruntime-linux-x64-gpu-${ONNXRUNTIME_VERSION}")
Copy link
Preview

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard-coded absolute paths make the build non-portable. These paths should be configurable through environment variables or CMake cache variables, e.g., set(ONNXRUNTIME_ROOT $ENV{ONNXRUNTIME_ROOT} CACHE PATH \"Path to ONNX Runtime\").

Copilot uses AI. Check for mistakes.

Copy link
Preview

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded absolute paths make the build non-portable. Use environment variables, find_package, or relative paths to make the build system more flexible and portable across different systems.

Suggested change
set(ONNXRUNTIME_ROOT "/home/amigo/Documents/repos/hero_sam.bak/onnxruntime-linux-x64-gpu-${ONNXRUNTIME_VERSION}")
# Set ONNXRUNTIME_ROOT via environment variable or CMake cache variable for portability.
if(NOT DEFINED ONNXRUNTIME_ROOT AND DEFINED ENV{ONNXRUNTIME_ROOT})
set(ONNXRUNTIME_ROOT $ENV{ONNXRUNTIME_ROOT})
endif()
set(ONNXRUNTIME_ROOT "${ONNXRUNTIME_ROOT}" CACHE PATH "Path to ONNX Runtime installation (set via -DONNXRUNTIME_ROOT=... or environment variable ONNXRUNTIME_ROOT)")
if(NOT ONNXRUNTIME_ROOT)
message(FATAL_ERROR "ONNXRUNTIME_ROOT is not set. Please set it via -DONNXRUNTIME_ROOT=... or export ONNXRUNTIME_ROOT=...")
endif()

Copilot uses AI. Check for mistakes.


# -------------- Neural Network Models ------------------#

# Copy model files to the same folder as the executables
#configure_file(/home/amigo/Documents/repos/hero_sam.bak/yolo_inference/data/coco.yaml ${CATKIN_DEVEL_PREFIX}/lib/ed_sensor_integration/coco.yaml COPYONLY)
#configure_file(/home/amigo/Documents/repos/hero_sam.bak/yolo_inference/model/yolo11m.onnx ${CATKIN_DEVEL_PREFIX}/lib/ed_sensor_integration/yolo11m.onnx COPYONLY)
# configure_file(/home/amigo/Documents/repos/hero_sam.bak/sam_inference/model/SAM_mask_decoder.onnx ${CATKIN_DEVEL_PREFIX}/lib/ed_sensor_integration/SAM_mask_decoder.onnx COPYONLY)
# configure_file(/home/amigo/Documents/repos/hero_sam.bak/sam_inference/model/SAM_encoder.onnx ${CATKIN_DEVEL_PREFIX}/lib/ed_sensor_integration/SAM_encoder.onnx COPYONLY)
#OR
# Define model paths
set(YOLO_MODELS_PATH "/home/amigo/Documents/repos/hero_sam.bak/yolo_inference/model")
set(SAM_MODELS_PATH "/home/amigo/Documents/repos/hero_sam.bak/sam_inference/model")
Comment on lines +21 to +22
Copy link
Preview

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard-coded absolute paths make the build non-portable. These paths should be configurable through environment variables or CMake cache variables, e.g., set(ONNXRUNTIME_ROOT $ENV{ONNXRUNTIME_ROOT} CACHE PATH \"Path to ONNX Runtime\").

Copilot uses AI. Check for mistakes.

Copy link
Preview

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded absolute paths make the build non-portable. Use environment variables, find_package, or relative paths to make the build system more flexible and portable across different systems.

Suggested change
set(SAM_MODELS_PATH "/home/amigo/Documents/repos/hero_sam.bak/sam_inference/model")
# Set the path to the SAM model files. Override with -DSAM_MODELS_PATH=/your/path when running cmake.
set(SAM_MODELS_PATH "" CACHE PATH "Path to the SAM model files")

Copilot uses AI. Check for mistakes.


# Make these paths available to the C++ code
add_definitions(-DYOLO_MODELS_PATH="${YOLO_MODELS_PATH}")
add_definitions(-DSAM_MODELS_PATH="${SAM_MODELS_PATH}")

find_package(OpenCV REQUIRED)
find_package(PCL REQUIRED COMPONENTS common kdtree)
Expand All @@ -21,6 +42,13 @@ find_package(catkin REQUIRED COMPONENTS
tue_config
tue_filesystem
visualization_msgs
# 2D -> 3D point cloud estimation
yolo_onnx_ros
sam_onnx_ros
bmm_ros
# For displaying SAM MASK
cv_bridge
image_transport
)

# ------------------------------------------------------------------------------------------------
Expand All @@ -29,8 +57,14 @@ find_package(catkin REQUIRED COMPONENTS

catkin_package(
INCLUDE_DIRS include
LIBRARIES ed_kinect
CATKIN_DEPENDS code_profiler ed ${PROJECT_NAME}_msgs geolib2 image_geometry rgbd rgbd_image_buffer roscpp tue_config visualization_msgs
LIBRARIES
ed_kinect
${PROJECT_NAME}_console_bridge
ed_association
ed_laser
CATKIN_DEPENDS
code_profiler ed ${PROJECT_NAME}_msgs geolib2 image_geometry rgbd rgbd_image_buffer roscpp tue_config visualization_msgs
sam_onnx_ros bmm_ros cv_bridge image_transport
DEPENDS OpenCV PCL
)

Expand All @@ -43,14 +77,17 @@ include_directories(
SYSTEM
${OpenCV_INCLUDE_DIRS}
${catkin_INCLUDE_DIRS}
${ONNXRUNTIME_ROOT}/include

)

# ------------------------------------------------------------------------------------------------
# LIBRARIES
# ------------------------------------------------------------------------------------------------



add_library(${PROJECT_NAME}_console_bridge
# Foward geolib2 and tue_filesystem logging to rosconsole
src/rosconsole_bridge.cpp
)

Expand All @@ -60,24 +97,34 @@ add_library(ed_association
)

add_library(ed_kinect
include/ed/kinect/association.h
include/ed/kinect/beam_model.h
include/ed/kinect/entity_update.h
include/ed/kinect/fitter.h
include/ed/kinect/mesh_tools.h
include/ed/kinect/renderer.h
include/ed/kinect/segmenter.h
include/ed/kinect/updater.h

src/kinect/association.cpp
src/kinect/beam_model.cpp
src/kinect/fitter.cpp
src/kinect/mesh_tools.cpp
src/kinect/renderer.cpp
src/kinect/segmenter.cpp
src/kinect/updater.cpp
)
target_link_libraries(ed_kinect ${PROJECT_NAME}_console_bridge ed_association ${OpenCV_LIBRARIES} ${catkin_LIBRARIES})
include/ed/kinect/association.h
include/ed/kinect/beam_model.h
include/ed/kinect/entity_update.h
include/ed/kinect/fitter.h
include/ed/kinect/mesh_tools.h
include/ed/kinect/renderer.h
include/ed/kinect/segmenter.h
include/ed/kinect/updater.h
src/kinect/association.cpp
src/kinect/beam_model.cpp
src/kinect/fitter.cpp
src/kinect/mesh_tools.cpp
src/kinect/renderer.cpp
src/kinect/segmenter.cpp
src/kinect/updater.cpp
)

add_library(ed_sam_segment_module
include/ed_sensor_integration/kinect/segmodules/sam_seg_module.h
src/kinect/sam_seg_module.cpp
)
target_link_libraries(ed_kinect
${PROJECT_NAME}_console_bridge
ed_association
ed_sam_segment_module
${OpenCV_LIBRARIES}
${catkin_LIBRARIES}
)
add_dependencies(ed_kinect ${catkin_EXPORTED_TARGETS})

add_library(ed_laser
Expand All @@ -93,28 +140,36 @@ add_dependencies(ed_laser ${catkin_EXPORTED_TARGETS})
# ------------------------------------------------------------------------------------------------

add_library(ed_kinect_plugin
src/kinect/kinect_plugin.cpp
src/kinect/kinect_plugin.h
src/kinect/ray_tracer.cpp
src/kinect/ray_tracer.h
src/kinect/kinect_plugin.cpp
src/kinect/kinect_plugin.h
src/kinect/ray_tracer.cpp
src/kinect/ray_tracer.h
)
target_link_libraries(ed_kinect_plugin ${PROJECT_NAME}_console_bridge ed_kinect ${catkin_LIBRARIES})

target_link_libraries(ed_kinect_plugin
${PROJECT_NAME}_console_bridge
ed_kinect
${catkin_LIBRARIES}
)

add_dependencies(ed_kinect_plugin ${catkin_EXPORTED_TARGETS})

# ------------------------------------------------------------------------------------------------

add_library(ed_laser_plugin
src/laser/laser_plugin.cpp
src/laser/laser_plugin.h
src/laser/laser_plugin.cpp
src/laser/laser_plugin.h
)

target_link_libraries(ed_laser_plugin ${PROJECT_NAME}_console_bridge ed_laser ed_association ${catkin_LIBRARIES})

# ------------------------------------------------------------------------------------------------

add_library(ed_clearer_plugin
src/clearer/clearer_plugin.cpp
src/clearer/clearer_plugin.h
src/clearer/clearer_plugin.cpp
src/clearer/clearer_plugin.h
)

target_link_libraries(ed_clearer_plugin ${catkin_LIBRARIES})

# ------------------------------------------------------------------------------------------------
Expand All @@ -126,13 +181,26 @@ target_link_libraries(ed_image_saver ${catkin_LIBRARIES})
add_dependencies(ed_image_saver ${catkin_EXPORTED_TARGETS})

add_executable(ed_segmenter tools/segmenter.cpp)
target_link_libraries(ed_segmenter ed_kinect ${catkin_LIBRARIES})
target_link_libraries(ed_segmenter
ed_kinect
${catkin_LIBRARIES}
)

add_executable(ed_fitter_data tools/fitter_viz_data.cpp)
target_link_libraries(ed_fitter_data ${PROJECT_NAME}_console_bridge ed_kinect ${OpenCV_LIBRARIES} ${catkin_LIBRARIES})
target_link_libraries(ed_fitter_data
${PROJECT_NAME}_console_bridge
ed_kinect
${OpenCV_LIBRARIES}
${catkin_LIBRARIES}
)

add_executable(ed_fitter_live tools/fitter_viz_live.cpp)
target_link_libraries(ed_fitter_live ${PROJECT_NAME}_console_bridge ed_kinect ${OpenCV_LIBRARIES} ${catkin_LIBRARIES})
target_link_libraries(ed_fitter_live
${PROJECT_NAME}_console_bridge
ed_kinect
${OpenCV_LIBRARIES}
${catkin_LIBRARIES}
)

# ------------------------------------------------------------------------------------------------
# Install
Expand Down Expand Up @@ -179,11 +247,18 @@ if (CATKIN_ENABLE_TESTING)
catkin_add_catkin_lint_test("-W2 --ignore HEADER_OUTSIDE_PACKAGE_INCLUDE_PATH")

catkin_add_gtest(test_furniture_fitting test/test_furniture_fit.cpp)
target_link_libraries(test_furniture_fitting ${PROJECT_NAME}_console_bridge ed_kinect ${OpenCV_LIBRARIES} ${catkin_LIBRARIES})
target_link_libraries(test_furniture_fitting
${PROJECT_NAME}_console_bridge
ed_kinect
${OpenCV_LIBRARIES}
${catkin_LIBRARIES}
)

catkin_add_gtest(test_laser_fitting test/test_laser_segmenter.cpp)
target_link_libraries(test_laser_fitting ${PROJECT_NAME}_console_bridge ed_laser ${OpenCV_LIBRARIES} ${catkin_LIBRARIES})
target_link_libraries(test_laser_fitting
${PROJECT_NAME}_console_bridge
ed_laser
${OpenCV_LIBRARIES}
${catkin_LIBRARIES}
)
endif ()



30 changes: 25 additions & 5 deletions ed_sensor_integration/include/ed/kinect/segmenter.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <rgbd/types.h>
#include <geolib/datatypes.h>
#include <opencv2/core/core.hpp>
#include <tue/config/configuration.h>

#include <ed/convex_hull.h>
#include <ed/types.h>
Expand All @@ -29,7 +30,7 @@ class Segmenter

public:

Segmenter();
Segmenter(tue::Configuration config);

~Segmenter();

Expand All @@ -38,12 +39,31 @@ class Segmenter

void calculatePointsWithin(const rgbd::Image& image, const geo::Shape& shape,
const geo::Pose3D& shape_pose, cv::Mat& filtered_depth_image) const;

void cluster(const cv::Mat& depth_image, const geo::DepthCamera& cam_model,
const geo::Pose3D& sensor_pose, std::vector<EntityUpdate>& clusters) const;
/**
* @brief Preprocess RGB image for segmentation. This function masks the RGB image with the filtered depth image (non-zero depth values are kept)
* It returns a masked RGB image with values only where depth is non-zero
*
* @param rgb_image
* @param filtered_depth_image
* @return cv::Mat filtered_depth_image
*/
cv::Mat preprocessRGBForSegmentation(const cv::Mat& rgb_image, const cv::Mat& filtered_depth_image) const;

/**
* @brief Cluster the depth image into segments. Applies new algorithm which is the YOLO - SAM - BMM depth segmentation pipeline.
*
* @param depth_image
* @param cam_model
* @param sensor_pose
* @param clusters
* @param rgb_image
* @return std::vector<cv::Mat> masks // 3D pointcloud masks of all the segmented objects
*/
std::vector<cv::Mat> cluster(const cv::Mat& depth_image, const geo::DepthCamera& cam_model,
const geo::Pose3D& sensor_pose, std::vector<EntityUpdate>& clusters, const cv::Mat& rgb_image);

private:

tue::Configuration config_;
};

#endif
11 changes: 8 additions & 3 deletions ed_sensor_integration/include/ed/kinect/updater.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
#include "ed/kinect/segmenter.h"
#include "ed/kinect/entity_update.h"

#include <tue/config/configuration.h>

#include <map>
#include <vector>

// ----------------------------------------------------------------------------------------------------

struct UpdateRequest
Expand Down Expand Up @@ -48,7 +49,7 @@ class Updater

public:

Updater();
Updater(tue::Configuration config);

~Updater();

Expand All @@ -59,11 +60,15 @@ class Updater

Fitter fitter_;

Segmenter segmenter_;
std::unique_ptr<Segmenter> segmenter_;

// Stores for each segmented entity with which area description it was found
std::map<ed::UUID, std::string> id_to_area_description_;

//For displaying SAM MASK
ros::Publisher mask_pub_;
ros::Publisher cloud_pub_;

};

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#pragma once

#include <ros/ros.h>
#include "yolo_inference.h"
#include "sam_inference.h"
#include <sensor_msgs/Image.h>
#include <sensor_msgs/PointCloud2.h>
#include <opencv2/core.hpp>
//#include "ed/kinect/entity_update.h"
#include <cv_bridge/cv_bridge.h>
#include <geolib/sensors/DepthCamera.h>
#include <geolib/Shape.h>
#include <pcl/point_types.h>
#include <pcl/point_cloud.h>
#include <pcl/segmentation/extract_clusters.h>
#include <pcl_conversions/pcl_conversions.h>
#include <sensor_msgs/Image.h>
#include <sensor_msgs/PointCloud2.h>

// EntityUpdate and UpdateResult come from kinect (avoid including laser variant to prevent redefinition)
#include <ed/kinect/entity_update.h>
#include <ed/kinect/segmenter.h> // defines UpdateResult (and possibly other needed types)

/**
* @brief Segmentation pipeline that processes the input image and generates segmentation masks.
*
* @param img The input RGB image to segment.
* @return std::vector<cv::Mat> The generated segmentation masks.
*/
std::vector<cv::Mat> SegmentationPipeline(const cv::Mat& img);

/**
* @brief Overlay segmentation masks on the RGB image for visualization purposes.
*
* @param rgb The RGB image to overlay masks on.
* @param masks The segmentation masks to overlay.
*/
void overlayMasksOnImage_(cv::Mat& rgb, const std::vector<cv::Mat>& masks);

/**
* @brief Publish segmentation results and pointcloud estimation as ROS messages.
*
* @param filtered_depth_image The filtered depth image to publish.
* @param rgb The RGB image to publish.
* @param sensor_pose The pose of the sensor.
* @param clustered_images The clustered segmentation masks.
* @param mask_pub_ The ROS publisher for the mask images.
* @param cloud_pub_ The ROS publisher for the point cloud data.
* @param res_updates The entity updates to publish.
*/
void publishSegmentationResults(const cv::Mat& filtered_depth_image, const cv::Mat& rgb,
const geo::Pose3D& sensor_pose, std::vector<cv::Mat>& clustered_images,
ros::Publisher& mask_pub_, ros::Publisher& cloud_pub_, std::vector<EntityUpdate>& res_updates);
Loading
Loading