staubli_driver_ros2 main
ROS2 control driver for Staubli robots
Loading...
Searching...
No Matches
messages.hpp
Go to the documentation of this file.
1// Copyright 2025 ICUBE Laboratory, University of Strasbourg
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// Author: Thibault Poignonec (thibault.poignonec@gmail.fr)
16
17#ifndef STAUBLI_ROBOT_DRIVER__COMMUNICATION__MESSAGES_HPP_
18#define STAUBLI_ROBOT_DRIVER__COMMUNICATION__MESSAGES_HPP_
19
21
22
24
63public:
65 ~RobotStateMessage() = default;
66
67 // Bring the vector-based methods from the base class into scope
70
72 bool serialize(uint8_t* buffer, size_t buffer_size) const override;
73
75 bool deserialize(uint8_t* buffer, size_t buffer_size) override;
76
78 static size_t message_size();
79
81 size_t get_serialized_size() const override {
82 return message_size();
83 }
84
85public:
86 // Sequence delay
87 uint16_t sequence_delay = 0;
88
89 // Robot operation mode
91
92 // Robot operation mode status (signification depends on mode...)
93 uint8_t operation_mode_status = 100;
94
95 // Current robot control state
97
98 // Safety state enum
100
101 // Robot status flags
102 bool power_on = false;
103 bool brakes_released = false;
104 bool motion_possible = false;
105 bool in_motion = false;
106 bool error_state = false;
107 bool estop_pressed = false;
108
109 // Valid fields flags
112 bool has_joint_torques = false;
113 bool has_ft_sensor = false;
114 bool has_digital_inputs = false;
115 bool has_analog_inputs = false;
116
117 // Joint positions in radians
118 std::array<double, 6> joint_positions;
119
120 // Joint velocities in radians/s
121 std::array<double, 6> joint_velocities;
122
123 // Joint torques in Nm
124 std::array<double, 6> joint_torques;
125
126 // F/T sensor readings in N and Nm
127 std::array<double, 6> ft_sensor;
128
129 // Digital inputs
130 std::array<bool, 16> digital_inputs;
131
132 // Analog inputs
133 std::array<double, 4> analog_inputs;
134};
135
140public:
143
144 // Bring the vector-based methods from the base class into scope
145 using Message::serialize;
147
149 bool serialize(uint8_t* buffer, size_t buffer_size) const override;
150
152 bool deserialize(uint8_t* buffer, size_t buffer_size) override;
153
155 static size_t message_size();
156
158 size_t get_serialized_size() const override {
159 return message_size();
160 }
161
162public:
163 // Command type (position, velocity, torque)
165
166 // Controller period in milliseconds
167 double controller_period = -1.0;
168
179 std::array<double, 6> command_reference;
180
181 // Digital outputs
182 std::array<bool, 16> digital_outputs;
183
184 // Analog outputs
185 std::array<double, 4> analog_outputs;
186};
187
192public:
195
196 // Bring the vector-based methods from the base class into scope
197 using Message::serialize;
199
201 bool serialize(uint8_t* buffer, size_t buffer_size) const override;
202
204 bool deserialize(uint8_t* buffer, size_t buffer_size) override;
205
207 static size_t message_size();
208
210 size_t get_serialized_size() const override {
211 return message_size();
212 }
213
214public:
215 // Robot controller type
216 enum class RobotControllerType : uint8_t {
217 UNKNOWN = 0x00,
218 CS8 = 0x01,
219 CS9 = 0x02,
220 };
222
223 // Robot firmware major version
224 struct Version {
225 uint8_t major;
226 uint8_t minor;
227 uint8_t patch;
228 };
230
231 // Error log entries, maximum 10 entries
233 uint32_t timestamp;
234 uint16_t error_code;
235 };
236 std::array<ErrorLogEntry, 10> error_log;
237
238 // Robot task statuses
240};
241
242} // namespace staubli_robot_driver
243
244#endif // STAUBLI_ROBOT_DRIVER__COMMUNICATION__MESSAGES_HPP_
Diagnostic data.
Definition messages.hpp:191
Version robot_firmware_version
Definition messages.hpp:229
size_t get_serialized_size() const override
Size of the entire message in bytes.
Definition messages.hpp:210
std::array< ErrorLogEntry, 10 > error_log
Definition messages.hpp:236
bool deserialize(uint8_t *buffer, size_t buffer_size) override
Deserialize bytes to message.
uint16_t control_task_status
Definition messages.hpp:239
RobotControllerType
Definition messages.hpp:216
RobotControllerType robot_controller_type
Definition messages.hpp:221
static size_t message_size()
Get the size of the message, static version.
bool serialize(uint8_t *buffer, size_t buffer_size) const override
Serialize message to bytes.
Generic message structure.
Definition protocol.hpp:104
virtual bool serialize(uint8_t *buffer, size_t buffer_size) const =0
Serialize message to bytes.
virtual bool deserialize(uint8_t *buffer, size_t buffer_size)=0
Deserialize bytes to message.
Robot command message.
Definition messages.hpp:139
CommandType command_type
Definition messages.hpp:164
static size_t message_size()
Get the size of the message, static version.
std::array< double, 4 > analog_outputs
Definition messages.hpp:185
bool serialize(uint8_t *buffer, size_t buffer_size) const override
Serialize message to bytes.
size_t get_serialized_size() const override
Size of the entire message in bytes.
Definition messages.hpp:158
std::array< double, 6 > command_reference
Command reference for the robot.
Definition messages.hpp:179
std::array< bool, 16 > digital_outputs
Definition messages.hpp:182
bool deserialize(uint8_t *buffer, size_t buffer_size) override
Deserialize bytes to message.
double controller_period
Definition messages.hpp:167
Robot state message.
Definition messages.hpp:62
OperationMode operation_mode
Definition messages.hpp:90
SafetyStatus safety_status
Definition messages.hpp:99
std::array< double, 6 > joint_torques
Definition messages.hpp:124
bool in_motion
Definition messages.hpp:105
static size_t message_size()
Get the size of the message, static version.
std::array< double, 6 > ft_sensor
Definition messages.hpp:127
bool serialize(uint8_t *buffer, size_t buffer_size) const override
Serialize message to bytes.
size_t get_serialized_size() const override
Size of the entire message in bytes.
Definition messages.hpp:81
std::array< double, 6 > joint_positions
Definition messages.hpp:118
CommandType control_state
Definition messages.hpp:96
std::array< bool, 16 > digital_inputs
Definition messages.hpp:130
bool has_analog_inputs
Definition messages.hpp:115
uint8_t operation_mode_status
Definition messages.hpp:93
bool has_digital_inputs
Definition messages.hpp:114
bool has_joint_positions
Definition messages.hpp:110
std::array< double, 6 > joint_velocities
Definition messages.hpp:121
bool estop_pressed
Definition messages.hpp:107
bool brakes_released
Definition messages.hpp:103
bool error_state
Definition messages.hpp:106
bool deserialize(uint8_t *buffer, size_t buffer_size) override
Deserialize bytes to message.
bool has_joint_velocities
Definition messages.hpp:111
std::array< double, 4 > analog_inputs
Definition messages.hpp:133
bool has_joint_torques
Definition messages.hpp:112
bool power_on
Definition messages.hpp:102
uint16_t sequence_delay
Definition messages.hpp:87
bool has_ft_sensor
Definition messages.hpp:113
bool motion_possible
Definition messages.hpp:104
Definition messages.hpp:23
OperationMode
Operation modes.
Definition types.hpp:49
CommandType
Command types.
Definition types.hpp:35
SafetyStatus
Safety status.
Definition types.hpp:74
uint16_t error_code
Error code, 0 if no error.
Definition messages.hpp:234
uint32_t timestamp
Timestamp of the error in milliseconds.
Definition messages.hpp:233
uint8_t major
Definition messages.hpp:225
uint8_t patch
Definition messages.hpp:227
uint8_t minor
Definition messages.hpp:226