Franky 0.12.0
A High-Level Motion API for Franka
Loading...
Searching...
No Matches
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 RobotState &robot_state, franka::Duration rel_time, franka::Duration abs_time)
 Get the new motion if the condition is met.
 
bool condition (const RobotState &robot_state, franka::Duration rel_time, franka::Duration abs_time) const
 Check if the condition is met.
 
void registerCallback (const std::function< void(const RobotState &, franka::Duration, franka::Duration)> &callback)
 Register a callback that is called when the condition of this reaction is met.
 

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]

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]

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()

bool franky::Reaction< ControlSignalType >::condition ( const RobotState robot_state,
franka::Duration  rel_time,
franka::Duration  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()()

std::shared_ptr< Motion< ControlSignalType > > franky::Reaction< ControlSignalType >::operator() ( const RobotState robot_state,
franka::Duration  rel_time,
franka::Duration  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()

void franky::Reaction< ControlSignalType >::registerCallback ( const std::function< void(const RobotState &, franka::Duration, franka::Duration)> &  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: