4 #include <franka/duration.h>
5 #include <franka/robot_state.h>
7 #include <ruckig/input_parameter.hpp>
14 using namespace movex;
21 auto affine =
Affine(vector);
23 return franka::CartesianPose(affine.array(), {vector[6], -1});
25 return franka::CartesianPose(affine.array());
28 static inline franka::CartesianPose
CartesianPose(
const std::array<double, 7>& vector,
bool include_elbow =
true) {
29 auto affine =
Affine(vector);
31 return franka::CartesianPose(affine.array(), {vector[6], -1});
33 return franka::CartesianPose(affine.array());
36 template <
class T =
double>
38 return {cart, cart, cart, rot, rot, rot, elbow};
42 const std::array<double, 7> data = VectorCartRotElbow(cart, rot, elbow);
43 vector = Eigen::Map<const Vector7d>(data.data(), data.size());
47 std::array<double, 7> result;
48 Vector7d::Map(result.data()) = vector;
55 movex.q_d = franka.q_d;
58 movex.O_T_EE = franka.O_T_EE;
59 movex.O_T_EE_c = franka.O_T_EE_c;
60 movex.O_dP_EE_c = franka.O_dP_EE_c;
62 movex.elbow = franka.elbow;
63 movex.elbow_c = franka.elbow_c;
64 movex.elbow_d = franka.elbow_d;
66 movex.O_F_ext_hat_K = franka.O_F_ext_hat_K;
70 template<
class RobotType>
71 static std::tuple<std::array<double, 7>, std::array<double, 7>, std::array<double, 7>>
getInputLimits(RobotType* robot,
const MotionData& data) {
72 return getInputLimits(robot,
Waypoint(), data);
75 template<
class RobotType>
76 static std::tuple<std::array<double, 7>, std::array<double, 7>, std::array<double, 7>>
getInputLimits(RobotType* robot,
const Waypoint& waypoint,
const MotionData& data) {
77 constexpr
double translation_factor {0.4};
78 constexpr
double derivative_factor {0.4};
82 0.8 * translation_factor * robot->max_translation_velocity,
83 0.8 * robot->max_rotation_velocity,
84 0.8 * robot->max_elbow_velocity
87 0.8 * translation_factor * derivative_factor * robot->max_translation_acceleration,
88 0.8 * derivative_factor * robot->max_rotation_acceleration,
89 0.8 * derivative_factor * robot->max_elbow_acceleration
92 0.8 * translation_factor * std::pow(derivative_factor, 2) * robot->max_translation_jerk,
93 0.8 * std::pow(derivative_factor, 2) * robot->max_rotation_jerk,
94 0.8 * std::pow(derivative_factor, 2) * robot->max_elbow_jerk
96 return {max_velocity, max_acceleration, max_jerk};
100 translation_factor * waypoint.
velocity_rel * data.
velocity_rel * robot->velocity_rel * robot->max_translation_velocity,
105 translation_factor * derivative_factor * data.
acceleration_rel * robot->acceleration_rel * robot->max_translation_acceleration,
106 derivative_factor * data.
acceleration_rel * robot->acceleration_rel * robot->max_rotation_acceleration,
107 derivative_factor * data.
acceleration_rel * robot->acceleration_rel * robot->max_elbow_acceleration
110 translation_factor * std::pow(derivative_factor, 2) * data.
jerk_rel * robot->jerk_rel * robot->max_translation_jerk,
111 std::pow(derivative_factor, 2) * data.
jerk_rel * robot->jerk_rel * robot->max_rotation_jerk,
112 std::pow(derivative_factor, 2) * data.
jerk_rel * robot->jerk_rel * robot->max_elbow_jerk
114 return {max_velocity, max_acceleration, max_jerk};
117 template<
class RobotType>
119 setInputLimits(input_parameters, robot,
Waypoint(), data);
122 template<
class RobotType>
124 std::tie(input_parameters.max_velocity, input_parameters.max_acceleration, input_parameters.max_jerk) = getInputLimits(robot, waypoint, data);
127 input_parameters.minimum_duration = waypoint.
minimum_time.value();
131 input_parameters.synchronization = ruckig::Synchronization::TimeIfNecessary;
133 input_parameters.synchronization = ruckig::Synchronization::Time;
140 template <
typename OriginalFunctor,
typename RType>
142 OriginalFunctor &fun;
150 template <
typename... Args>
151 RType operator() (Args&&... args) {
152 return fun(std::forward<Args>(args)...);
157 template <
typename RT,
typename OF>