#include <cmath>
#include <iostream>
const bool on_ramp = t < ramp_pos / std::abs(ramp_vel);
target.
position[0] = on_ramp ? t * ramp_vel : ramp_pos;
target.
velocity[0] = on_ramp ? ramp_vel : 0.0;
return target;
}
return target;
}
target.
position[0] = std::sin(ramp_vel * t);
target.
velocity[0] = ramp_vel * std::cos(ramp_vel * t);
target.
acceleration[0] = -ramp_vel * ramp_vel * std::sin(ramp_vel * t);
return target;
}
otg.reactiveness = 1.0;
std::cout << "target | follow" << std::endl;
for (size_t t = 0; t < 500; t += 1) {
auto target_state =
model_ramp(otg.delta_time * t);
auto res = otg.update(target_state, input, output);
std::cout << target_state.position[0] <<
" " << output.
new_position[0] << std::endl;
}
}
int main()
Definition: 10_dynamic_dofs_waypoints.cpp:10
TargetState< 1 > model_constant_acceleration(double t, double ramp_acc=0.05)
Definition: 14_tracking.cpp:21
TargetState< 1 > model_sinus(double t, double ramp_vel=0.4)
Definition: 14_tracking.cpp:29
TargetState< 1 > model_ramp(double t, double ramp_vel=0.5, double ramp_pos=1.0)
Definition: 14_tracking.cpp:12
Output type of Ruckig.
Definition: output_parameter.hpp:15
Vector< double > new_position
Definition: output_parameter.hpp:31
void pass_to_input(InputParameter< DOFs, CustomVector > &input) const
Definition: output_parameter.hpp:69
The kinematic target state for Trackig.
Definition: trackig.hpp:19
Vector< double > acceleration
Definition: trackig.hpp:28
Vector< double > position
Definition: trackig.hpp:26
Vector< double > velocity
Definition: trackig.hpp:27
The main interface for the Trackig algorithm.
Definition: trackig.hpp:61
from math import sin, cos
from pathlib import Path
from sys import path
build_path = Path(__file__).parent.absolute().parent / 'build'
path.insert(0, str(build_path))
from ruckig import Trackig, TargetState, InputParameter, OutputParameter
target = TargetState(1)
on_ramp = t < ramp_pos / abs(ramp_vel)
target.position = [t * ramp_vel] if on_ramp else [ramp_pos]
target.velocity = [ramp_vel] if on_ramp else [0.0]
target.acceleration = [0.0]
return target
target = TargetState(1)
target.position = [t * t * ramp_acc]
target.velocity = [t * ramp_acc]
target.acceleration = [ramp_acc]
return target
target = TargetState(1)
target.position = [sin(ramp_vel * t)]
target.velocity = [ramp_vel * cos(ramp_vel * t)]
target.acceleration = [-ramp_vel * ramp_vel * sin(ramp_vel * t)]
return target
if __name__ == '__main__':
inp = InputParameter(1)
out = OutputParameter(inp.degrees_of_freedom)
otg = Trackig(inp.degrees_of_freedom, 0.01)
inp.current_position = [0.0]
inp.current_velocity = [0.0]
inp.current_acceleration = [0.0]
inp.max_velocity = [0.8]
inp.max_acceleration = [2.0]
inp.max_jerk = [5.0]
inp.min_position = [-2.5]
inp.max_position = [2.5]
print('\t'.join(['t'] + [str(i) for i in range(otg.degrees_of_freedom)]))
steps, target_list, follow_list = [], [], []
for t in range(500):
steps.append(t)
res = otg.update(target_state, inp, out)
out.pass_to_input(inp)
print('\t'.join([f'{p:0.3f}' for p in target_state.position] + [f'{p:0.3f}' for p in out.new_position]) + f' in {out.calculation_duration:0.2f} [µs]')
target_list.append([target_state.position, target_state.velocity, target_state.acceleration])
follow_list.append([out.new_position, out.new_velocity, out.new_acceleration])