Franky 0.12.0
A High-Level Motion API for Franka
Loading...
Searching...
No Matches
velocity_waypoint_motion.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <ruckig/ruckig.hpp>
4
5#include "franky/util.hpp"
9
10namespace franky {
11
17template<typename TargetType>
19
27template<typename ControlSignalType, typename TargetType>
28class VelocityWaypointMotion : public WaypointMotion<ControlSignalType, VelocityWaypoint<TargetType>, TargetType> {
29 public:
38 const RelativeDynamicsFactor &relative_dynamics_factor = 1.0
39 )
41 relative_dynamics_factor_(relative_dynamics_factor) {}
42
43 protected:
45 const VelocityWaypoint<TargetType> &waypoint, ruckig::InputParameter<7> &input_parameter) const override {
47
48 auto relative_dynamics_factor =
49 waypoint.relative_dynamics_factor * relative_dynamics_factor_ * this->robot()->relative_dynamics_factor();
50
51 input_parameter.max_velocity = toStdD<7>(relative_dynamics_factor.acceleration() * acc_lim);
52 input_parameter.max_acceleration = toStdD<7>(relative_dynamics_factor.jerk() * jerk_lim);
53 input_parameter.max_jerk = toStdD<7>(Vector7d::Constant(std::numeric_limits<double>::infinity()));
54
55 if (relative_dynamics_factor.max_dynamics()) {
56 input_parameter.synchronization = ruckig::Synchronization::TimeIfNecessary;
57 } else {
58 input_parameter.synchronization = ruckig::Synchronization::Time;
59 if (waypoint.minimum_time.has_value())
60 input_parameter.minimum_duration = waypoint.minimum_time.value().toSec();
61 }
62 }
63
65 const franka::Duration &time_step, const ruckig::InputParameter<7> &input_parameter,
66 ruckig::OutputParameter<7> &output_parameter) const override {
68
69 auto acc = toEigenD<7>(input_parameter.current_velocity);
70 auto vel = toEigenD<7>(input_parameter.current_position);
71
72 auto new_vel = (vel + acc * time_step.toSec()).cwiseMin(vel_lim).cwiseMax(-vel_lim);
73
74 // Franka assumes a constant acceleration model if no new input is received.
75 // See https://frankaemika.github.io/docs/libfranka.html#under-the-hood
76 output_parameter.new_acceleration = toStdD<7>(Vector7d::Zero());
77 output_parameter.new_velocity = input_parameter.current_velocity;
78 output_parameter.new_position = toStdD<7>(new_vel);
79 }
80
81 [[nodiscard]] std::tuple<Vector7d, Vector7d, Vector7d> getAbsoluteInputLimits() const override = 0;
82
83 private:
84 RelativeDynamicsFactor relative_dynamics_factor_;
85};
86
87} // namespace franky
Robot * robot() const
Definition motion.hpp:114
Relative dynamics factors.
Definition relative_dynamics_factor.hpp:13
RelativeDynamicsFactor relative_dynamics_factor()
Returns the current global relative dynamics factor of the robot.
Definition robot.cpp:136
A motion following multiple positional waypoints in a time-optimal way. Works with arbitrary initial ...
Definition velocity_waypoint_motion.hpp:28
void setInputLimits(const VelocityWaypoint< TargetType > &waypoint, ruckig::InputParameter< 7 > &input_parameter) const override
Definition velocity_waypoint_motion.hpp:44
void extrapolateMotion(const franka::Duration &time_step, const ruckig::InputParameter< 7 > &input_parameter, ruckig::OutputParameter< 7 > &output_parameter) const override
Definition velocity_waypoint_motion.hpp:64
VelocityWaypointMotion(std::vector< VelocityWaypoint< TargetType > > waypoints, const RelativeDynamicsFactor &relative_dynamics_factor=1.0)
Definition velocity_waypoint_motion.hpp:36
std::tuple< Vector7d, Vector7d, Vector7d > getAbsoluteInputLimits() const override=0
A motion following multiple waypoints in a time-optimal way. Works with arbitrary initial conditions.
Definition waypoint_motion.hpp:60
Definition dynamics_limit.cpp:8
std::array< double, dims > toStdD(const Eigen::Matrix< double, dims, 1 > &vector)
Definition util.hpp:18
ControlSignalType
Type of control signal.
Definition control_signal_type.hpp:8
A waypoint with a target and optional parameters.
Definition waypoint_motion.hpp:38