Flexiv RDK APIs  1.5
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 {
17 namespace rdk {
18 
24 class Robot
25 {
26 public:
40  Robot(const std::string& robot_sn);
41  virtual ~Robot();
42 
43  //========================================= ACCESSORS ==========================================
48  bool connected() const;
49 
54  const RobotInfo info() const;
55 
60  Mode mode() const;
61 
67  const RobotStates states() const;
68 
73  bool stopped() const;
74 
84  bool operational(bool verbose = true) const;
85 
91 
99  bool busy() const;
100 
105  bool fault() const;
106 
117  bool reduced() const;
118 
130  bool recovery() const;
131 
136  bool estop_released() const;
137 
143 
152  const std::vector<std::string> mu_log() const;
153 
154  //======================================= SYSTEM CONTROL =======================================
162  void Enable();
163 
174  void Brake(bool engage);
175 
189 
195  void Stop();
196 
209  bool ClearFault(unsigned int timeout_sec = 30);
210 
220 
232  void SetGlobalVariables(const std::map<std::string, FlexivDataTypes>& global_vars);
233 
234  [[deprecated("[Remove in v1.6] Use the other SetGlobalVariables() instead")]] void
235  SetGlobalVariables(const std::string& global_vars);
236 
245  std::map<std::string, FlexivDataTypes> global_variables() const;
246 
247  [[deprecated("[Remove in v1.6] Use the other global_variables() instead")]] const std::vector<
248  std::string>
249  global_variables(bool dummy);
250 
251  //======================================= PLAN EXECUTION =======================================
270  unsigned int index, bool continue_exec = false, bool block_until_started = true);
271 
289  const std::string& name, bool continue_exec = false, bool block_until_started = true);
290 
300  void PausePlan(bool pause);
301 
308  const std::vector<std::string> plan_list() const;
309 
319  const PlanInfo plan_info() const;
320 
331  void SetBreakpointMode(bool is_enabled);
332 
344 
357  void SetVelocityScale(unsigned int velocity_scale);
358 
359  //==================================== PRIMITIVE EXECUTION =====================================
383  void ExecutePrimitive(const std::string& primitive_name,
384  const std::map<std::string, FlexivDataTypes>& input_params,
385  bool block_until_started = true);
386 
387  [[deprecated("[Remove in v1.6] Use the other ExecutePrimitive() instead")]] void
388  ExecutePrimitive(const std::string& pt_cmd, bool block_until_started = true);
389 
398  std::map<std::string, FlexivDataTypes> primitive_states() const;
399 
400  [[deprecated("[Remove in v1.6] Use the other primitive_states() instead")]] const std::vector<
401  std::string>
402  primitive_states(bool dummy);
403 
404  //==================================== DIRECT JOINT CONTROL ====================================
420  void StreamJointTorque(const std::vector<double>& torques, bool enable_gravity_comp = true,
421  bool enable_soft_limits = true);
422 
441  void StreamJointPosition(const std::vector<double>& positions,
442  const std::vector<double>& velocities, const std::vector<double>& accelerations);
443 
469  void SendJointPosition(const std::vector<double>& positions,
470  const std::vector<double>& velocities, const std::vector<double>& accelerations,
471  const std::vector<double>& max_vel, const std::vector<double>& max_acc);
472 
489  void SetJointImpedance(const std::vector<double>& K_q,
490  const std::vector<double>& Z_q = {0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7});
491 
492  //================================== DIRECT CARTESIAN CONTROL ==================================
538  void StreamCartesianMotionForce(const std::array<double, kPoseSize>& pose,
539  const std::array<double, kCartDoF>& wrench = {},
540  const std::array<double, kCartDoF>& velocity = {},
541  const std::array<double, kCartDoF>& acceleration = {});
542 
583  void SendCartesianMotionForce(const std::array<double, kPoseSize>& pose,
584  const std::array<double, kCartDoF>& wrench = {}, double max_linear_vel = 0.5,
585  double max_angular_vel = 1.0, double max_linear_acc = 2.0, double max_angular_acc = 5.0);
586 
606  void SetCartesianImpedance(const std::array<double, kCartDoF>& K_x,
607  const std::array<double, kCartDoF>& Z_x = {0.7, 0.7, 0.7, 0.7, 0.7, 0.7});
608 
625  void SetMaxContactWrench(const std::array<double, kCartDoF>& max_wrench);
626 
648  void SetNullSpacePosture(const std::vector<double>& ref_positions);
649 
671  void SetNullSpaceObjectives(double linear_manipulability = 0.0,
672  double angular_manipulability = 0.0, double ref_positions_tracking = 0.5);
673 
693  void SetForceControlAxis(const std::array<bool, kCartDoF>& enabled_axes,
694  const std::array<double, kCartDoF / 2>& max_linear_vel = {1.0, 1.0, 1.0});
695 
727  const std::array<double, kPoseSize>& T_in_root = {0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0});
728 
750  void SetPassiveForceControl(bool is_enabled);
751 
752  //======================================== IO CONTROL ========================================
765  const std::vector<unsigned int>& port_idx, const std::vector<bool>& values);
766 
767  [[deprecated("[Remove in v1.6] Use SetDigitalOutputs() instead")]] void WriteDigitalOutput(
768  const std::vector<unsigned int>& port_idx, const std::vector<bool>& values);
769 
775  const std::array<bool, kIOPorts> digital_inputs();
776 
777  [[deprecated("[Remove in v1.6] Use digital_inputs() instead")]] const std::array<bool, kIOPorts>
778  ReadDigitalInput();
779 
780 private:
781  class Impl;
782  std::unique_ptr<Impl> pimpl_;
783 
784  friend class Device;
785  friend class FileIO;
786  friend class Gripper;
787  friend class Model;
788  friend class Tool;
789  friend class WorkCoord;
790 };
791 
792 } /* namespace rdk */
793 } /* namespace flexiv */
794 
795 #endif /* FLEXIV_RDK_ROBOT_HPP_ */
Interface with the robot device(s).
Definition: device.hpp:20
Interface for file transfer with the robot. The robot must be put into IDLE mode when transferring fi...
Definition: file_io.hpp:20
Interface with the robot gripper.
Definition: gripper.hpp:20
Interface to access certain robot kinematics and dynamics data.
Definition: model.hpp:21
Main interface with the robot, containing several function categories and background services.
Definition: robot.hpp:25
void ExecutePlan(unsigned int index, bool continue_exec=false, bool block_until_started=true)
[Blocking] Execute a plan by specifying its index.
void SetNullSpaceObjectives(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...
void SetMaxContactWrench(const std::array< double, kCartDoF > &max_wrench)
[Blocking] Set maximum contact wrench for the motion control part of the Cartesian motion-force contr...
void SetDigitalOutputs(const std::vector< unsigned int > &port_idx, const std::vector< bool > &values)
[Blocking] Set one or more digital output port(s) on the control box.
const RobotStates states() const
[Non-blocking] Current states data of the robot.
const std::vector< std::string > plan_list() const
[Blocking] Get a list of all available plans.
void SetJointImpedance(const std::vector< double > &K_q, const std::vector< double > &Z_q={0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7})
[Blocking] Set impedance properties of the robot's joint motion controller used in the joint impedanc...
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...
bool stopped() const
[Non-blocking] Whether the robot has come to a complete stop.
const RobotInfo info() const
[Non-blocking] General information about the connected robot.
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 ExecutePrimitive(const std::string &primitive_name, const std::map< std::string, FlexivDataTypes > &input_params, bool block_until_started=true)
[Blocking] Execute a primitive by specifying its name and parameters, which can be found in the Flexi...
bool operational(bool verbose=true) const
[Non-blocking] Whether the robot is ready to be operated, which requires the following conditions to ...
void StreamJointTorque(const std::vector< double > &torques, bool enable_gravity_comp=true, bool enable_soft_limits=true)
[Non-blocking] Continuously stream joint torque command to the robot.
void StreamCartesianMotionForce(const std::array< double, kPoseSize > &pose, const std::array< double, kCartDoF > &wrench={}, const std::array< double, kCartDoF > &velocity={}, const std::array< double, kCartDoF > &acceleration={})
[Non-blocking] Continuously stream Cartesian motion and/or force command for the robot to track using...
void SetVelocityScale(unsigned int velocity_scale)
[Blocking] Set overall velocity scale for robot motions during plan and primitive execution.
void SendJointPosition(const std::vector< double > &positions, const std::vector< double > &velocities, const std::vector< double > &accelerations, const std::vector< double > &max_vel, const std::vector< double > &max_acc)
[Non-blocking] Discretely send joint position, velocity, and acceleration command to the robot....
const std::vector< std::string > primitive_states(bool dummy)
Unused parameter [dummy] is needed for function overloading.
void SetForceControlFrame(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....
void Stop()
[Blocking] Stop the robot and transit robot mode to IDLE.
void PausePlan(bool pause)
[Blocking] Pause or resume the execution of the current plan.
const std::vector< std::string > global_variables(bool dummy)
Unused parameter [dummy] is needed for function overloading.
const std::vector< std::string > mu_log() const
[Non-blocking] Get multilingual log messages of the connected robot.
void SwitchMode(Mode mode)
[Blocking] Switch to a new control mode and wait until mode transition is finished.
std::map< std::string, FlexivDataTypes > global_variables() const
[Blocking] Existing global variables and their current values.
const std::array< bool, kIOPorts > digital_inputs()
[Non-blocking] Current reading of all digital input ports on the control box.
void SetCartesianImpedance(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 ...
bool reduced() const
[Non-blocking] Whether the robot is in reduced state.
Robot(const std::string &robot_sn)
[Blocking] Create an instance as the main robot control interface. RDK services will initialize and c...
bool connected() const
[Non-blocking] Whether the connection with the robot is established.
bool enabling_button_pressed() const
[Non-blocking] Whether the enabling button is pressed.
void SetForceControlAxis(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...
std::map< std::string, FlexivDataTypes > primitive_states() const
[Blocking] State parameters of the executing primitive and their current values.
void SetBreakpointMode(bool is_enabled)
[Blocking] Enable or disable the breakpoint mode during plan execution. When enabled,...
void ExecutePlan(const std::string &name, bool continue_exec=false, bool block_until_started=true)
[Blocking] Execute a plan by specifying its name.
void SendCartesianMotionForce(const std::array< double, kPoseSize > &pose, const std::array< double, kCartDoF > &wrench={}, double max_linear_vel=0.5, double max_angular_vel=1.0, double max_linear_acc=2.0, double max_angular_acc=5.0)
[Non-blocking] Discretely send Cartesian motion and/or force command for the robot to track using its...
const PlanInfo plan_info() const
[Blocking] Get detailed information about the currently executing plan. Contains information like pla...
void StreamJointPosition(const std::vector< double > &positions, const std::vector< double > &velocities, const std::vector< double > &accelerations)
[Non-blocking] Continuously stream joint position, velocity, and acceleration command to the robot....
void Enable()
[Blocking] Enable the robot, if E-stop is released and there's no fault, the robot will release brake...
bool fault() const
[Non-blocking] Whether the robot is in fault state.
void SetPassiveForceControl(bool is_enabled)
[Blocking] Enable or disable passive force control for the Cartesian motion-force control modes....
bool ClearFault(unsigned int timeout_sec=30)
[Blocking] Try to clear minor or critical fault of the robot without a power cycle.
bool estop_released() const
[Non-blocking] Whether the emergency stop is released.
bool busy() const
[Non-blocking] Whether the robot is currently executing a task. This includes any user commanded oper...
void RunAutoRecovery()
[Blocking] Run automatic recovery to bring joints that are outside the allowed position range back in...
void SetNullSpacePosture(const std::vector< double > &ref_positions)
[Blocking] Set reference joint positions for the null-space posture control module used in the Cartes...
Interface to online update and interact with the robot tools. All updates will take effect immediatel...
Definition: tool.hpp:20
Interface to online update and interact with the robot's work coordinates. All updates will take effe...
Definition: work_coord.hpp:21
Header file containing various constant expressions, data structs, and enums.
CoordType
Type of commonly-used reference coordinates.
Definition: data.hpp:58
OperationalStatus
Operational status of the robot. Except for the first two, the other enumerators indicate the cause o...
Definition: data.hpp:39
Mode
Robot control modes. The robot needs to be switched into the correct control mode before the correspo...
Definition: mode.hpp:22
Data structure containing information of the on-going primitive/plan.
Definition: data.hpp:273
General information about the connected robot.
Definition: data.hpp:69
Data structure containing the joint- and Cartesian-space robot states.
Definition: data.hpp:130