8 #include <franka/robot_state.h>
15 template<
typename ControlSignalType>
24 template<
typename ControlSignalType>
26 using MotionFunc = std::function<std::shared_ptr<Motion<ControlSignalType>>(
const franka::RobotState &, double, double)>;
49 std::shared_ptr<Motion<ControlSignalType>>
operator()(
const franka::RobotState &robot_state,
double rel_time,
double abs_time);
59 [[nodiscard]]
inline bool condition(
const franka::RobotState &robot_state,
double rel_time,
double abs_time)
const {
60 return condition_(robot_state, rel_time, abs_time);
68 void registerCallback(std::function<
void(
const franka::RobotState &,
double,
double)> callback);
71 MotionFunc motion_func_;
73 std::mutex callback_mutex_;
74 std::vector<std::function<void(
const franka::RobotState &,
double,
double)>> callbacks_{};
A condition on the robot state.
Definition: condition.hpp:18
Base class for motions.
Definition: motion.hpp:22
A reaction that can be attached to a motion.
Definition: reaction.hpp:25
std::shared_ptr< Motion< ControlSignalType > > operator()(const franka::RobotState &robot_state, double rel_time, double abs_time)
Get the new motion if the condition is met.
Definition: reaction.cpp:28
Reaction(const Condition &condition, std::shared_ptr< Motion< ControlSignalType >> new_motion=nullptr)
Definition: reaction.cpp:19
bool condition(const franka::RobotState &robot_state, double rel_time, double abs_time) const
Check if the condition is met.
Definition: reaction.hpp:59
void registerCallback(std::function< void(const franka::RobotState &, double, double)> callback)
Register a callback that is called when the condition of this reaction is met.
Definition: reaction.cpp:37
Definition: gripper.cpp:3