RealSense Cross Platform API
RealSense Cross-platform API
Loading...
Searching...
No Matches
rs_safety_sensor.hpp
Go to the documentation of this file.
1// License: Apache 2.0. See LICENSE file in root directory.
2// Copyright(c) 2024 RealSense, Inc. All Rights Reserved.
3
4#ifndef LIBREALSENSE_RS2_SAFETY_SENSOR_HPP
5#define LIBREALSENSE_RS2_SAFETY_SENSOR_HPP
6
7#include "rs_sensor.hpp"
8
9namespace rs2
10{
11 class safety_sensor : public sensor
12 {
13 public:
15 : sensor(s.get())
16 {
17 rs2_error* e = nullptr;
19 {
20 _sensor.reset();
21 }
23 }
24
25 operator bool() const { return _sensor.get() != nullptr; }
26
27 std::string get_safety_preset(int index) const
28 {
29 std::vector<uint8_t> result;
30
31 rs2_error* e = nullptr;
32 auto buffer = rs2_get_safety_preset(_sensor.get(), index, &e);
33
34 std::shared_ptr<const rs2_raw_data_buffer> list(buffer, rs2_delete_raw_data);
36
37 auto size = rs2_get_raw_data_size(list.get(), &e);
39
40 auto start = rs2_get_raw_data(list.get(), &e);
42
43 result.insert(result.begin(), start, start + size);
44
45 return std::string(result.begin(), result.end());
46 }
47
48 void set_safety_preset(int index, const std::string& sp_json_str) const
49 {
50 rs2_error* e = nullptr;
51 rs2_set_safety_preset(_sensor.get(), index, sp_json_str.c_str(), &e);
53 }
54
56 {
57 std::vector<uint8_t> result;
58
59 rs2_error* e = nullptr;
60 auto buffer = rs2_get_safety_interface_config(_sensor.get(), calib_location, &e);
61
62 std::shared_ptr<const rs2_raw_data_buffer> list(buffer, rs2_delete_raw_data);
64
65 auto size = rs2_get_raw_data_size(list.get(), &e);
67
68 auto start = rs2_get_raw_data(list.get(), &e);
70
71 result.insert(result.begin(), start, start + size);
72
73 return std::string(result.begin(), result.end());
74
75 }
76
77 void set_safety_interface_config(const std::string& sic_json_str) const
78 {
79 rs2_error* e = nullptr;
80 rs2_set_safety_interface_config(_sensor.get(), sic_json_str.c_str(), &e);
82
83 }
84
85 std::string get_application_config() const
86 {
87 std::vector<uint8_t> result;
88
89 rs2_error* e = nullptr;
90 auto buffer = rs2_get_application_config(_sensor.get(), &e);
91
92 std::shared_ptr<const rs2_raw_data_buffer> list(buffer, rs2_delete_raw_data);
94
95 auto size = rs2_get_raw_data_size(list.get(), &e);
97
98 auto start = rs2_get_raw_data(list.get(), &e);
100
101 result.insert(result.begin(), start, start + size);
102
103 return std::string(result.begin(), result.end());
104 }
105
106 void set_application_config(const std::string& application_config_json_str) const
107 {
108 rs2_error* e = nullptr;
109 rs2_set_application_config(_sensor.get(), application_config_json_str.c_str(), &e);
110 error::handle(e);
111 }
112
113 };
114}
115#endif // LIBREALSENSE_RS2_SAFETY_SENSOR_HPP
static void handle(rs2_error *e)
Definition rs_types.hpp:167
void set_application_config(const std::string &application_config_json_str) const
Definition rs_safety_sensor.hpp:106
std::string get_application_config() const
Definition rs_safety_sensor.hpp:85
safety_sensor(sensor s)
Definition rs_safety_sensor.hpp:14
void set_safety_interface_config(const std::string &sic_json_str) const
Definition rs_safety_sensor.hpp:77
std::string get_safety_interface_config(rs2_calib_location calib_location=RS2_CALIB_LOCATION_RAM) const
Definition rs_safety_sensor.hpp:55
void set_safety_preset(int index, const std::string &sp_json_str) const
Definition rs_safety_sensor.hpp:48
std::string get_safety_preset(int index) const
Definition rs_safety_sensor.hpp:27
sensor()
Definition rs_sensor.hpp:349
std::shared_ptr< rs2_sensor > _sensor
Definition rs_sensor.hpp:388
const std::shared_ptr< rs2_sensor > & get() const
Definition rs_sensor.hpp:356
void start(T callback) const
Definition rs_sensor.hpp:186
Definition rs_processing_gl.hpp:13
const unsigned char * rs2_get_raw_data(const rs2_raw_data_buffer *buffer, rs2_error **error)
int rs2_get_raw_data_size(const rs2_raw_data_buffer *buffer, rs2_error **error)
void rs2_delete_raw_data(const rs2_raw_data_buffer *buffer)
void rs2_set_application_config(rs2_sensor const *sensor, const char *application_config_json_str, rs2_error **error)
void rs2_set_safety_preset(rs2_sensor const *sensor, int index, const char *sp_json_str, rs2_error **error)
const rs2_raw_data_buffer * rs2_get_safety_interface_config(rs2_sensor const *sensor, rs2_calib_location loc, rs2_error **error)
const rs2_raw_data_buffer * rs2_get_application_config(rs2_sensor const *sensor, rs2_error **error)
const rs2_raw_data_buffer * rs2_get_safety_preset(rs2_sensor const *sensor, int index, rs2_error **error)
void rs2_set_safety_interface_config(rs2_sensor const *sensor, const char *sic_json_str, rs2_error **error)
int rs2_is_sensor_extendable_to(const rs2_sensor *sensor, rs2_extension extension, rs2_error **error)
rs2_calib_location
Definition rs_types.h:256
@ RS2_CALIB_LOCATION_RAM
Definition rs_types.h:260
@ RS2_EXTENSION_SAFETY_SENSOR
Definition rs_types.h:196
struct rs2_error rs2_error
Definition rs_types.h:276