pub struct Ruckig(/* private fields */);Implementations§
Source§impl Ruckig
impl Ruckig
Sourcepub fn new_direct_and_offline(dofs: usize) -> Self
pub fn new_direct_and_offline(dofs: usize) -> Self
Examples found in repository?
examples/02_position_offline.rs (line 19)
3fn main() {
4 // Create input parameters
5 let mut input = InputParameter::new(3);
6 input.current_position = vec![0.0, 0.0, 0.5];
7 input.current_velocity = vec![0.0, -2.2, -0.5];
8 input.current_acceleration = vec![0.0, 2.5, -0.5];
9
10 input.target_position = vec![5.0, -2.0, -3.5];
11 input.target_velocity = vec![0.0, -0.5, -2.0];
12 input.target_acceleration = vec![0.0, 0.0, 0.5];
13
14 input.max_velocity = vec![3.0, 1.0, 3.0];
15 input.max_acceleration = vec![3.0, 2.0, 1.0];
16 input.max_jerk = vec![4.0, 3.0, 2.0];
17
18 // We don't need to pass the control rate (cycle time) when using only offline features
19 let mut ruckig = Ruckig::new_direct_and_offline(3);
20 let mut trajectory = Trajectory::new_direct(3);
21
22 // Calculate the trajectory in an offline manner (outside of the control loop)
23 let result = ruckig.calculate(&mut input, &mut trajectory);
24 if result == Result::ErrorInvalidInput {
25 println!("Invalid input!");
26 return;
27 }
28
29 // Get duration of the trajectory
30 println!("Trajectory duration: {} [s].", trajectory.get_duration());
31}Sourcepub fn new_direct(dofs: usize, delta_time: f64) -> Self
pub fn new_direct(dofs: usize, delta_time: f64) -> Self
Examples found in repository?
examples/01_position.rs (line 5)
3fn main() {
4 // Create instances: Ruckig as well as input and output parameters
5 let mut ruckig = Ruckig::new_direct(3, 0.01); // DoFs, control cycle
6 let mut input = InputParameter::new(3);
7 let mut output = OutputParameter::new_direct(3);
8
9 // Set input parameters
10 input.current_position = vec![0.0, 0.0, 0.5];
11 input.current_velocity = vec![0.0, -2.2, -0.5];
12 input.current_acceleration = vec![0.0, 2.5, -0.5];
13
14 input.target_position = vec![5.0, -2.0, -3.5];
15 input.target_velocity = vec![0.0, -0.5, -2.0];
16 input.target_acceleration = vec![0.0, 0.0, 0.5];
17
18 input.max_velocity = vec![3.0, 1.0, 3.0];
19 input.max_acceleration = vec![3.0, 2.0, 1.0];
20 input.max_jerk = vec![4.0, 3.0, 2.0];
21
22 // Generate the trajectory within the control loop
23 println!("t | position");
24 while ruckig.update(&mut input, &mut output) == Result::Working {
25 let pos: Vec<String> = output.new_position.iter().map(|x| format!("{x:.4}")).collect();
26 println!("{:.4} | [{}]", output.time, pos.join(", "));
27
28 output.pass_to_input(&mut input);
29 }
30
31 println!("Trajectory duration: {} [s].", output.trajectory().get_duration());
32}More examples
examples/05_velocity.rs (line 5)
3fn main() {
4 // Create instances: Ruckig as well as input and output parameters
5 let mut ruckig = Ruckig::new_direct(3, 0.01); // DoFs, control cycle
6 let mut input = InputParameter::new(3);
7 let mut output = OutputParameter::new_direct(3);
8
9 // Set input parameters and velocity control interface
10 input.control_interface = ruckig::ControlInterface::Velocity;
11
12 input.current_position = vec![0.0, 0.0, 0.5];
13 input.current_velocity = vec![3.0, -2.2, -0.5];
14 input.current_acceleration = vec![0.0, 2.5, -0.5];
15
16 input.target_velocity = vec![0.0, -0.5, -1.5];
17 input.target_acceleration = vec![0.0, 0.0, 0.5];
18
19 input.max_acceleration = vec![3.0, 2.0, 1.0];
20 input.max_jerk = vec![6.0, 6.0, 4.0];
21
22 // Generate the trajectory within the control loop
23 println!("t | position");
24 while ruckig.update(&mut input, &mut output) == Result::Working {
25 let pos: Vec<String> = output.new_position.iter().map(|x| format!("{x:.4}")).collect();
26 println!("{:.4} | [{}]", output.time, pos.join(", "));
27
28 output.pass_to_input(&mut input);
29 }
30
31 println!("Trajectory duration: {} [s].", output.trajectory().get_duration());
32}pub fn new_offline(dofs: usize, waypoints: usize) -> Self
Sourcepub fn new(dofs: usize, delta_time: f64, waypoints: usize) -> Self
pub fn new(dofs: usize, delta_time: f64, waypoints: usize) -> Self
Examples found in repository?
examples/03_waypoints.rs (line 9)
3fn main() {
4 let control_cycle = 0.01;
5 let dofs = 3;
6 let max_number_of_waypoints = 10; // for memory allocation
7
8 // Create instances: Ruckig as well as input and output parameters
9 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 // Set input parameters
14 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 // Generate the trajectory within the control loop
34 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}pub fn reset(&mut self)
Sourcepub fn update(
&mut self,
input: &mut InputParameter,
output: &mut OutputParameter,
) -> Result
pub fn update( &mut self, input: &mut InputParameter, output: &mut OutputParameter, ) -> Result
Examples found in repository?
examples/01_position.rs (line 24)
3fn main() {
4 // Create instances: Ruckig as well as input and output parameters
5 let mut ruckig = Ruckig::new_direct(3, 0.01); // DoFs, control cycle
6 let mut input = InputParameter::new(3);
7 let mut output = OutputParameter::new_direct(3);
8
9 // Set input parameters
10 input.current_position = vec![0.0, 0.0, 0.5];
11 input.current_velocity = vec![0.0, -2.2, -0.5];
12 input.current_acceleration = vec![0.0, 2.5, -0.5];
13
14 input.target_position = vec![5.0, -2.0, -3.5];
15 input.target_velocity = vec![0.0, -0.5, -2.0];
16 input.target_acceleration = vec![0.0, 0.0, 0.5];
17
18 input.max_velocity = vec![3.0, 1.0, 3.0];
19 input.max_acceleration = vec![3.0, 2.0, 1.0];
20 input.max_jerk = vec![4.0, 3.0, 2.0];
21
22 // Generate the trajectory within the control loop
23 println!("t | position");
24 while ruckig.update(&mut input, &mut output) == Result::Working {
25 let pos: Vec<String> = output.new_position.iter().map(|x| format!("{x:.4}")).collect();
26 println!("{:.4} | [{}]", output.time, pos.join(", "));
27
28 output.pass_to_input(&mut input);
29 }
30
31 println!("Trajectory duration: {} [s].", output.trajectory().get_duration());
32}More examples
examples/05_velocity.rs (line 24)
3fn main() {
4 // Create instances: Ruckig as well as input and output parameters
5 let mut ruckig = Ruckig::new_direct(3, 0.01); // DoFs, control cycle
6 let mut input = InputParameter::new(3);
7 let mut output = OutputParameter::new_direct(3);
8
9 // Set input parameters and velocity control interface
10 input.control_interface = ruckig::ControlInterface::Velocity;
11
12 input.current_position = vec![0.0, 0.0, 0.5];
13 input.current_velocity = vec![3.0, -2.2, -0.5];
14 input.current_acceleration = vec![0.0, 2.5, -0.5];
15
16 input.target_velocity = vec![0.0, -0.5, -1.5];
17 input.target_acceleration = vec![0.0, 0.0, 0.5];
18
19 input.max_acceleration = vec![3.0, 2.0, 1.0];
20 input.max_jerk = vec![6.0, 6.0, 4.0];
21
22 // Generate the trajectory within the control loop
23 println!("t | position");
24 while ruckig.update(&mut input, &mut output) == Result::Working {
25 let pos: Vec<String> = output.new_position.iter().map(|x| format!("{x:.4}")).collect();
26 println!("{:.4} | [{}]", output.time, pos.join(", "));
27
28 output.pass_to_input(&mut input);
29 }
30
31 println!("Trajectory duration: {} [s].", output.trajectory().get_duration());
32}examples/03_waypoints.rs (line 35)
3fn main() {
4 let control_cycle = 0.01;
5 let dofs = 3;
6 let max_number_of_waypoints = 10; // for memory allocation
7
8 // Create instances: Ruckig as well as input and output parameters
9 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 // Set input parameters
14 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 // Generate the trajectory within the control loop
34 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}Sourcepub fn calculate(
&mut self,
input: &mut InputParameter,
trajectory: &mut Trajectory,
) -> Result
pub fn calculate( &mut self, input: &mut InputParameter, trajectory: &mut Trajectory, ) -> Result
Examples found in repository?
examples/02_position_offline.rs (line 23)
3fn main() {
4 // Create input parameters
5 let mut input = InputParameter::new(3);
6 input.current_position = vec![0.0, 0.0, 0.5];
7 input.current_velocity = vec![0.0, -2.2, -0.5];
8 input.current_acceleration = vec![0.0, 2.5, -0.5];
9
10 input.target_position = vec![5.0, -2.0, -3.5];
11 input.target_velocity = vec![0.0, -0.5, -2.0];
12 input.target_acceleration = vec![0.0, 0.0, 0.5];
13
14 input.max_velocity = vec![3.0, 1.0, 3.0];
15 input.max_acceleration = vec![3.0, 2.0, 1.0];
16 input.max_jerk = vec![4.0, 3.0, 2.0];
17
18 // We don't need to pass the control rate (cycle time) when using only offline features
19 let mut ruckig = Ruckig::new_direct_and_offline(3);
20 let mut trajectory = Trajectory::new_direct(3);
21
22 // Calculate the trajectory in an offline manner (outside of the control loop)
23 let result = ruckig.calculate(&mut input, &mut trajectory);
24 if result == Result::ErrorInvalidInput {
25 println!("Invalid input!");
26 return;
27 }
28
29 // Get duration of the trajectory
30 println!("Trajectory duration: {} [s].", trajectory.get_duration());
31}Auto Trait Implementations§
impl Freeze for Ruckig
impl RefUnwindSafe for Ruckig
impl !Send for Ruckig
impl !Sync for Ruckig
impl Unpin for Ruckig
impl UnsafeUnpin for Ruckig
impl UnwindSafe for Ruckig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more