zivid_camera.h
Go to the documentation of this file.
1 #pragma once
2 
5 
6 #include <sensor_msgs/PointCloud2.h>
7 #include <sensor_msgs/Image.h>
8 
10 
11 #include <dynamic_reconfigure/server.h>
12 
13 #include <ros/ros.h>
14 
15 #include <Zivid/Application.h>
16 #include <Zivid/Camera.h>
17 #include <Zivid/Image.h>
18 
19 namespace Zivid
20 {
21 class Settings;
22 }
23 
24 namespace zivid_camera
25 {
26 enum class CameraStatus
27 {
28  Idle,
29  Connected,
31 };
32 
34 {
35 public:
37 
38 private:
39  void onCameraConnectionKeepAliveTimeout(const ros::TimerEvent& event);
40  void reconnectToCameraIfNecessary();
41  void setCameraStatus(CameraStatus camera_status);
42  bool cameraInfoModelNameServiceHandler(CameraInfoModelName::Request& req, CameraInfoModelName::Response& res);
43  bool cameraInfoSerialNumberServiceHandler(CameraInfoSerialNumber::Request& req,
44  CameraInfoSerialNumber::Response& res);
45  bool captureServiceHandler(Capture::Request& req, Capture::Response& res);
46  bool capture2DServiceHandler(Capture2D::Request& req, Capture2D::Response& res);
47  bool captureAssistantSuggestSettingsServiceHandler(CaptureAssistantSuggestSettings::Request& req,
48  CaptureAssistantSuggestSettings::Response& res);
49  void serviceHandlerHandleCameraConnectionLoss();
50  bool isConnectedServiceHandler(IsConnected::Request& req, IsConnected::Response& res);
51  void publishFrame(Zivid::Frame&& frame);
52  bool shouldPublishPointsXYZ() const;
53  bool shouldPublishPointsXYZRGBA() const;
54  bool shouldPublishColorImg() const;
55  bool shouldPublishDepthImg() const;
56  bool shouldPublishSnrImg() const;
57  std_msgs::Header makeHeader();
58  void publishPointCloudXYZ(const std_msgs::Header& header, const Zivid::PointCloud& point_cloud);
59  void publishPointCloudXYZRGBA(const std_msgs::Header& header, const Zivid::PointCloud& point_cloud);
60  void publishColorImage(const std_msgs::Header& header, const sensor_msgs::CameraInfoConstPtr& camera_info,
61  const Zivid::PointCloud& point_cloud);
62  void publishColorImage(const std_msgs::Header& header, const sensor_msgs::CameraInfoConstPtr& camera_info,
63  const Zivid::Image<Zivid::ColorRGBA>& image);
64  void publishDepthImage(const std_msgs::Header& header, const sensor_msgs::CameraInfoConstPtr& camera_info,
65  const Zivid::PointCloud& point_cloud);
66  void publishSnrImage(const std_msgs::Header& header, const sensor_msgs::CameraInfoConstPtr& camera_info,
67  const Zivid::PointCloud& point_cloud);
68  sensor_msgs::CameraInfoConstPtr makeCameraInfo(const std_msgs::Header& header, std::size_t width, std::size_t height,
69  const Zivid::CameraIntrinsics& intrinsics);
70 
75 
97  std::unique_ptr<Capture3DSettingsController> capture_settings_controller_;
98  std::unique_ptr<Capture2DSettingsController> capture_2d_settings_controller_;
99  Zivid::Application zivid_;
100  Zivid::Camera camera_;
101  std::string frame_id_;
102  unsigned int header_seq_;
103 };
104 } // namespace zivid_camera
std::unique_ptr< Capture2DSettingsController > capture_2d_settings_controller_
Definition: zivid_camera.h:98
bool use_latched_publisher_for_color_image_
Definition: zivid_camera.h:82
image_transport::ImageTransport image_transport_
Definition: zivid_camera.h:87
ros::NodeHandle priv_
Definition: zivid_camera.h:77
CameraStatus camera_status_
Definition: zivid_camera.h:79
ros::ServiceServer is_connected_service_
Definition: zivid_camera.h:96
ros::ServiceServer capture_assistant_suggest_settings_service_
Definition: zivid_camera.h:95
image_transport::CameraPublisher snr_image_publisher_
Definition: zivid_camera.h:90
bool use_latched_publisher_for_depth_image_
Definition: zivid_camera.h:83
bool use_latched_publisher_for_points_xyz_
Definition: zivid_camera.h:80
ros::Publisher points_xyz_publisher_
Definition: zivid_camera.h:85
Zivid::Application zivid_
Definition: zivid_camera.h:99
bool use_latched_publisher_for_points_xyzrgba_
Definition: zivid_camera.h:81
ros::ServiceServer capture_2d_service_
Definition: zivid_camera.h:94
ros::ServiceServer capture_service_
Definition: zivid_camera.h:93
image_transport::CameraPublisher depth_image_publisher_
Definition: zivid_camera.h:89
Controller that manages dynamic_reconfigure nodes for Settings and Settings2D
std::unique_ptr< Capture3DSettingsController > capture_settings_controller_
Definition: zivid_camera.h:97
ros::ServiceServer camera_info_model_name_service_
Definition: zivid_camera.h:92
ros::Timer camera_connection_keepalive_timer_
Definition: zivid_camera.h:78
ros::ServiceServer camera_info_serial_number_service_
Definition: zivid_camera.h:91
ros::Publisher points_xyzrgba_publisher_
Definition: zivid_camera.h:86
image_transport::CameraPublisher color_image_publisher_
Definition: zivid_camera.h:88


zivid_camera
Author(s): Zivid
autogenerated on Sat Apr 17 2021 02:51:05