Flexiv RDK APIs  2.1
data.hpp
Go to the documentation of this file.
1 
7 #ifndef FLEXIV_RDK_DATA_HPP_
8 #define FLEXIV_RDK_DATA_HPP_
9 
10 #include <array>
11 #include <vector>
12 #include <string>
13 #include <ostream>
14 #include <variant>
15 #include <chrono>
16 #include <map>
17 
18 namespace flexiv::rdk {
20 constexpr size_t kCartDoF = 6;
21 
23 constexpr size_t kSerialJointDoF = 7;
24 
26 constexpr size_t kPoseSize = 7;
27 
30 constexpr size_t kIOPorts = 16 + 2 * 2;
31 
33 constexpr size_t kMaxExtAxes = 6;
34 
38 enum class ProductModel
39 {
40  UNKNOWN = 0,
41  Enlight_L,
42  Enlight_LL,
43  MICO_Core,
44  MICO_Plus,
45  MICO_Ultra,
46 };
47 
49 inline const std::map<ProductModel, std::string> kProductModelNames
50  = {{ProductModel::UNKNOWN, "UNKNOWN"}, {ProductModel::Enlight_L, "Enlight-L"},
51  {ProductModel::Enlight_LL, "Enlight-LL"}, {ProductModel::MICO_Core, "MICO-Core"},
52  {ProductModel::MICO_Plus, "MICO-Plus"}, {ProductModel::MICO_Ultra, "MICO-Ultra"}};
53 
57 enum class JointGroup
58 {
59  UNKNOWN = -1,
60  ALL = 0,
61  ARMS = 2,
62  ARM_1 = 3,
63  ARM_2 = 4,
64  EXT_AXIS = 5,
65 
66  FIRST = ALL,
67  LAST = EXT_AXIS,
68 };
69 
71 inline const std::map<JointGroup, std::string> kJointGroupNames {
72  {JointGroup::UNKNOWN, "UNKNOWN"},
73  {JointGroup::ALL, "ALL"},
74  {JointGroup::ARMS, "ARMS"},
75  {JointGroup::ARM_1, "ARM_1"},
76  {JointGroup::ARM_2, "ARM_2"},
77  {JointGroup::EXT_AXIS, "EXT_AXIS"},
78 };
79 
86 {
87  UNKNOWN = 0,
88  READY,
89  BOOTING,
91  NOT_SERVO_ON,
93  MINOR_FAULT,
98  IN_AUTO_MODE,
99 };
100 
102 inline const std::map<OperationalStatus, std::string> kOpStatusNames {
103  {OperationalStatus::UNKNOWN, "Unknown status"},
104  {OperationalStatus::READY, "Ready"},
105  {OperationalStatus::BOOTING, "System booting"},
106  {OperationalStatus::ESTOP_NOT_RELEASED, "E-Stop not released"},
107  {OperationalStatus::NOT_SERVO_ON, "Not servo on"},
108  {OperationalStatus::RELEASING_BRAKE, "Releasing brakes"},
109  {OperationalStatus::MINOR_FAULT, "Minor fault occurred"},
110  {OperationalStatus::CRITICAL_FAULT, "Critical fault occurred"},
111  {OperationalStatus::IN_REDUCED_STATE, "In reduced state"},
112  {OperationalStatus::IN_RECOVERY_STATE, "In recovery state"},
113  {OperationalStatus::IN_MANUAL_MODE, "In Manual mode"},
114  {OperationalStatus::IN_AUTO_MODE, "In regular Auto mode"},
115 };
116 
120 enum class CoordType
121 {
122  WORLD,
123  TCP,
124 };
125 
132 {
133  enum Level
134  {
135  UNKNOWN = 0,
140  };
141 
144 
146  int id = 0;
147 
149  std::string description = "";
150 
152  std::string consequences = "";
153 
155  std::string probable_causes = "";
156 
158  std::string recommended_actions = "";
159 
161  std::chrono::time_point<std::chrono::system_clock> timestamp;
162 };
163 
169 struct RobotInfo
170 {
173 
175  std::string serial_num = {};
176 
178  std::string software_ver = {};
179 
181  std::string license_type = {};
182 
184  std::map<JointGroup, std::string> all_groups = {};
185 
187  std::map<JointGroup, std::string> single_arm_groups = {};
188 
190  std::map<JointGroup, size_t> DoF = {};
191 
197  std::map<JointGroup, std::array<double, kCartDoF>> K_x_nom = {};
198 
202  std::map<JointGroup, std::vector<double>> K_q_nom = {};
203 
206  std::map<JointGroup, std::vector<double>> q_min = {};
207 
210  std::map<JointGroup, std::vector<double>> q_max = {};
211 
214  std::map<JointGroup, std::vector<double>> dq_max = {};
215 
218  std::map<JointGroup, std::vector<double>> tau_max = {};
219 };
220 
226 {
229  std::pair<int, int> timestamp = {};
230 
236  std::vector<double> q = {};
237 
245  std::vector<double> theta = {};
246 
253  std::vector<double> dq = {};
254 
261  std::vector<double> dtheta = {};
262 
267  std::vector<double> tau = {};
268 
274  std::vector<double> tau_dot = {};
275 
282  std::vector<double> tau_ext = {};
283 
289  std::vector<double> tau_interact = {};
290 
295  std::vector<double> temperature = {};
296 
302  std::array<double, kPoseSize> flange_pose = {};
303 
309  std::array<double, kPoseSize> tcp_pose = {};
310 
317  std::array<double, kCartDoF> tcp_twist = {};
318 
325  std::array<double, kCartDoF> tcp_wrench = {};
326 
333  std::array<double, kCartDoF> tcp_wrench_local = {};
334 
338  std::array<double, kCartDoF> raw_tcp_wrench = {};
339 
343  std::array<double, kCartDoF> raw_tcp_wrench_local = {};
344 
351  std::array<double, kCartDoF> raw_ft_sensor = {};
352 };
353 
359 {
362  std::pair<int, int> timestamp = {};
363 
367  std::vector<double> q_d = {};
368 
373  std::vector<double> dq_d = {};
374 
382  std::vector<double> tau_d = {};
383 
389  std::array<double, kPoseSize> tcp_pose_d = {};
390 
397  std::array<double, kCartDoF> tcp_twist_d = {};
398 
405  std::array<double, kCartDoF> tcp_wrench_d = {};
406 };
407 
413 struct PlanInfo
414 {
416  std::string pt_name = {};
417 
419  std::string node_name = {};
420 
422  std::string node_path = {};
423 
425  std::string node_path_time_period = {};
426 
428  std::string node_path_number = {};
429 
431  std::string assigned_plan_name = {};
432 
434  double velocity_scale = {};
435 
437  bool waiting_for_step = {};
438 };
439 
447 struct JPos
448 {
450  JPos() = default;
451 
457  JPos(const std::array<double, kSerialJointDoF>& q_m,
458  const std::array<double, kMaxExtAxes>& q_e = {})
459  : q_m(q_m)
460  , q_e(q_e)
461  {
462  }
463 
465  std::array<double, kSerialJointDoF> q_m = {};
466 
470  std::array<double, kMaxExtAxes> q_e = {};
471 
473  std::string str() const;
474 };
475 
483 struct Coord
484 {
486  Coord() = default;
487 
496  Coord(const std::array<double, kCartDoF / 2>& position,
497  const std::array<double, kCartDoF / 2>& orientation,
498  const std::array<std::string, 2>& ref_frame,
499  const std::array<double, kSerialJointDoF>& ref_q_m = {},
500  const std::array<double, kMaxExtAxes>& ref_q_e = {})
501  : position(position)
504  , ref_q_m(ref_q_m)
505  , ref_q_e(ref_q_e)
506  {
507  }
508 
510  std::array<double, kCartDoF / 2> position = {};
511 
513  std::array<double, kCartDoF / 2> orientation = {};
514 
522  std::array<std::string, 2> ref_frame = {};
523 
528  std::array<double, kSerialJointDoF> ref_q_m = {};
529 
534  std::array<double, kMaxExtAxes> ref_q_e = {};
535 
537  std::string str() const;
538 };
539 
544 enum class SyncMotionMode
545 {
546  DISABLE = 0,
547  ARM1_TCP = 1,
548  ARM2_TCP = 2,
549  POSITIONER = 3,
550 };
551 
553 using FlexivDataTypes = std::variant<int, double, std::string, rdk::JPos, rdk::Coord,
554  std::vector<int>, std::vector<double>, std::vector<std::string>, std::vector<rdk::JPos>,
555  std::vector<rdk::Coord>>;
556 
564 {
566  PrimitiveArgs() = default;
567 
570  const std::string& pt_name, const std::map<std::string, FlexivDataTypes>& input_params)
571  : pt_name(pt_name)
573  {
574  }
575 
577  std::string pt_name = {};
578 
584  std::map<std::string, FlexivDataTypes> input_params = {};
585 
591 
597  SyncMotionMode sync_motion_mode = SyncMotionMode::DISABLE;
598 };
599 
606 {
608  std::string pt_name = {};
609 
614  std::map<std::string, FlexivDataTypes> names_and_values = {};
615 };
616 
623 {
625  RtJointTorqueCmd() = default;
626 
628  RtJointTorqueCmd(const std::vector<double>& tau_d, bool enable_gravity_comp = true,
629  bool enable_soft_limits = true, double friction_comp_scale = 100.0)
630  : tau_d(tau_d)
634  {
635  }
636 
638  std::vector<double> tau_d = {};
639 
641  bool enable_gravity_comp = true;
642 
645  bool enable_soft_limits = true;
646 
651  double friction_comp_scale = 100.0;
652 };
653 
660 {
662  RtJointPositionCmd() = default;
663 
665  RtJointPositionCmd(const std::vector<double>& q_d, const std::vector<double>& dq_d,
666  const std::vector<double>& ddq_d)
667  : q_d(q_d)
668  , dq_d(dq_d)
669  , ddq_d(ddq_d)
670  {
671  }
672 
674  std::vector<double> q_d = {};
675 
678  std::vector<double> dq_d = {};
679 
682  std::vector<double> ddq_d = {};
683 };
684 
691 {
693  NrtJointPositionCmd() = default;
694 
696  NrtJointPositionCmd(const std::vector<double>& q_d, const std::vector<double>& dq_d,
697  const std::vector<double>& dq_max, const std::vector<double>& ddq_max)
698  : q_d(q_d)
699  , dq_d(dq_d)
700  , dq_max(dq_max)
701  , ddq_max(ddq_max)
702  {
703  }
704 
706  std::vector<double> q_d = {};
707 
711  std::vector<double> dq_d = {};
712 
715  std::vector<double> dq_max = {};
716 
719  std::vector<double> ddq_max = {};
720 };
721 
728 {
730  RtCartesianCmd() = default;
731 
733  RtCartesianCmd(const std::array<double, kPoseSize>& pose_d,
734  const std::array<double, kCartDoF>& wrench_d = {},
735  const std::array<double, kCartDoF>& twist_d = {},
736  const std::array<double, kCartDoF>& acc_d = {})
737  : pose_d(pose_d)
738  , wrench_d(wrench_d)
739  , twist_d(twist_d)
740  , acc_d(acc_d)
741  {
742  }
743 
747  std::array<double, kPoseSize> pose_d = {};
748 
754  std::array<double, kCartDoF> wrench_d = {};
755 
761  std::array<double, kCartDoF> twist_d = {};
762 
768  std::array<double, kCartDoF> acc_d = {};
769 };
770 
777 {
779  NrtCartesianCmd() = default;
780 
782  NrtCartesianCmd(const std::array<double, kPoseSize>& pose_d,
783  const std::array<double, kCartDoF>& wrench_d = {},
784  const std::array<double, kCartDoF>& twist_d = {}, double max_linear_vel = 0.5,
785  double max_angular_vel = 1.0, double max_linear_acc = 2.0, double max_angular_acc = 5.0)
786  : pose_d(pose_d)
787  , wrench_d(wrench_d)
788  , twist_d(twist_d)
793  {
794  }
795 
799  std::array<double, kPoseSize> pose_d = {};
800 
806  std::array<double, kCartDoF> wrench_d = {};
807 
813  std::array<double, kCartDoF> twist_d = {};
814 
817  double max_linear_vel = 0.5;
818 
821  double max_angular_vel = 1.0;
822 
825  double max_linear_acc = 2.0;
826 
829  double max_angular_acc = 5.0;
830 };
831 
838 {
841 
843  NrtCartesianMultiWaypointCmd(const std::vector<NrtCartesianCmd>& waypoints)
845  {
846  }
847 
850  std::vector<NrtCartesianCmd> waypoints = {};
851 };
852 
860 std::ostream& operator<<(std::ostream& ostream, const RobotEvent& robot_event);
861 
868 std::ostream& operator<<(std::ostream& ostream, const RobotInfo& robot_info);
869 
876 std::ostream& operator<<(std::ostream& ostream, const RobotStates& robot_states);
877 
884 std::ostream& operator<<(std::ostream& ostream, const RobotActions& robot_actions);
885 
892 std::ostream& operator<<(std::ostream& ostream, const PlanInfo& plan_info);
893 
894 } /* namespace flexiv::rdk */
895 
896 #endif /* FLEXIV_RDK_DATA_HPP_ */
const std::map< JointGroup, std::string > kJointGroupNames
Definition: data.hpp:71
CoordType
Type of commonly-used reference coordinates.
Definition: data.hpp:121
@ WORLD
World frame (fixed).
@ TCP
TCP frame (move with the robot's end effector).
JointGroup
All possible joint groups of the robot.
Definition: data.hpp:58
@ ARM_1
The 1st single arm in a dual-arm robot or the only arm in a single-arm robot.
@ ARM_2
The 2nd single arm in a dual-arm robot, not applicable to single-arm robots.
@ ALL
The full system, including all actuated joints.
@ EXT_AXIS
External axis(es) for workspace extension.
@ ARMS
The dual arms as a whole, only applicable to dual-arm robots.
std::ostream & operator<<(std::ostream &ostream, const RobotEvent &robot_event)
Operator overloading to out stream all members of RobotEvent in JSON format.
constexpr size_t kMaxExtAxes
Definition: data.hpp:33
constexpr size_t kPoseSize
Definition: data.hpp:26
constexpr size_t kSerialJointDoF
Definition: data.hpp:23
constexpr size_t kCartDoF
Definition: data.hpp:20
SyncMotionMode
Modes for synchronous motions.
Definition: data.hpp:545
@ ARM1_TCP
Sync with arm1 tcp.
@ ARM2_TCP
sync with arm2 tcp
@ POSITIONER
sync with positioner
@ DISABLE
Don't sync with any target.
const std::map< ProductModel, std::string > kProductModelNames
Definition: data.hpp:50
OperationalStatus
All possible operational statuses of the robot. Except for the first two, the other enumerators indic...
Definition: data.hpp:86
@ IN_RECOVERY_STATE
In recovery state, see recovery().
@ ESTOP_NOT_RELEASED
E-Stop is not released.
@ READY
Ready to be operated.
@ IN_MANUAL_MODE
In Manual mode, need to switch to Auto (Remote) mode.
@ IN_AUTO_MODE
In regular Auto mode, need to switch to Auto (Remote) mode.
@ CRITICAL_FAULT
Critical fault occurred, call ClearFault() to try clearing it.
@ RELEASING_BRAKE
Brake release in progress, please wait.
@ IN_REDUCED_STATE
In reduced state, see reduced().
@ MINOR_FAULT
Minor fault occurred, call ClearFault() to try clearing it.
@ NOT_SERVO_ON
Not servo on, call ServoOn() to send the signal.
@ BOOTING
System still booting, please wait.
const std::map< OperationalStatus, std::string > kOpStatusNames
Definition: data.hpp:102
constexpr size_t kIOPorts
Definition: data.hpp:30
std::variant< int, double, std::string, rdk::JPos, rdk::Coord, std::vector< int >, std::vector< double >, std::vector< std::string >, std::vector< rdk::JPos >, std::vector< rdk::Coord > > FlexivDataTypes
Definition: data.hpp:555
ProductModel
All supported product models of the robot.
Definition: data.hpp:39
@ Enlight_LL
Enlight-L standard version.
@ MICO_Ultra
MICO-Plus: MICO-Core with pan-tilt torso.
@ MICO_Core
Enlight-LL: Dual Enlight-L with customizable mounting poses.
@ MICO_Plus
MICO-Core: Dual Enlight-L with fixed-mounting upper body.
Data structure representing the customized data type "COORD" in Flexiv Elements.
Definition: data.hpp:484
std::array< double, kCartDoF/2 > orientation
Definition: data.hpp:513
std::array< std::string, 2 > ref_frame
Definition: data.hpp:522
std::array< double, kCartDoF/2 > position
Definition: data.hpp:510
std::array< double, kSerialJointDoF > ref_q_m
Definition: data.hpp:528
Coord(const std::array< double, kCartDoF/2 > &position, const std::array< double, kCartDoF/2 > &orientation, const std::array< std::string, 2 > &ref_frame, const std::array< double, kSerialJointDoF > &ref_q_m={}, const std::array< double, kMaxExtAxes > &ref_q_e={})
Custom constructor.
Definition: data.hpp:496
std::array< double, kMaxExtAxes > ref_q_e
Definition: data.hpp:534
std::string str() const
Data structure representing the customized data type "JPOS" in Flexiv Elements.
Definition: data.hpp:448
JPos(const std::array< double, kSerialJointDoF > &q_m, const std::array< double, kMaxExtAxes > &q_e={})
Custom constructor.
Definition: data.hpp:457
std::string str() const
std::array< double, kMaxExtAxes > q_e
Definition: data.hpp:470
std::array< double, kSerialJointDoF > q_m
Definition: data.hpp:465
Commands data for non-real-time Cartesian motion-force control.
Definition: data.hpp:777
NrtCartesianCmd(const std::array< double, kPoseSize > &pose_d, const std::array< double, kCartDoF > &wrench_d={}, const std::array< double, kCartDoF > &twist_d={}, double max_linear_vel=0.5, double max_angular_vel=1.0, double max_linear_acc=2.0, double max_angular_acc=5.0)
Definition: data.hpp:782
std::array< double, kCartDoF > twist_d
Definition: data.hpp:813
std::array< double, kPoseSize > pose_d
Definition: data.hpp:799
std::array< double, kCartDoF > wrench_d
Definition: data.hpp:806
Commands data for non-real-time Cartesian multi-waypoint motion-force control.
Definition: data.hpp:838
NrtCartesianMultiWaypointCmd(const std::vector< NrtCartesianCmd > &waypoints)
Definition: data.hpp:843
std::vector< NrtCartesianCmd > waypoints
Definition: data.hpp:850
Commands data for non-real-time joint position control.
Definition: data.hpp:691
std::vector< double > q_d
Definition: data.hpp:706
std::vector< double > dq_d
Definition: data.hpp:711
std::vector< double > ddq_max
Definition: data.hpp:719
std::vector< double > dq_max
Definition: data.hpp:715
NrtJointPositionCmd(const std::vector< double > &q_d, const std::vector< double > &dq_d, const std::vector< double > &dq_max, const std::vector< double > &ddq_max)
Definition: data.hpp:696
Information of the on-going primitive/plan.
Definition: data.hpp:414
std::string node_name
Definition: data.hpp:419
std::string node_path_time_period
Definition: data.hpp:425
std::string node_path
Definition: data.hpp:422
std::string pt_name
Definition: data.hpp:416
double velocity_scale
Definition: data.hpp:434
std::string assigned_plan_name
Definition: data.hpp:431
std::string node_path_number
Definition: data.hpp:428
Arguments of a primitive command.
Definition: data.hpp:564
std::map< std::string, FlexivDataTypes > input_params
Definition: data.hpp:584
PrimitiveArgs(const std::string &pt_name, const std::map< std::string, FlexivDataTypes > &input_params)
Definition: data.hpp:569
SyncMotionMode sync_motion_mode
Definition: data.hpp:597
States data of a primitive.
Definition: data.hpp:606
std::map< std::string, FlexivDataTypes > names_and_values
Definition: data.hpp:614
Robot actions data in joint and Cartesian space for a joint group.
Definition: data.hpp:359
std::pair< int, int > timestamp
Definition: data.hpp:362
std::vector< double > tau_d
Definition: data.hpp:382
std::array< double, kCartDoF > tcp_wrench_d
Definition: data.hpp:405
std::array< double, kCartDoF > tcp_twist_d
Definition: data.hpp:397
std::vector< double > q_d
Definition: data.hpp:367
std::array< double, kPoseSize > tcp_pose_d
Definition: data.hpp:389
std::vector< double > dq_d
Definition: data.hpp:373
Information about a robot event.
Definition: data.hpp:132
std::string probable_causes
Definition: data.hpp:155
std::string consequences
Definition: data.hpp:152
@ CRITICAL
Critical error event.
Definition: data.hpp:139
@ ERROR
Error event.
Definition: data.hpp:138
@ INFO
Informational event.
Definition: data.hpp:136
@ WARNING
Warning event.
Definition: data.hpp:137
std::chrono::time_point< std::chrono::system_clock > timestamp
Definition: data.hpp:161
std::string description
Definition: data.hpp:149
std::string recommended_actions
Definition: data.hpp:158
General information about the connected robot.
Definition: data.hpp:170
std::map< JointGroup, std::vector< double > > dq_max
Definition: data.hpp:214
std::string license_type
Definition: data.hpp:181
ProductModel product_model
Definition: data.hpp:172
std::map< JointGroup, std::vector< double > > q_min
Definition: data.hpp:206
std::map< JointGroup, std::array< double, kCartDoF > > K_x_nom
Definition: data.hpp:197
std::map< JointGroup, std::vector< double > > K_q_nom
Definition: data.hpp:202
std::string serial_num
Definition: data.hpp:175
std::map< JointGroup, std::vector< double > > tau_max
Definition: data.hpp:218
std::string software_ver
Definition: data.hpp:178
std::map< JointGroup, std::string > single_arm_groups
Definition: data.hpp:187
std::map< JointGroup, std::string > all_groups
Definition: data.hpp:184
std::map< JointGroup, std::vector< double > > q_max
Definition: data.hpp:210
std::map< JointGroup, size_t > DoF
Definition: data.hpp:190
Robot states data in joint and Cartesian space for a joint group.
Definition: data.hpp:226
std::array< double, kCartDoF > raw_tcp_wrench
Definition: data.hpp:338
std::vector< double > dtheta
Definition: data.hpp:261
std::vector< double > q
Definition: data.hpp:236
std::pair< int, int > timestamp
Definition: data.hpp:229
std::array< double, kCartDoF > tcp_wrench
Definition: data.hpp:325
std::vector< double > temperature
Definition: data.hpp:295
std::vector< double > tau_dot
Definition: data.hpp:274
std::array< double, kCartDoF > raw_ft_sensor
Definition: data.hpp:351
std::vector< double > tau_ext
Definition: data.hpp:282
std::array< double, kPoseSize > tcp_pose
Definition: data.hpp:309
std::vector< double > theta
Definition: data.hpp:245
std::vector< double > dq
Definition: data.hpp:253
std::array< double, kCartDoF > tcp_wrench_local
Definition: data.hpp:333
std::vector< double > tau
Definition: data.hpp:267
std::vector< double > tau_interact
Definition: data.hpp:289
std::array< double, kPoseSize > flange_pose
Definition: data.hpp:302
std::array< double, kCartDoF > tcp_twist
Definition: data.hpp:317
std::array< double, kCartDoF > raw_tcp_wrench_local
Definition: data.hpp:343
Commands data for real-time Cartesian motion-force control.
Definition: data.hpp:728
std::array< double, kCartDoF > wrench_d
Definition: data.hpp:754
RtCartesianCmd(const std::array< double, kPoseSize > &pose_d, const std::array< double, kCartDoF > &wrench_d={}, const std::array< double, kCartDoF > &twist_d={}, const std::array< double, kCartDoF > &acc_d={})
Definition: data.hpp:733
std::array< double, kCartDoF > twist_d
Definition: data.hpp:761
std::array< double, kPoseSize > pose_d
Definition: data.hpp:747
std::array< double, kCartDoF > acc_d
Definition: data.hpp:768
Commands data for real-time joint position control.
Definition: data.hpp:660
std::vector< double > dq_d
Definition: data.hpp:678
RtJointPositionCmd(const std::vector< double > &q_d, const std::vector< double > &dq_d, const std::vector< double > &ddq_d)
Definition: data.hpp:665
std::vector< double > q_d
Definition: data.hpp:674
std::vector< double > ddq_d
Definition: data.hpp:682
Commands data for real-time joint torque control.
Definition: data.hpp:623
RtJointTorqueCmd(const std::vector< double > &tau_d, bool enable_gravity_comp=true, bool enable_soft_limits=true, double friction_comp_scale=100.0)
Definition: data.hpp:628
std::vector< double > tau_d
Definition: data.hpp:638