Skip to main content

Ruckig

Struct Ruckig 

Source
pub struct Ruckig(/* private fields */);

Implementations§

Source§

impl Ruckig

Source

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}
Source

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
Hide additional 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}
Source

pub fn new_offline(dofs: usize, waypoints: usize) -> Self

Source

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}
Source

pub fn reset(&mut self)

Source

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
Hide additional 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}
Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.