14template <
typename ControlSignalType>
23template <
typename ControlSignalType>
51 std::vector<std::shared_ptr<Reaction<ControlSignalType>>>
reactions();
79 const RobotState &robot_state, franka::Duration time_step, franka::Duration rel_time, franka::Duration abs_time,
80 const std::optional<ControlSignalType> &previous_command);
90 const RobotState &robot_state, franka::Duration rel_time, franka::Duration abs_time);
95 virtual void initImpl(
const RobotState &robot_state,
const std::optional<ControlSignalType> &previous_command) {}
98 const RobotState &robot_state, franka::Duration time_step, franka::Duration rel_time, franka::Duration abs_time,
99 const std::optional<ControlSignalType> &previous_command) = 0;
104 std::mutex reaction_mutex_;
105 std::list<std::shared_ptr<Reaction<ControlSignalType>>> reactions_;
106 std::mutex callback_mutex_;
107 std::vector<CallbackType> callbacks_;
Base class for motions.
Definition motion.hpp:24
void registerCallback(CallbackType callback)
Register a callback that is called in every step of the motion.
Definition motion.cpp:24
std::shared_ptr< Motion< ControlSignalType > > checkAndCallReactions(const RobotState &robot_state, franka::Duration rel_time, franka::Duration abs_time)
Check and call reactions.
Definition motion.cpp:67
void init(Robot *robot, const RobotState &robot_state, const std::optional< ControlSignalType > &previous_command)
Initialize the motion.
Definition motion.cpp:50
Robot * robot() const
Definition motion.hpp:101
void addReaction(std::shared_ptr< Reaction< ControlSignalType > > reaction)
Add a reaction to the motion.
Definition motion.cpp:30
void addReactionFront(std::shared_ptr< Reaction< ControlSignalType > > reaction)
Add a reaction to the front of the reaction list.
Definition motion.cpp:37
virtual ~Motion()=default
std::function< void(const RobotState &, franka::Duration, franka::Duration, franka::Duration, const ControlSignalType &)> CallbackType
Definition motion.hpp:28
Motion()
Definition motion.cpp:18
ControlSignalType nextCommand(const RobotState &robot_state, franka::Duration time_step, franka::Duration rel_time, franka::Duration abs_time, const std::optional< ControlSignalType > &previous_command)
Get the next command of the motion.
Definition motion.cpp:57
virtual void initImpl(const RobotState &robot_state, const std::optional< ControlSignalType > &previous_command)
Definition motion.hpp:95
virtual ControlSignalType nextCommandImpl(const RobotState &robot_state, franka::Duration time_step, franka::Duration rel_time, franka::Duration abs_time, const std::optional< ControlSignalType > &previous_command)=0
std::vector< std::shared_ptr< Reaction< ControlSignalType > > > reactions()
Currently registered reactions of the motion.
Definition motion.cpp:44
A reaction that can be attached to a motion.
Definition reaction.hpp:27
A class representing a Franka robot.
Definition robot.hpp:48
Definition dynamics_limit.cpp:8
ControlSignalType
Type of control signal.
Definition control_signal_type.hpp:8
Full state of the robot.
Definition robot_state.hpp:23