Galaxis Codebase  1.0.0
Team Galaxis software stack for the Carolo Cup 2023 - ROS2 based software
RealSenseNode.hpp
Go to the documentation of this file.
1 #ifndef PARAM_IDENT_NODE_HPP_
2 #define PARAM_IDENT_NODE_HPP_
3 
4 #include <vector>
5 #include <string>
6 #include <mutex>
7 #include <opencv2/core.hpp>
8 #include <opencv2/objdetect.hpp>
9 #include <opencv2/imgproc/imgproc.hpp>
10 #include <cv_bridge/cv_bridge.h>
11 #include <DepthCamera.hpp>
12 
13 #include <galaxis/GalaxisNode.hpp>
14 #include <sensor_msgs/msg/point_cloud2.hpp>
15 
16 #include <iostream>
17 
18 #include <PCLObjectDetector.hpp>
19 
20 class RealSenseNode : public GalaxisNode {
21 private:
22  bool m_debugMode = false;
23  bool m_listenToROSPCL = false;
24 
27 
28  // ros2
29  rclcpp::Publisher<ObstacleListType>::SharedPtr m_obstaclePublisher;
30 
31  // debug
32  rclcpp::Publisher<sensor_msgs::msg::PointCloud2>::SharedPtr m_depthPublisherSPtr;
33  rclcpp::Publisher<sensor_msgs::msg::PointCloud2>::SharedPtr m_debugPclPublisherFiltered;
34  rclcpp::Publisher<sensor_msgs::msg::PointCloud2>::SharedPtr m_debugPclPublisherResult;
35 
36  // ros2 replay
37  rclcpp::Subscription<sensor_msgs::msg::PointCloud2>::SharedPtr m_depthSubscriberSPtr;
38 
40 
41  std::mutex m_settingsMtx;
42 
43  // settings are overwritten by runtime_system.json
44 
45  /* NICE PARAMS -- NOT REALLY
46 
47  "cluster_extraction": {
48  "cluster_size_max": 5000,
49  "cluster_size_min": 300,
50  "cluster_tolerance": 0.02,
51  "leaf_size": 0.015
52  },
53  "postprocessing": {
54  "object_min_size_x": 0.1,
55  "object_min_size_y": 0.2,
56  "object_min_size_z": 0.001
57  }
58  */
59 
60  // GOOD PARAMETERS -- NOT REALLY
61  float m_clusterTolerance = 0.02f;
62  unsigned int m_minClusterSize = 300;
63  unsigned int m_maxClusterSize = 5000;
64  float m_leafSize = 0.015;
65  /* vertical axis points to bottom */
66  float m_yMin = -1.00;
67  float m_yMax = 1.00;
68 
69 
70 public:
71  RealSenseNode();
72 
73 private:
74  void on_ros_pointcloud_callback(sensor_msgs::msg::PointCloud2::SharedPtr pclMsg);
75  void object_detection_loop();
76  void object_detection(std::shared_ptr<std::pair<rclcpp::Time, pcl::PointCloud<pcl::PointXYZ>::Ptr>> pointCloudRawPair);
77  // void pointcloud_publish_loop();
78 
79  rcl_interfaces::msg::SetParametersResult new_parameters_callback(const std::vector<rclcpp::Parameter>& parameters);
80 };
81 
82 #endif //PARAM_IDENT_NODE_HPP_
RealSenseNode::m_cam
Realsense m_cam
Definition: RealSenseNode.hpp:25
RealSenseNode::object_detection
void object_detection(std::shared_ptr< std::pair< rclcpp::Time, pcl::PointCloud< pcl::PointXYZ >::Ptr >> pointCloudRawPair)
Definition: RealSenseNode.cpp:88
RealSenseNode::m_depthPublisherSPtr
rclcpp::Publisher< sensor_msgs::msg::PointCloud2 >::SharedPtr m_depthPublisherSPtr
Definition: RealSenseNode.hpp:32
RealSenseNode::m_listenToROSPCL
bool m_listenToROSPCL
Definition: RealSenseNode.hpp:23
EuclideanDetector
Definition: PCLObjectDetector.hpp:61
RealSenseNode::m_leafSize
float m_leafSize
Definition: RealSenseNode.hpp:64
RealSenseNode::m_depthSubscriberSPtr
rclcpp::Subscription< sensor_msgs::msg::PointCloud2 >::SharedPtr m_depthSubscriberSPtr
Definition: RealSenseNode.hpp:37
RealSenseNode::m_minClusterSize
unsigned int m_minClusterSize
Definition: RealSenseNode.hpp:62
RealSenseNode
Definition: RealSenseNode.hpp:20
RealSenseNode::m_clusterTolerance
float m_clusterTolerance
Definition: RealSenseNode.hpp:61
PCLObjectDetector.hpp
GalaxisNode.hpp
RealSenseNode::new_parameters_callback
rcl_interfaces::msg::SetParametersResult new_parameters_callback(const std::vector< rclcpp::Parameter > &parameters)
Definition: RealSenseNode.cpp:188
Realsense
Definition: DepthCamera.hpp:24
RealSenseNode::on_ros_pointcloud_callback
void on_ros_pointcloud_callback(sensor_msgs::msg::PointCloud2::SharedPtr pclMsg)
Definition: RealSenseNode.cpp:65
RealSenseNode::m_debugPclPublisherFiltered
rclcpp::Publisher< sensor_msgs::msg::PointCloud2 >::SharedPtr m_debugPclPublisherFiltered
Definition: RealSenseNode.hpp:33
RealSenseNode::m_maxClusterSize
unsigned int m_maxClusterSize
Definition: RealSenseNode.hpp:63
RealSenseNode::m_debugMode
bool m_debugMode
Definition: RealSenseNode.hpp:22
RealSenseNode::m_objectDetector
EuclideanDetector m_objectDetector
Definition: RealSenseNode.hpp:39
RealSenseNode::m_debugPclPublisherResult
rclcpp::Publisher< sensor_msgs::msg::PointCloud2 >::SharedPtr m_debugPclPublisherResult
Definition: RealSenseNode.hpp:34
GalaxisNode
Definition: GalaxisNode.hpp:21
RealSenseNode::m_yMax
float m_yMax
Definition: RealSenseNode.hpp:67
RealSenseNode::m_yMin
float m_yMin
Definition: RealSenseNode.hpp:66
RealSenseNode::m_obstaclePublisher
rclcpp::Publisher< ObstacleListType >::SharedPtr m_obstaclePublisher
Definition: RealSenseNode.hpp:29
RealSenseNode::RealSenseNode
RealSenseNode()
Definition: RealSenseNode.cpp:24
RealSenseNode::object_detection_loop
void object_detection_loop()
Definition: RealSenseNode.cpp:74
RealSenseNode::m_settingsMtx
std::mutex m_settingsMtx
Definition: RealSenseNode.hpp:41
DepthCamera.hpp
RealSenseNode::m_settingsJsonFilename
std::string m_settingsJsonFilename
Definition: RealSenseNode.hpp:26