6 #include <franka/duration.h>
7 #include <franka/robot_state.h>
8 #include "ruckig/ruckig.hpp"
18 using std::runtime_error::runtime_error;
23 template<
typename ControlSignalType>
29 template<
typename ControlSignalType>
59 update_callbacks_.push_back(callback);
79 std::shared_ptr<Motion<ControlSignalType>> initial_motion_;
80 std::shared_ptr<Motion<ControlSignalType>> current_motion_;
81 std::shared_ptr<Motion<ControlSignalType>> new_motion_;
82 std::vector<std::function<void(
const franka::RobotState &, franka::Duration,
double)>> update_callbacks_;
83 std::mutex new_motion_mutex_;
84 std::optional<ControlSignalType> previous_command_;
86 double abs_time_{0.0};
87 double rel_time_offset_{0.0};
Helper class for handling motions and reactions.
Definition: motion_generator.hpp:30
void registerUpdateCallback(const std::function< void(const franka::RobotState &, franka::Duration, double)> &callback)
Register a callback that is called in every step of the motion.
Definition: motion_generator.hpp:58
void updateMotion(std::shared_ptr< Motion< ControlSignalType >> new_motion)
Update the current motion.
Definition: motion_generator.cpp:68
static constexpr size_t REACTION_RECURSION_LIMIT
Maximum recursion limit for reactions. After more than this number of reactions are fired in a single...
Definition: motion_generator.hpp:36
MotionGenerator(Robot *robot, std::shared_ptr< Motion< ControlSignalType >> initial_motion)
Definition: motion_generator.cpp:18
ControlSignalType operator()(const franka::RobotState &robot_state, franka::Duration period)
Update the motion generator and get the next control signal.
Definition: motion_generator.cpp:24
void resetTimeUnsafe()
Reset the time of the motion generator without locking the mutex.
Definition: motion_generator.cpp:79
bool has_new_motion()
Whether a new motion is available.
Definition: motion_generator.cpp:74
Base class for motions.
Definition: motion.hpp:22
A class representing a Franka robot.
Definition: robot.hpp:45
Definition: gripper.cpp:3
ControlSignalType
Type of control signal.
Definition: control_signal_type.hpp:8
Exception thrown when the reaction recursion limit (8) is reached.
Definition: motion_generator.hpp:17