3 #include <franka/duration.h>
4 #include <franka/robot_state.h>
15 using namespace movex;
17 template<
class RobotType>
19 size_t trajectory_index {0};
20 double s_current {0.0};
21 const bool use_elbow {
false};
33 auto initial_state = robot->readOnce();
34 franka::CartesianPose initial_cartesian_pose(initial_state.O_T_EE_c, initial_state.elbow_c);
35 Affine initial_pose(initial_cartesian_pose.O_T_EE);
37 Waypoint start_waypoint {initial_pose * frame, initial_cartesian_pose.
elbow[0]};
39 all_waypoints.insert(all_waypoints.begin(), start_waypoint);
42 const Path path {all_waypoints};
46 const auto [max_velocity, max_acceleration, max_jerk] = getInputLimits(robot, data);
47 trajectory = time_parametrization.parametrize(path, max_velocity, max_acceleration, max_jerk);
50 franka::CartesianPose
operator()(
const franka::RobotState& robot_state, franka::Duration period) {
51 time += period.toSec();
54 if (robot->stop_at_python_signal && Py_IsInitialized() && PyErr_CheckSignals() == -1) {
59 const int steps = std::max<int>(period.toMSec(), 1);
60 trajectory_index += steps;
61 if (trajectory_index >= trajectory.states.size()) {
62 s_current = trajectory.path.get_length();
63 return franka::MotionFinished(CartesianPose(trajectory.path.q(s_current, frame), use_elbow));
66 s_current = trajectory.states[trajectory_index].s;
67 return CartesianPose(trajectory.path.q(s_current, frame), use_elbow);