ros2_control - foxy
Loading...
Searching...
No Matches
serialization.h
1// Copyright 2026 Open Source Robotics Foundation, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef ZENBEDDED_TRANSPORT__SERIALIZATION_H_
16#define ZENBEDDED_TRANSPORT__SERIALIZATION_H_
17
18#include <stdbool.h>
19#include <stddef.h>
20#include <stdint.h>
21
22#ifdef __cplusplus
23extern "C"
24{
25#endif
26
27#ifdef CONFIG_ZENBEDDED_TIER_1
28
32 typedef struct
33 {
34 uint32_t num_joints;
35 size_t offset_timestamp;
36 size_t offset_position;
37 size_t offset_velocity;
38 size_t offset_effort;
39 size_t payload_size;
40 } zcdr_joint_state_ctx_t;
41
51 void zcdr_init_joint_state(
52 zcdr_joint_state_ctx_t * ctx, const char * frame_id, const char ** joint_names,
53 uint32_t num_joints, uint8_t * out_buffer);
54
66 void zcdr_serialize_joint_state(
67 const zcdr_joint_state_ctx_t * ctx, int32_t stamp_sec, uint32_t stamp_nanosec,
68 const double * positions, const double * velocities, const double * efforts,
69 uint8_t * out_buffer);
70
84 bool zcdr_deserialize_joint_state(
85 const zcdr_joint_state_ctx_t * ctx, const uint8_t * in_buffer, size_t buffer_size,
86 int32_t * out_stamp_sec, uint32_t * out_stamp_nanosec, double * out_positions,
87 double * out_velocities, double * out_efforts);
88
92 typedef struct
93 {
94 uint32_t num_joints;
95 size_t offset_timestamp;
96 size_t offset_values;
97 size_t payload_size;
98 } zcdr_joint_command_ctx_t;
99
110 void zcdr_init_joint_command(
111 zcdr_joint_command_ctx_t * ctx, const char * frame_id, const char ** joint_names,
112 uint32_t num_joints, const char * interface_name, uint8_t * out_buffer);
113
123 void zcdr_serialize_joint_command(
124 const zcdr_joint_command_ctx_t * ctx, int32_t stamp_sec, uint32_t stamp_nanosec,
125 const double * values, uint8_t * out_buffer);
126
138 bool zcdr_deserialize_joint_command(
139 const zcdr_joint_command_ctx_t * ctx, const uint8_t * in_buffer, size_t buffer_size,
140 int32_t * out_stamp_sec, uint32_t * out_stamp_nanosec, double * out_values);
141#endif // CONFIG_ZENBEDDED_TIER_1
142
143#ifdef __cplusplus
144}
145#endif
146
147#endif // ZENBEDDED_TRANSPORT__SERIALIZATION_H_