rby1-sdk
Loading...
Searching...
No Matches
robot_command_feedback.h
1#pragma once
2
3#include <memory>
4#include <string>
5#include <vector>
6
7#include "Eigen/Core"
8#include "export.h"
9
10namespace rb {
11
12class RobotCommandFeedbackParserImpl;
13
14class RBY1_SDK_API Feedback {
15 public:
16 bool valid() const { return valid_; }
17
18 private:
19 bool valid_{false};
20
21 friend class RobotCommandFeedbackParserImpl;
22};
23
24class RBY1_SDK_API CommandHeaderFeedback : public Feedback {
25 public:
26 bool finished() const { return finished_; }
27
28 private:
29 bool finished_;
30
31 friend class RobotCommandFeedbackParserImpl;
32};
33
34class RBY1_SDK_API CommandFeedback : public Feedback {
35 public:
36 const CommandHeaderFeedback& command_header() const { return command_header_; }
37
38 protected:
39 CommandHeaderFeedback command_header_{};
40
41 friend class RobotCommandFeedbackParserImpl;
42};
43
44class RBY1_SDK_API StopCommandFeedback : public CommandFeedback {
45 public:
46 protected:
47 private:
48 friend class RobotCommandFeedbackParserImpl;
49};
50
52 public:
53 protected:
54 private:
55 friend class RobotCommandFeedbackParserImpl;
56};
57
58class RBY1_SDK_API SE2VelocityCommandFeedback : public CommandFeedback {
59 public:
60 protected:
61 private:
62 friend class RobotCommandFeedbackParserImpl;
63};
64
65class RBY1_SDK_API JogCommandFeedback : public CommandFeedback {
66 public:
67 const std::string& target_joint_name() const { return target_joint_name_; }
68
69 protected:
70 std::string target_joint_name_;
71
72 private:
73 friend class RobotCommandFeedbackParserImpl;
74};
75
76class RBY1_SDK_API JointVelocityCommandFeedback : public CommandFeedback {
77 public:
78 protected:
79 private:
80 friend class RobotCommandFeedbackParserImpl;
81};
82
83class RBY1_SDK_API JointPositionCommandFeedback : public CommandFeedback {
84 public:
85 double time_based_progress() const { return time_based_progress_; }
86
87 double position_based_progress() const { return position_based_progress_; }
88
89 protected:
90 double time_based_progress_{};
91 double position_based_progress_{};
92
93 private:
94 friend class RobotCommandFeedbackParserImpl;
95};
96
98 public:
99 const std::vector<unsigned int>& joint_indices() const { return joint_indices_; }
100
101 double time_based_progress() const { return time_based_progress_; }
102
103 double position_based_progress() const { return position_based_progress_; }
104
105 protected:
106 std::vector<unsigned int> joint_indices_;
107 double time_based_progress_;
108 double position_based_progress_;
109
110 private:
111 friend class RobotCommandFeedbackParserImpl;
112};
113
114class RBY1_SDK_API CartesianCommandFeedback : public CommandFeedback {
115 public:
116 struct RBY1_SDK_API TrackingError {
117 double position_error;
118 double orientation_error;
119 };
120
121 const std::vector<TrackingError>& se3_pose_tracking_errors() const { return se3_pose_tracking_errors_; }
122
123 const std::vector<double>& joint_position_tracking_errors() const { return joint_position_tracking_errors_; }
124
125 double remain_time() const { return remain_time_; }
126
127 double manipulability() const { return manipulability_; }
128
129 protected:
130 std::vector<TrackingError> se3_pose_tracking_errors_;
131 std::vector<double> joint_position_tracking_errors_;
132 double remain_time_;
133 double manipulability_;
134
135 private:
136 friend class RobotCommandFeedbackParserImpl;
137};
138
140 public:
141 Eigen::VectorXd set_position() const { return set_position_; }
142
143 double remain_time() const { return remain_time_; }
144
145 double manipulability() const { return manipulability_; }
146
147 private:
148 Eigen::VectorXd set_position_;
149 double remain_time_;
150 double manipulability_;
151
152 private:
153 friend class RobotCommandFeedbackParserImpl;
154};
155
157 public:
158 protected:
159 private:
160 friend class RobotCommandFeedbackParserImpl;
161};
162
164 public:
165 struct RBY1_SDK_API TrackingError {
166 double position_error;
167 double rotation_error;
168 };
169
170 const TrackingError& tracking_error() const { return tracking_error_; }
171
172 protected:
173 TrackingError tracking_error_{};
174
175 private:
176 friend class RobotCommandFeedbackParserImpl;
177};
178
180 public:
181 const std::vector<double>& set_position() const { return set_position_; }
182
183 const std::vector<double>& error() const { return error_; }
184
185 protected:
186 std::vector<double> set_position_;
187 std::vector<double> error_;
188
189 private:
190 friend class RobotCommandFeedbackParserImpl;
191};
192
194 public:
195 double total_cost() const { return total_cost_; }
196
197 const std::vector<double>& cartesian_costs() const { return cartesian_costs_; }
198
199 double center_of_mass_cost() const { return center_of_mass_cost_; }
200
201 const std::vector<double>& joint_position_costs() const { return joint_position_costs_; }
202
203 protected:
204 double total_cost_;
205 std::vector<double> cartesian_costs_;
206 double center_of_mass_cost_;
207 std::vector<double> joint_position_costs_;
208
209 private:
210 friend class RobotCommandFeedbackParserImpl;
211};
212
213class RBY1_SDK_API WholeBodyCommandFeedback : public CommandFeedback {
214 public:
215 const StopCommandFeedback& stop_command() const { return stop_command_; }
216
217 const RealtimeControlCommandFeedback& realtime_control_command() const { return realtime_control_command_; }
218
219 protected:
220 StopCommandFeedback stop_command_;
221 RealtimeControlCommandFeedback realtime_control_command_;
222
223 private:
224 friend class RobotCommandFeedbackParserImpl;
225};
226
227class RBY1_SDK_API ArmCommandFeedback : public CommandFeedback {
228 public:
229 const JointPositionCommandFeedback& joint_position_command() const { return joint_position_command_; }
230
231 const GravityCompensationCommandFeedback& gravity_compensation_command() const {
232 return gravity_compensation_command_;
233 }
234
235 const CartesianCommandFeedback& cartesian_command() const { return cartesian_command_; }
236
237 const ImpedanceControlCommandFeedback& impedance_control_command() const { return impedance_control_command_; }
238
239 const CartesianImpedanceControlCommandFeedback& cartesian_impedance_control_command() const {
240 return cartesian_impedance_control_command_;
241 }
242
243 const JointImpedanceControlCommandFeedback& joint_impedance_control_command() const {
244 return joint_impedance_control_command_;
245 }
246
247 protected:
248 JointPositionCommandFeedback joint_position_command_;
249 GravityCompensationCommandFeedback gravity_compensation_command_;
250 CartesianCommandFeedback cartesian_command_;
251 ImpedanceControlCommandFeedback impedance_control_command_;
252 CartesianImpedanceControlCommandFeedback cartesian_impedance_control_command_;
253 JointImpedanceControlCommandFeedback joint_impedance_control_command_;
254
255 private:
256 friend class RobotCommandFeedbackParserImpl;
257};
258
259class RBY1_SDK_API TorsoCommandFeedback : public CommandFeedback {
260 public:
261 const JointPositionCommandFeedback& joint_position_command() const { return joint_position_command_; }
262
263 const GravityCompensationCommandFeedback& gravity_compensation_command() const {
264 return gravity_compensation_command_;
265 }
266
267 const CartesianCommandFeedback& cartesian_command() const { return cartesian_command_; }
268
269 const ImpedanceControlCommandFeedback& impedance_control_command() const { return impedance_control_command_; }
270
271 const OptimalControlCommandFeedback& optimal_control_command() const { return optimal_control_command_; }
272
273 const CartesianImpedanceControlCommandFeedback& cartesian_impedance_control_command() const {
274 return cartesian_impedance_control_command_;
275 }
276
277 const JointImpedanceControlCommandFeedback& joint_impedance_control_command() const {
278 return joint_impedance_control_command_;
279 }
280
281 const JointGroupPositionCommandFeedback& joint_group_position_command() const {
282 return joint_group_position_command_;
283 }
284
285 protected:
286 JointPositionCommandFeedback joint_position_command_;
287 GravityCompensationCommandFeedback gravity_compensation_command_;
288 CartesianCommandFeedback cartesian_command_;
289 ImpedanceControlCommandFeedback impedance_control_command_;
290 OptimalControlCommandFeedback optimal_control_command_;
291 CartesianImpedanceControlCommandFeedback cartesian_impedance_control_command_;
292 JointImpedanceControlCommandFeedback joint_impedance_control_command_;
293 JointGroupPositionCommandFeedback joint_group_position_command_;
294
295 private:
296 friend class RobotCommandFeedbackParserImpl;
297};
298
300 public:
301 const ArmCommandFeedback& right_arm_command() const { return right_arm_command_; } // NOLINT
302
303 const ArmCommandFeedback& left_arm_command() const { return left_arm_command_; } // NOLINT
304
305 const TorsoCommandFeedback& torso_command() const { return torso_command_; } // NOLINT
306
307 protected:
308 ArmCommandFeedback right_arm_command_;
309 ArmCommandFeedback left_arm_command_;
310 TorsoCommandFeedback torso_command_;
311
312 private:
313 friend class RobotCommandFeedbackParserImpl;
314};
315
316class RBY1_SDK_API HeadCommandFeedback : public CommandFeedback {
317 public:
318 const JointPositionCommandFeedback& joint_position_command() const { return joint_position_command_; } // NOLINT
319
320 protected:
321 JointPositionCommandFeedback joint_position_command_;
322
323 private:
324 friend class RobotCommandFeedbackParserImpl;
325};
326
327class RBY1_SDK_API BodyCommandFeedback : public CommandFeedback {
328 public:
329 const JointPositionCommandFeedback& joint_position_command() const { return joint_position_command_; } // NOLINT
330
331 const OptimalControlCommandFeedback& optimal_control_command() const { return optimal_control_command_; } // NOLINT
332
333 const GravityCompensationCommandFeedback& gravity_compensation_command() const { // NOLINT
334 return gravity_compensation_command_;
335 }
336
337 const CartesianCommandFeedback& cartesian_command() const { return cartesian_command_; } // NOLINT
338
339 const BodyComponentBasedCommandFeedback& body_component_based_command() const { // NOLINT
340 return body_component_based_command_;
341 }
342
343 const CartesianImpedanceControlCommandFeedback& cartesian_impedance_control_command() const {
344 return cartesian_impedance_control_command_;
345 }
346
347 const JointImpedanceControlCommandFeedback& joint_impedance_control_command() const {
348 return joint_impedance_control_command_;
349 }
350
351 protected:
352 JointPositionCommandFeedback joint_position_command_;
353 OptimalControlCommandFeedback optimal_control_command_;
354 GravityCompensationCommandFeedback gravity_compensation_command_;
355 CartesianCommandFeedback cartesian_command_;
356 BodyComponentBasedCommandFeedback body_component_based_command_;
357 CartesianImpedanceControlCommandFeedback cartesian_impedance_control_command_;
358 JointImpedanceControlCommandFeedback joint_impedance_control_command_;
359
360 private:
361 friend class RobotCommandFeedbackParserImpl;
362};
363
364class RBY1_SDK_API MobilityCommandFeedback : public CommandFeedback {
365 public:
366 const JointVelocityCommandFeedback& joint_velocity_command() const { return joint_velocity_command_; } // NOLINT
367
368 const SE2VelocityCommandFeedback& se2_velocity_command() const { return se2_velocity_command_; } // NOLINT
369
370 protected:
371 JointVelocityCommandFeedback joint_velocity_command_;
372 SE2VelocityCommandFeedback se2_velocity_command_;
373
374 private:
375 friend class RobotCommandFeedbackParserImpl;
376};
377
379 public:
380 const HeadCommandFeedback& head_command() const { return head_command_; } // NOLINT
381
382 const BodyCommandFeedback& body_command() const { return body_command_; } // NOLINT
383
384 const MobilityCommandFeedback& mobility_command() const { return mobility_command_; } // NOLINT
385
386 protected:
387 HeadCommandFeedback head_command_;
388 BodyCommandFeedback body_command_;
389 MobilityCommandFeedback mobility_command_;
390
391 private:
392 friend class RobotCommandFeedbackParserImpl;
393};
394
395class RBY1_SDK_API RobotCommandFeedback : public CommandFeedback {
396 public:
397 enum class Status : int { kIdle = 0, kInitializing, kRunning, kFinished };
398
399 enum class FinishCode : int {
400 kUnknown = 0,
401 kOk,
402 kCanceled,
403 kPreempted,
404 kInitializationFailed,
405 kControlManagerIdle,
406 kControlManagerFault,
407 kUnexpectedState
408 };
409
410 const WholeBodyCommandFeedback& whole_body_command() const { return whole_body_command_; } // NOLINT
411
412 const ComponentBasedCommandFeedback& component_based_command() const { return component_based_command_; } // NOLINT
413
414 const JogCommandFeedback& jog_command() const { return jog_command_; } // NOLINT
415
416 const Status& status() const { return status_; } // NOLINT
417
418 const FinishCode& finish_code() const { return finish_code_; } // NOLINT
419
420 protected:
421 WholeBodyCommandFeedback whole_body_command_;
422 ComponentBasedCommandFeedback component_based_command_;
423 JogCommandFeedback jog_command_;
424
425 Status status_{};
426 FinishCode finish_code_{};
427
428 private:
429 friend class RobotCommandFeedbackParserImpl;
430};
431
432class RBY1_SDK_API RobotCommandFeedbackParser {
433 public:
435
437
438 void Parse(RobotCommandFeedback& self, void* msg);
439
440 private:
441 std::unique_ptr<RobotCommandFeedbackParserImpl> impl_;
442};
443
444} // namespace rb
Definition robot_command_feedback.h:227
Definition robot_command_feedback.h:327
Definition robot_command_feedback.h:299
Definition robot_command_feedback.h:114
Definition robot_command_feedback.h:139
Definition robot_command_feedback.h:34
Definition robot_command_feedback.h:24
Definition robot_command_feedback.h:378
Definition robot_command_feedback.h:14
Definition robot_command_feedback.h:156
Definition robot_command_feedback.h:316
Definition robot_command_feedback.h:163
Definition robot_command_feedback.h:65
Definition robot_command_feedback.h:97
Definition robot_command_feedback.h:179
Definition robot_command_feedback.h:83
Definition robot_command_feedback.h:76
Definition robot_command_feedback.h:364
Definition robot_command_feedback.h:193
Definition robot_command_feedback.h:51
Definition robot_command_feedback.h:395
Definition robot_command_feedback.h:432
Definition robot_command_feedback.h:58
Definition robot_command_feedback.h:44
Definition robot_command_feedback.h:259
Definition robot_command_feedback.h:213
Definition robot_command_feedback.h:116
Definition robot_command_feedback.h:165