Franky  0.9.1
A High-Level Motion API for Franka
Public Member Functions | List of all members
franky::Reaction< ControlSignalType > Class Template Reference

A reaction that can be attached to a motion. More...

#include <reaction.hpp>

Public Member Functions

 Reaction (const Condition &condition, std::shared_ptr< Motion< ControlSignalType >> new_motion=nullptr)
 
 Reaction (Condition condition, const MotionFunc &motion_func)
 
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. More...
 
bool condition (const franka::RobotState &robot_state, double rel_time, double abs_time) const
 Check if the condition is met. More...
 
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. More...
 

Detailed Description

template<typename ControlSignalType>
class franky::Reaction< ControlSignalType >

A reaction that can be attached to a motion.

This class defines a reaction in a motion, which can be used to change the motion based on the robot state. Reactions consist of a condition and a motion that replaces the current motion immediately if the condition is met.

Constructor & Destructor Documentation

◆ Reaction() [1/2]

template<typename ControlSignalType >
franky::Reaction< ControlSignalType >::Reaction ( const Condition condition,
std::shared_ptr< Motion< ControlSignalType >>  new_motion = nullptr 
)
explicit
Parameters
conditionThe condition that must be met for the reaction to be executed.
new_motionThe motion that is executed if the condition is met.

◆ Reaction() [2/2]

template<typename ControlSignalType >
franky::Reaction< ControlSignalType >::Reaction ( Condition  condition,
const MotionFunc &  motion_func 
)
explicit
Parameters
conditionThe condition that must be met for the reaction to be executed.
motion_funcA function that returns a motion that is executed if the condition is met.

Member Function Documentation

◆ condition()

template<typename ControlSignalType >
bool franky::Reaction< ControlSignalType >::condition ( const franka::RobotState &  robot_state,
double  rel_time,
double  abs_time 
) const
inline

Check if the condition is met.

Parameters
robot_stateThe current robot state.
rel_timeThe time since the start of the current motion.
abs_timeThe time since the start of the current chain of motions. This value measures the time since the robot started moving, and is only reset if a motion expires without being replaced by a new motion.
Returns
True if the condition is met, false otherwise.

◆ operator()()

template<typename ControlSignalType >
std::shared_ptr< Motion< ControlSignalType > > franky::Reaction< ControlSignalType >::operator() ( const franka::RobotState &  robot_state,
double  rel_time,
double  abs_time 
)

Get the new motion if the condition is met.

Parameters
robot_stateThe current robot state.
rel_timeThe time since the start of the current motion.
abs_timeThe time since the start of the current chain of motions. This value measures the time since the robot started moving, and is only reset if a motion expires without being replaced by a new motion.
Returns
The new motion if the condition is met, or nullptr otherwise.

◆ registerCallback()

template<typename ControlSignalType >
void franky::Reaction< ControlSignalType >::registerCallback ( std::function< void(const franka::RobotState &, double, double)>  callback)

Register a callback that is called when the condition of this reaction is met.

Parameters
callbackThe callback to register. Callbacks are called with the robot state, the relative time [s] and the absolute time [s].

The documentation for this class was generated from the following files: