Flexiv RDK APIs  2.1
robot.hpp
Go to the documentation of this file.
1 
6 #ifndef FLEXIV_RDK_ROBOT_HPP_
7 #define FLEXIV_RDK_ROBOT_HPP_
8 
9 #include "data.hpp"
10 #include "mode.hpp"
11 #include <vector>
12 #include <memory>
13 #include <exception>
14 #include <map>
15 
16 namespace flexiv::rdk {
17 
23 class Robot
24 {
25 public:
48  Robot(const std::string& robot_sn, bool verbose = true, bool lite = false);
49  virtual ~Robot();
50 
51  //========================================= ACCESSORS ==========================================
56  bool lite() const;
57 
62  bool connected() const;
63 
68  RobotInfo info() const;
69 
74  Mode mode() const;
75 
81  std::map<JointGroup, RobotStates> states() const;
82 
88  std::map<JointGroup, RobotActions> actions() const;
89 
96  std::map<JointGroup, bool> stopped() const;
97 
102  bool all_stopped() const;
103 
111  bool operational() const;
112 
118 
126  bool busy() const;
127 
132  bool fault() const;
133 
144  bool reduced() const;
145 
157  bool recovery() const;
158 
163  bool estop_released() const;
164 
170  bool enabling_device_on() const;
171 
179 
187  std::vector<RobotEvent> event_log() const;
188 
189  //======================================= SYSTEM CONTROL =======================================
197  void ServoOn();
198 
210  void Home(const std::vector<JointGroup>& groups = {});
211 
222  void Brake(bool engage);
223 
238 
244  void Stop();
245 
258  bool ClearFault(unsigned int timeout_sec = 30);
259 
271  void SetGlobalVariables(const std::map<std::string, FlexivDataTypes>& global_vars);
272 
281  std::map<std::string, FlexivDataTypes> global_variables() const;
282 
292  void SetTimelinessFailureLimit(double percentage = 2.0);
293 
294  //======================================= PLAN EXECUTION =======================================
314  unsigned int index, bool continue_exec = false, bool block_until_started = true);
315 
334  const std::string& name, bool continue_exec = false, bool block_until_started = true);
335 
345  void PausePlan(bool toggle);
346 
354  void StopPlan();
355 
362  std::vector<std::string> plan_list() const;
363 
374 
385  void SetBreakpointMode(bool is_enabled);
386 
398 
411  void SetVelocityScale(unsigned int velocity_scale);
412 
413  //==================================== PRIMITIVE EXECUTION =====================================
439  const std::map<JointGroup, PrimitiveArgs>& primitive_args, bool block_until_started = true);
440 
448  std::map<JointGroup, PrimitiveStates> primitive_states() const;
449 
450  //==================================== DIRECT JOINT CONTROL ====================================
466  void StreamJointTorque(const std::map<JointGroup, RtJointTorqueCmd>& cmds);
467 
484  void StreamJointPosition(const std::map<JointGroup, RtJointPositionCmd>& cmds);
485 
504  void SendJointPosition(const std::map<JointGroup, NrtJointPositionCmd>& cmds);
505 
527  JointGroup group, const std::vector<double>& K_q, const std::vector<double>& Z_q = {});
528 
545  void SetMaxContactTorque(JointGroup group, const std::vector<double>& max_torques);
546 
566  void SetJointInertiaScale(JointGroup group, const std::vector<double>& inertia_scales);
567 
568  //================================== DIRECT CARTESIAN CONTROL ==================================
600  void StreamCartesianMotionForce(const std::map<JointGroup, RtCartesianCmd>& cmds);
601 
632  void SendCartesianMotionForce(const std::map<JointGroup, NrtCartesianCmd>& cmds);
633 
652  const std::map<JointGroup, NrtCartesianMultiWaypointCmd>& cmds);
653 
678  void SetCartesianImpedance(JointGroup group, const std::array<double, kCartDoF>& K_x,
679  const std::array<double, kCartDoF>& Z_x = {0.7, 0.7, 0.7, 0.7, 0.7, 0.7});
680 
702  void SetMaxContactWrench(JointGroup group, const std::array<double, kCartDoF>& max_wrench);
703 
730  void SetNullSpacePosture(JointGroup group, const std::vector<double>& ref_positions);
731 
757  void SetNullSpaceObjectives(JointGroup group, double linear_manipulability = 0.0,
758  double angular_manipulability = 0.0, double ref_positions_tracking = 0.5);
759 
783  void SetForceControlAxis(JointGroup group, const std::array<bool, kCartDoF>& enabled_axes,
784  const std::array<double, kCartDoF / 2>& max_linear_vel = {1.0, 1.0, 1.0});
785 
821  void SetForceControlFrame(JointGroup group, CoordType root_coord,
822  const std::array<double, kPoseSize>& T_in_root = {0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0});
823 
849  void SetPassiveForceControl(JointGroup group, bool is_enabled);
850 
851  //======================================== IO CONTROL ========================================
862  void SetDigitalOutputs(const std::map<unsigned int, bool>& digital_outputs);
863 
870  std::array<bool, kIOPorts> digital_inputs() const;
871 
878  std::array<bool, kIOPorts> digital_outputs() const;
879 
880 private:
881  class Impl;
882  std::unique_ptr<Impl> pimpl_;
883 
884  friend class Device;
885  friend class FileIO;
886  friend class Gripper;
887  friend class Maintenance;
888  friend class Model;
889  friend class Safety;
890  friend class Tool;
891  friend class WorkCoord;
892 };
893 
894 } /* namespace flexiv::rdk */
895 
896 #endif /* FLEXIV_RDK_ROBOT_HPP_ */
Interface to control the peripheral device(s) connected to the robot.
Definition: device.hpp:22
Interface to exchange files with the robot. Only certain types of file can be transferred.
Definition: file_io.hpp:18
Interface to control the gripper installed on the robot. Because gripper is also a type of robot devi...
Definition: gripper.hpp:77
Interface to run maintenance operations on the robot.
Definition: maintenance.hpp:18
Interface to obtain certain model data of the robot, including kinematics and dynamics.
Definition: model.hpp:49
Main interface to control the robot, containing several function categories and background services.
Definition: robot.hpp:24
void ExecutePlan(unsigned int index, bool continue_exec=false, bool block_until_started=true)
[Blocking] Execute a plan by specifying its index.
RobotInfo info() const
[Non-blocking] General information about the robot.
bool enabling_device_on() const
[Non-blocking] Whether the 3-position enabling device (e.g. enabling button on the motion bar) is in ...
void Home(const std::vector< JointGroup > &groups={})
[Blocking] Move the specified joint groups to the home posture using Home primitive.
void SetPassiveForceControl(JointGroup group, bool is_enabled)
[Blocking] Enable or disable passive force control for the Cartesian motion-force control modes....
void StreamJointPosition(const std::map< JointGroup, RtJointPositionCmd > &cmds)
[Non-blocking] Continuously stream joint position, velocity, and acceleration commands of the specifi...
bool recovery() const
[Non-blocking] Whether the robot is in recovery state.
void Brake(bool engage)
[Blocking] Force robot brakes to engage or release during normal operation. Restrictions apply,...
OperationalStatus operational_status() const
[Non-blocking] Current operational status of the robot.
void StepBreakpoint()
[Blocking] If breakpoint mode is enabled, step to the next breakpoint. The plan execution will contin...
void StreamCartesianMotionForce(const std::map< JointGroup, RtCartesianCmd > &cmds)
[Non-blocking] Continuously stream Cartesian motion and/or force commands of the specified joint grou...
void SetGlobalVariables(const std::map< std::string, FlexivDataTypes > &global_vars)
[Blocking] Set values to global variables that already exist in the robot.
Mode mode() const
[Non-blocking] Current control mode of the robot.
void SetForceControlAxis(JointGroup group, const std::array< bool, kCartDoF > &enabled_axes, const std::array< double, kCartDoF/2 > &max_linear_vel={1.0, 1.0, 1.0})
[Blocking] Set Cartesian axes to enable force control while in the Cartesian motion-force control mod...
void SetNullSpacePosture(JointGroup group, const std::vector< double > &ref_positions)
[Blocking] Set reference joint positions for the null-space posture control module used in the Cartes...
void SetDigitalOutputs(const std::map< unsigned int, bool > &digital_outputs)
[Blocking] Set one or more digital output ports, including 16 on the control box plus 2 inside each w...
void SetVelocityScale(unsigned int velocity_scale)
[Blocking] Set overall velocity scale of robot motions during plan and primitive execution.
void SetJointImpedance(JointGroup group, const std::vector< double > &K_q, const std::vector< double > &Z_q={})
[Blocking] Set impedance properties of the robot's joint motion controller used in the joint impedanc...
std::vector< RobotEvent > event_log() const
[Non-blocking] Robot events stored since the last successful instantiation of this class.
void Stop()
[Blocking] Stop the robot and transit its control mode to IDLE.
void SetForceControlFrame(JointGroup group, CoordType root_coord, const std::array< double, kPoseSize > &T_in_root={0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0})
[Blocking] Set reference frame for force control while in the Cartesian motion-force control modes....
std::map< JointGroup, bool > stopped() const
[Non-blocking] Whether specific joint groups of the robot have come to a complete stop.
void ExecutePrimitive(const std::map< JointGroup, PrimitiveArgs > &primitive_args, bool block_until_started=true)
[Blocking] Execute primitive(s) on specified joint group(s).
void SwitchMode(Mode mode)
[Blocking] Switch the robot to a new control mode and wait for the mode transition to finish.
std::map< std::string, FlexivDataTypes > global_variables() const
[Blocking] Existing global variables and their current values.
void PausePlan(bool toggle)
[Blocking] Pause or resume the execution of the current plan.
void SetCartesianImpedance(JointGroup group, const std::array< double, kCartDoF > &K_x, const std::array< double, kCartDoF > &Z_x={0.7, 0.7, 0.7, 0.7, 0.7, 0.7})
[Blocking] Set impedance properties of the robot's Cartesian motion controller used in the Cartesian ...
std::map< JointGroup, PrimitiveStates > primitive_states() const
[Blocking] States data of the primitive(s) that are currently running.
bool reached_timeliness_failure_limit() const
[Non-blocking] Whether the timeliness failure limit has been reached within a 1-second moving window.
std::map< JointGroup, RobotStates > states() const
[Non-blocking] Current states data of all existing joint groups of the robot.
bool reduced() const
[Non-blocking] Whether the robot is in reduced state.
void StopPlan()
[Blocking] Stop the execution of the current plan.
bool connected() const
[Non-blocking] Whether the connection with the robot is established.
std::map< JointGroup, RobotActions > actions() const
[Non-blocking] Current actions data of all existing joint groups of the robot.
void SetMaxContactTorque(JointGroup group, const std::vector< double > &max_torques)
[Blocking] Set maximum contact torques for the robot's joint motion controller used in the joint impe...
void SetMaxContactWrench(JointGroup group, const std::array< double, kCartDoF > &max_wrench)
[Blocking] Set maximum contact wrench for the motion control part of the Cartesian motion-force contr...
void SetTimelinessFailureLimit(double percentage=2.0)
[Non-blocking] Set the maximum tolerable percentage of real-time commands that arrived the robot too ...
std::vector< std::string > plan_list() const
[Blocking] A list of all available plans.
Robot(const std::string &robot_sn, bool verbose=true, bool lite=false)
[Blocking] Instantiate the robot control interface. RDK services will be started and establish connec...
bool operational() const
[Non-blocking] Whether the robot is ready to be operated, which requires the following conditions to ...
void SetBreakpointMode(bool is_enabled)
[Blocking] Enable or disable the breakpoint mode during plan execution. When enabled,...
void SendCartesianMotionForce(const std::map< JointGroup, NrtCartesianCmd > &cmds)
[Non-blocking] Discretely send Cartesian motion and/or force commands of the specified joint group(s)...
void ExecutePlan(const std::string &name, bool continue_exec=false, bool block_until_started=true)
[Blocking] Execute a plan by specifying its name.
void SetJointInertiaScale(JointGroup group, const std::vector< double > &inertia_scales)
[Blocking] Set inertia shaping scales for the robot's joint motion controller used in the joint imped...
std::array< bool, kIOPorts > digital_outputs() const
[Non-blocking] Current reading from all digital output ports, including 16 on the control box plus 2 ...
void StreamJointTorque(const std::map< JointGroup, RtJointTorqueCmd > &cmds)
[Non-blocking] Continuously stream joint torque commands of the specified joint group(s) to the robot...
void SendJointPosition(const std::map< JointGroup, NrtJointPositionCmd > &cmds)
[Non-blocking] Discretely send joint position and velocity commands of the specified joint group(s) t...
bool all_stopped() const
[Non-blocking] Whether all joint groups of the robot have come to a complete stop.
void ServoOn()
[Blocking] Servo on the robot. If E-stop is released and there's no fault, the robot will release bra...
PlanInfo plan_info() const
[Blocking] Detailed information about the executing plan. Contains plan name, primitive name,...
void SendCartesianMotionForceMultiWaypoint(const std::map< JointGroup, NrtCartesianMultiWaypointCmd > &cmds)
[Non-blocking] Discretely send Cartesian multi-waypoint motion and/or force commands for the robot to...
bool lite() const
[Non-blocking] Whether this rdk::Robot instance is a lite one.
bool fault() const
[Non-blocking] Whether the robot is in fault state.
bool ClearFault(unsigned int timeout_sec=30)
[Blocking] Try to clear minor or critical fault for the robot without a power cycle.
bool estop_released() const
[Non-blocking] Whether all connected emergency stops (E-stops) are released.
void SetNullSpaceObjectives(JointGroup group, double linear_manipulability=0.0, double angular_manipulability=0.0, double ref_positions_tracking=0.5)
[Blocking] Set weights of the three optimization objectives while computing the robot's null-space po...
bool busy() const
[Non-blocking] Whether the robot is busy. This includes any user commanded operations that requires t...
std::array< bool, kIOPorts > digital_inputs() const
[Non-blocking] Current reading from all digital input ports, including 16 on the control box plus 2 i...
Interface to manage safety settings of the robot. A password is required to authenticate this interfa...
Definition: safety.hpp:48
Interface to manage tools of the robot. All updates take effect immediately without a power cycle....
Definition: tool.hpp:41
Interface to manage work coordinates of the robot. All updates take effect immediately without a powe...
Definition: work_coord.hpp:19
Header file containing various constant expressions, data structures, and enums.
CoordType
Type of commonly-used reference coordinates.
Definition: data.hpp:121
JointGroup
All possible joint groups of the robot.
Definition: data.hpp:58
OperationalStatus
All possible operational statuses of the robot. Except for the first two, the other enumerators indic...
Definition: data.hpp:86
Mode
Robot control modes. The robot needs to be switched into the correct control mode before the correspo...
Definition: mode.hpp:22
Information of the on-going primitive/plan.
Definition: data.hpp:414
General information about the connected robot.
Definition: data.hpp:170