28 #include <boost/predef/other/endian.h> 31 #include <msgpack.hpp> 35 #if BOOST_ENDIAN_LITTLE_BYTE 36 #define ENDIANNESS_STR "<" 37 #elif BOOST_ENDIAN_BIG_BYTE 38 #define ENDIANNESS_STR ">" 40 #error Cannot determine endianness 56 return ENDIANNESS_STR
"f4";
60 return ENDIANNESS_STR
"f8";
68 return ENDIANNESS_STR
"i2";
72 return ENDIANNESS_STR
"i4";
76 return ENDIANNESS_STR
"i8";
84 return ENDIANNESS_STR
"u2";
88 return ENDIANNESS_STR
"u4";
92 return ENDIANNESS_STR
"u8";
118 static std::string
MsgId() {
return "array"; }
122 const std::vector<int64_t>&
shape) {
124 arr.
type = TypeStr<T>();
126 arr.
data.ptr = (
const char*)ptr;
128 for (int64_t n : shape) num *= n;
144 std::string& errstr)
const {
145 for (
auto rank : expected_ranks) {
146 if (shape.size() ==
size_t(rank))
return true;
148 errstr +=
" expected rank to be in (";
149 for (
auto rank : expected_ranks) {
150 errstr += std::to_string(rank) +
", ";
152 errstr += std::string(
")") +
" but got shape [";
153 for (
auto d : shape) {
154 errstr += std::to_string(d) +
", ";
159 bool CheckRank(
const std::vector<int>& expected_ranks)
const {
168 std::string& errstr)
const {
173 for (
size_t i = 0; i < expected_shape.size(); ++i) {
174 int64_t d_expected = expected_shape[i];
175 int64_t d = shape[i];
176 if ((d_expected != -1 && d_expected != d) || d < 0) {
177 errstr +=
" expected shape [";
178 for (
auto d : expected_shape) {
182 errstr += std::to_string(d) +
", ";
185 errstr +=
"] but got [";
186 for (
auto d : shape) {
187 errstr += std::to_string(d) +
", ";
195 bool CheckShape(
const std::vector<int64_t>& expected_shape)
const {
205 for (
auto d : shape) n *= d;
206 if (0 == n || shape.empty()) {
207 errstr +=
" expected non empty array but got array with shape [";
208 for (
auto d : shape) {
209 errstr += std::to_string(d) +
", ";
224 bool CheckType(
const std::vector<std::string>& expected_types,
225 std::string& errstr)
const {
226 for (
const auto& t : expected_types) {
227 if (t == type)
return true;
229 errstr +=
" expected array type to be one of (";
230 for (
const auto& t : expected_types) {
233 errstr +=
") but got " +
type;
236 bool CheckType(
const std::vector<std::string>& expected_types)
const {
247 static std::string
MsgId() {
return "mesh_data"; }
280 std::string tmp =
"invalid vertices array:";
283 if (!status) errstr += tmp;
288 if (faces.
shape.empty())
return true;
290 std::string tmp =
"invalid faces array:";
292 bool status = faces.
CheckRank({1, 2}, tmp);
313 status = faces.
shape[1] > 2;
314 tmp +=
" expected shape [?, >2] but got [" +
315 std::to_string(faces.
shape[0]) +
", " +
316 std::to_string(faces.
shape[1]) +
"]";
326 std::string tmp =
"invalid mesh_data message:";
327 bool status = CheckVertices(errstr) && CheckFaces(errstr);
328 if (!status) errstr += tmp;
344 static std::string
MsgId() {
return "set_mesh_data"; }
363 static std::string
MsgId() {
return "get_mesh_data"; }
379 static std::string
MsgId() {
return "camera_data"; }
387 std::array<double, 4>
R;
389 std::array<double, 3>
t;
405 R, t, intrinsic_model, intrinsic_parameters, width, height, images);
411 static std::string
MsgId() {
return "set_camera_data"; }
431 static std::string
MsgId() {
return "set_time"; }
441 static std::string
MsgId() {
return "set_active_camera"; }
450 static std::string
MsgId() {
return "set_properties"; }
475 static std::string
MsgId() {
return "status"; }
478 Status(
int code,
const std::string& str) : code(code), str(str) {}
481 return Status(1,
"unsupported msg_id");
484 return Status(2,
"error during unpacking");
487 return Status(3,
"error while processing message");
std::string msg_id
Definition: Messages.h:461
std::string msg_id
Definition: Messages.h:468
bool CheckNonEmpty() const
Definition: Messages.h:216
bool CheckType(const std::vector< std::string > &expected_types, std::string &errstr) const
Definition: Messages.h:224
std::string TypeStr< float >()
Definition: Messages.h:55
std::string TypeStr< uint8_t >()
Definition: Messages.h:79
std::string path
Definition: Messages.h:451
Definition: Messages.h:117
const char const char value recording_handle imu_sample recording_handle uint8_t size_t data_size k4a_record_configuration_t config target_format k4a_capture_t capture_handle k4a_imu_sample_t imu_sample playback_handle k4a_logging_message_cb_t void min_level device_handle k4a_imu_sample_t timeout_in_ms capture_handle capture_handle capture_handle image_handle temperature_c k4a_image_t image_handle uint8_t image_handle image_handle image_handle image_handle uint32_t
Definition: K4aPlugin.cpp:557
int32_t time
The time for which to return the data.
Definition: Messages.h:418
const T * Ptr() const
Definition: Messages.h:137
static std::string MsgId()
Definition: Messages.h:379
std::string path
Path defining the location in the scene tree.
Definition: Messages.h:349
bool CheckMessage(std::string &errstr) const
Definition: Messages.h:325
std::string TypeStr()
Definition: Messages.h:51
Status(int code, const std::string &str)
Definition: Messages.h:478
CameraData data
The data to be set.
Definition: Messages.h:423
std::string TypeStr< int64_t >()
Definition: Messages.h:75
int32_t time
The time associated with this data.
Definition: Messages.h:351
struct for storing MeshData, e.g., PointClouds, TriangleMesh, ..
Definition: Messages.h:246
static Status ErrorProcessingMessage()
Definition: Messages.h:486
Definition: Messages.h:474
std::string TypeStr< int8_t >()
Definition: Messages.h:63
static std::string MsgId()
Definition: Messages.h:118
std::string path
Definition: Messages.h:442
static std::string MsgId()
Definition: Messages.h:247
Definition: Messages.h:343
struct for storing camera data
Definition: Messages.h:378
Definition: Messages.h:410
const char const char value recording_handle imu_sample recording_handle uint8_t size_t data_size k4a_record_configuration_t config target_format k4a_capture_t capture_handle k4a_imu_sample_t imu_sample playback_handle k4a_logging_message_cb_t void min_level device_handle k4a_imu_sample_t int32_t
Definition: K4aPlugin.cpp:398
Definition: Messages.h:449
msgpack::type::raw_ref data
Definition: Messages.h:134
Definition: Messages.h:460
std::string path
Path defining the location in the scene tree.
Definition: Messages.h:368
bool CheckVertices(std::string &errstr) const
Definition: Messages.h:279
Definition: Messages.h:430
bool CheckShape(const std::vector< int64_t > &expected_shape, std::string &errstr) const
Definition: Messages.h:167
std::string path
Path defining the location in the scene tree.
Definition: Messages.h:416
std::map< std::string, Array > textures
map of arrays that can be interpreted as textures
Definition: Messages.h:277
bool CheckNonEmpty(std::string &errstr) const
Definition: Messages.h:203
GetMeshData()
Definition: Messages.h:365
static Status OK()
Definition: Messages.h:479
MSGPACK_DEFINE_MAP(type, shape, data)
std::vector< int64_t > shape
Definition: Messages.h:133
Array vertices
shape must be [num_verts,3]
Definition: Messages.h:250
Status()
Definition: Messages.h:477
static Status ErrorUnsupportedMsgId()
Definition: Messages.h:480
static std::string MsgId()
Definition: Messages.h:344
int height
Definition: Messages.h:399
bool CheckFaces(std::string &errstr) const
Definition: Messages.h:287
std::string TypeStr< uint16_t >()
Definition: Messages.h:83
std::map< std::string, Array > face_attributes
stores arbitrary attributes for each face
Definition: Messages.h:263
std::map< std::string, Array > line_attributes
stores arbitrary attributes for each line
Definition: Messages.h:274
std::string TypeStr< uint32_t >()
Definition: Messages.h:87
std::string layer
The layer for which to return the data.
Definition: Messages.h:420
std::string TypeStr< uint64_t >()
Definition: Messages.h:91
bool CheckRank(const std::vector< int > &expected_ranks) const
Definition: Messages.h:159
static std::string MsgId()
Definition: Messages.h:363
bool CheckType(const std::vector< std::string > &expected_types) const
Definition: Messages.h:236
static std::string MsgId()
Definition: Messages.h:411
Array lines
Definition: Messages.h:272
std::vector< double > intrinsic_parameters
Definition: Messages.h:395
std::string TypeStr< int16_t >()
Definition: Messages.h:67
const char const char value recording_handle imu_sample recording_handle uint8_t size_t data_size k4a_record_configuration_t config target_format k4a_capture_t capture_handle k4a_imu_sample_t imu_sample playback_handle k4a_logging_message_cb_t void min_level device_handle k4a_imu_sample_t timeout_in_ms capture_handle capture_handle capture_handle image_handle temperature_c int
Definition: K4aPlugin.cpp:479
int32_t time
The time for which to return the data.
Definition: Messages.h:370
std::string intrinsic_model
Definition: Messages.h:394
static std::string MsgId()
Definition: Messages.h:450
static std::string MsgId()
Definition: Messages.h:441
std::string TypeStr< int32_t >()
Definition: Messages.h:71
static std::string MsgId()
Definition: Messages.h:431
SetTime()
Definition: Messages.h:432
std::string str
string representation of the code
Definition: Messages.h:493
CameraData()
Definition: Messages.h:381
std::map< std::string, Array > images
map of arrays that can be interpreted as camera images
Definition: Messages.h:402
SetMeshData()
Definition: Messages.h:346
int32_t time
Definition: Messages.h:433
Definition: Messages.h:440
Definition: PinholeCameraIntrinsic.cpp:35
std::string layer
The layer for this data.
Definition: Messages.h:353
int height
Definition: FilePCD.cpp:72
std::array< double, 3 > t
translation
Definition: Messages.h:389
struct for defining a "get_mesh_data" message, which requests mesh data.
Definition: Messages.h:362
bool CheckShape(const std::vector< int64_t > &expected_shape) const
Definition: Messages.h:195
std::string layer
The layer for which to return the data.
Definition: Messages.h:372
const char const char value recording_handle imu_sample recording_handle uint8_t size_t data_size k4a_record_configuration_t config target_format k4a_capture_t capture_handle k4a_imu_sample_t imu_sample playback_handle k4a_logging_message_cb_t void min_level device_handle k4a_imu_sample_t timeout_in_ms capture_handle capture_handle capture_handle image_handle temperature_c k4a_image_t image_handle uint8_t image_handle image_handle image_handle image_handle image_handle timestamp_usec white_balance image_handle k4a_device_configuration_t config device_handle char size_t serial_number_size bool int32_t int32_t int32_t int32_t k4a_color_control_mode_t default_mode value const const k4a_calibration_t calibration char size_t
Definition: K4aPlugin.cpp:724
MeshData data
The data to be set.
Definition: Messages.h:356
bool CheckRank(const std::vector< int > &expected_ranks, std::string &errstr) const
Definition: Messages.h:143
SetCameraData()
Definition: Messages.h:413
static Array FromPtr(const T *const ptr, const std::vector< int64_t > &shape)
Definition: Messages.h:121
Definition: Messages.h:467
int width
image dimensions in pixels
Definition: Messages.h:398
Array faces
Definition: Messages.h:261
std::array< double, 4 > R
rotation R as quaternion [x,y,z,w]
Definition: Messages.h:387
static Status ErrorUnpackingFailed()
Definition: Messages.h:483
static std::string MsgId()
Definition: Messages.h:475
std::map< std::string, Array > vertex_attributes
Definition: Messages.h:253
int32_t code
return code. 0 means everything is OK.
Definition: Messages.h:491
int width
Definition: FilePCD.cpp:71
std::string type
Definition: Messages.h:132
std::string TypeStr< double >()
Definition: Messages.h:59