#include <iostream>
Result result = otg.calculate(input, trajectory);
if (result == Result::ErrorInvalidInput) {
std::cout << "Invalid input!" << std::endl;
return -1;
}
std::cout << "Trajectory duration: " << trajectory.get_duration() << " [s]." << std::endl;
double new_time = 1.0;
std::array<double, 3> new_position, new_velocity, new_acceleration;
trajectory.at_time(new_time, new_position, new_velocity, new_acceleration);
std::cout <<
"Position at time " << new_time <<
" [s]: " <<
join(new_position) << std::endl;
std::array<Bound, 3> position_extrema = trajectory.get_position_extrema();
std::cout << "Position extremas for DoF 4 are " << position_extrema[2].min << " (min) to " << position_extrema[2].max << " (max)" << std::endl;
}
int main()
Definition 01_position.cpp:8
Main interface for the Ruckig algorithm.
Definition ruckig.hpp:25
The trajectory generated by the Ruckig algorithm.
Definition trajectory.hpp:21
std::string join(const Vector &array, bool high_precision=false)
Join a vector for easy printing (e.g. to std::cout)
Definition utils.hpp:40
from ruckig import InputParameter, Ruckig, Trajectory, Result
if __name__ == '__main__':
inp = InputParameter(3)
inp.current_position = [0.0, 0.0, 0.5]
inp.current_velocity = [0.0, -2.2, -0.5]
inp.current_acceleration = [0.0, 2.5, -0.5]
inp.target_position = [5.0, -2.0, -3.5]
inp.target_velocity = [0.0, -0.5, -2.0]
inp.target_acceleration = [0.0, 0.0, 0.5]
inp.max_velocity = [3.0, 1.0, 3.0]
inp.max_acceleration = [3.0, 2.0, 1.0]
inp.max_jerk = [4.0, 3.0, 2.0]
inp.min_velocity = [-1.0, -0.5, -3.0]
inp.min_acceleration = [-2.0, -1.0, -2.0]
otg = Ruckig(3)
trajectory = Trajectory(3)
result = otg.calculate(inp, trajectory)
if result == Result.ErrorInvalidInput:
raise Exception('Invalid input!')
print(f'Trajectory duration: {trajectory.duration:0.4f} [s]')
new_time = 1.0
new_position, new_velocity, new_acceleration = trajectory.at_time(new_time)
print(f'Position at time {new_time:0.4f} [s]: {new_position}')
print(f'Position extremas are {trajectory.position_extrema}')