Galaxis Codebase  1.0.0
Team Galaxis software stack for the Carolo Cup 2023 - ROS2 based software
DepthCamera.hpp
Go to the documentation of this file.
1 #ifndef CAMERA_HPP_
2 #define CAMERA_HPP_
3 
4 #include <librealsense2/rs.hpp> // Include RealSense Cross Platform API
5 #include <librealsense2/rs_advanced_mode.hpp>
6 #include <librealsense2/hpp/rs_types.hpp>
7 #include <librealsense2/rsutil.h>
8 
9 #include <rclcpp/rclcpp.hpp>
10 
11 #include <sensor_msgs/msg/point_cloud2.hpp>
12 #include <sensor_msgs/point_cloud2_iterator.hpp>
13 
14 // #include <PCLObjectDetector.hpp>
15 #include <string>
16 #include <mutex>
17 #include <memory>
18 #include <condition_variable>
19 
20 // pcl
21 #include <pcl/point_types.h>
22 #include <pcl/filters/passthrough.h>
23 
24 class Realsense {
25 private:
26  rs2::config m_cfg;
27  rs2::pipeline m_pipe;
28  rs2::pipeline_profile m_profile;
29  std::shared_ptr<std::pair<rclcpp::Time, pcl::PointCloud<pcl::PointXYZ>::Ptr>> m_currentPointCloudPairSPtr = nullptr;
31 
32  rclcpp::Node* m_nodePtr;
33 
34  std::mutex m_mtx;
35  std::condition_variable m_newPCLConditionVar;
36 
37  pcl::PointCloud<pcl::PointXYZ>::Ptr points_to_pcl(const rs2::points& points);
38 
39 public:
40  Realsense() {};
41 
42  void set_node(rclcpp::Node* ptr);
43 
48  void init(std::string config);
49 
50  std::shared_ptr<std::pair<rclcpp::Time, pcl::PointCloud<pcl::PointXYZ>::Ptr>> pop_last_grabbed_pcl(bool blocking);
51  std::shared_ptr<std::pair<rclcpp::Time, pcl::PointCloud<pcl::PointXYZ>::Ptr>> get_last_grabbed_pcl();
52 };
53 
54 #endif /* ifndef CAMERA_HPP_ */
Realsense::m_newPCLConditionVar
std::condition_variable m_newPCLConditionVar
Definition: DepthCamera.hpp:35
Realsense::get_last_grabbed_pcl
std::shared_ptr< std::pair< rclcpp::Time, pcl::PointCloud< pcl::PointXYZ >::Ptr > > get_last_grabbed_pcl()
Definition: DepthCamera.cpp:156
Realsense::Realsense
Realsense()
Definition: DepthCamera.hpp:40
Realsense::m_nodePtr
rclcpp::Node * m_nodePtr
Definition: DepthCamera.hpp:32
Realsense::m_currentPointCloudPairSPtr
std::shared_ptr< std::pair< rclcpp::Time, pcl::PointCloud< pcl::PointXYZ >::Ptr > > m_currentPointCloudPairSPtr
Definition: DepthCamera.hpp:29
Realsense::set_node
void set_node(rclcpp::Node *ptr)
Definition: DepthCamera.cpp:10
Realsense
Definition: DepthCamera.hpp:24
Realsense::m_profile
rs2::pipeline_profile m_profile
Definition: DepthCamera.hpp:28
Realsense::m_pipe
rs2::pipeline m_pipe
Definition: DepthCamera.hpp:27
Realsense::m_mtx
std::mutex m_mtx
Definition: DepthCamera.hpp:34
Realsense::m_cfg
rs2::config m_cfg
Definition: DepthCamera.hpp:26
Realsense::points_to_pcl
pcl::PointCloud< pcl::PointXYZ >::Ptr points_to_pcl(const rs2::points &points)
Definition: DepthCamera.cpp:162
Realsense::m_currentPointCloudPairNewData
bool m_currentPointCloudPairNewData
Definition: DepthCamera.hpp:30
Realsense::init
void init(std::string config)
initializes camera with json settings
Definition: DepthCamera.cpp:14
Realsense::pop_last_grabbed_pcl
std::shared_ptr< std::pair< rclcpp::Time, pcl::PointCloud< pcl::PointXYZ >::Ptr > > pop_last_grabbed_pcl(bool blocking)
Definition: DepthCamera.cpp:137