03_waypoints/
03_waypoints.rs1use ruckig::{InputParameter, OutputParameter, Result, Ruckig};
2
3fn main() {
4 let control_cycle = 0.01;
5 let dofs = 3;
6 let max_number_of_waypoints = 10; let mut ruckig = Ruckig::new(dofs, control_cycle, max_number_of_waypoints);
10 let mut input = InputParameter::new(dofs);
11 let mut output = OutputParameter::new(dofs, max_number_of_waypoints);
12
13 input.current_position = vec![0.2, 0.0, -0.3];
15 input.current_velocity = vec![0.0, 0.2, 0.0];
16 input.current_acceleration = vec![0.0, 0.6, 0.0];
17
18 input.intermediate_positions = vec![
19 vec![1.4, -1.6, 1.0],
20 vec![-0.6, -0.5, 0.4],
21 vec![-0.4, -0.35, 0.0],
22 vec![0.8, 1.8, -0.1]
23 ];
24
25 input.target_position = vec![0.5, 1.0, 0.0];
26 input.target_velocity = vec![0.2, 0.0, 0.3];
27 input.target_acceleration = vec![0.0, 0.1, -0.1];
28
29 input.max_velocity = vec![1.0, 2.0, 1.0];
30 input.max_acceleration = vec![3.0, 2.0, 2.0];
31 input.max_jerk = vec![6.0, 10.0, 20.0];
32
33 println!("t | position");
35 while ruckig.update(&mut input, &mut output) == Result::Working {
36 let pos: Vec<String> = output.new_position.iter().map(|x| format!("{x:.4}")).collect();
37 println!("{:.4} | [{}]", output.time, pos.join(", "));
38
39 output.pass_to_input(&mut input);
40 }
41
42 println!("Trajectory duration: {} [s].", output.trajectory().get_duration());
43}
44