Frankx  0.2.0
A High-Level Motion API for Franka
robot.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #ifdef WITH_PYTHON
4  #include <Python.h>
5 #endif
6 
7 #include <franka/control_types.h>
8 #include <franka/duration.h>
9 #include <franka/exception.h>
10 #include <franka/model.h>
11 #include <franka/robot.h>
12 #include <franka/robot_state.h>
13 
14 #include <affx/affine.hpp>
18 
19 #include <frankx/kinematics.hpp>
25 
26 
27 namespace frankx {
28  using namespace movex;
29  using Affine = affx::Affine;
30 
31 class Robot: public franka::Robot {
32  // Modified DH-parameters: alpha, d, a
33  const KinematicChain<7> kinematics = KinematicChain<7>(
34  {{{0.0, 0.333, 0.0}, {-M_PI/2, 0.0, 0.0}, {M_PI/2, 0.316, 0.0}, {M_PI/2, 0.0, 0.0825}, {-M_PI/2, 0.384, -0.0825}, {M_PI/2, 0.0, 0.0}, {M_PI/2, 0.0, 0.088}}},
35  Affine(0, 0, 0.107, M_PI/4, 0, M_PI)
36  );
37 
38 public:
40  std::string fci_ip;
41 
42  // Cartesian constraints
43  static constexpr double max_translation_velocity {1.7}; // [m/s]
44  static constexpr double max_rotation_velocity {2.5}; // [rad/s]
45  static constexpr double max_elbow_velocity {2.175}; // [rad/s]
46  static constexpr double max_translation_acceleration {13.0}; // [m/s²]
47  static constexpr double max_rotation_acceleration {25.0}; // [rad/s²]
48  static constexpr double max_elbow_acceleration {10.0}; // [rad/s²]
49  static constexpr double max_translation_jerk {6500.0}; // [m/s³]
50  static constexpr double max_rotation_jerk {12500.0}; // [rad/s³]
51  static constexpr double max_elbow_jerk {5000.0}; // [rad/s³]
52 
53  // Joint constraints
54  static constexpr std::array<double, 7> max_joint_velocity {{2.175, 2.175, 2.175, 2.175, 2.610, 2.610, 2.610}}; // [rad/s]
55  static constexpr std::array<double, 7> max_joint_acceleration {{15.0, 7.5, 10.0, 12.5, 15.0, 20.0, 20.0}}; // [rad/s²]
56  static constexpr std::array<double, 7> max_joint_jerk {{7500.0, 3750.0, 5000.0, 6250.0, 7500.0, 10000.0, 10000.0}}; // [rad/s^3]
57 
58  static constexpr size_t degrees_of_freedoms {7};
59  static constexpr double control_rate {0.001}; // [s]
60 
61  double velocity_rel {1.0}, acceleration_rel {1.0}, jerk_rel {1.0};
62 
63  franka::ControllerMode controller_mode {franka::ControllerMode::kJointImpedance}; // kCartesianImpedance wobbles -> setK?
64 
66  bool repeat_on_error {true};
67 
69  bool stop_at_python_signal {true};
70 
72  explicit Robot(std::string fci_ip, double dynamic_rel = 1.0, bool repeat_on_error = true, bool stop_at_python_signal = true);
73 
74  void setDefaultBehavior();
75  void setDynamicRel(double dynamic_rel);
76 
77  bool hasErrors();
78  bool recoverFromErrors();
79 
80  Affine currentPose(const Affine& frame = Affine());
81  std::array<double, 7> currentJointPositions();
82  Affine forwardKinematics(const std::array<double, 7>& q);
83  std::array<double, 7> inverseKinematics(const Affine& target, const std::array<double, 7>& q0);
84 
85  ::franka::RobotState get_state();
86 
87  bool move(ImpedanceMotion& motion);
88  bool move(ImpedanceMotion& motion, MotionData& data);
89  bool move(const Affine& frame, ImpedanceMotion& motion);
90  bool move(const Affine& frame, ImpedanceMotion& motion, MotionData& data);
91 
92  bool move(JointMotion motion);
93  bool move(JointMotion motion, MotionData& data);
94 
95  bool move(PathMotion motion);
96  bool move(PathMotion motion, MotionData& data);
97  bool move(const Affine& frame, PathMotion motion);
98  bool move(const Affine& frame, PathMotion motion, MotionData& data);
99 
100  bool move(WaypointMotion& motion);
101  bool move(WaypointMotion& motion, MotionData& data);
102  bool move(const Affine& frame, WaypointMotion& motion);
103  bool move(const Affine& frame, WaypointMotion& motion, MotionData& data);
104 };
105 
106 } // namespace frankx
frankx
Definition: __init__.py:1
movex::JointMotion
Definition: motion_joint.hpp:11
frankx::Robot::fci_ip
std::string fci_ip
The robot's hostname / IP address.
Definition: robot.hpp:40
frankx.robot.Robot
Definition: robot.py:13
kinematics.hpp
robot_state.hpp
motion_impedance_generator.hpp
movex::PathMotion
Definition: motion_path.hpp:15
motion_waypoint_generator.hpp
motion_path_generator.hpp
movex::ImpedanceMotion
Definition: motion_impedance.hpp:15
movex::KinematicChain< 7 >
motion_data.hpp
kinematics.hpp
movex::MotionData
Definition: motion_data.hpp:8
movex::WaypointMotion
Definition: motion_waypoint.hpp:16
frankx::Affine
affx::Affine Affine
Definition: motion_generator.hpp:15
movex
Definition: motion_impedance.hpp:13
motion_generator.hpp
motion_joint_generator.hpp