Skip to main content

OutputParameter

Struct OutputParameter 

Source
pub struct OutputParameter {
    pub degrees_of_freedom: usize,
    pub new_position: Vec<f64>,
    pub new_velocity: Vec<f64>,
    pub new_acceleration: Vec<f64>,
    pub time: f64,
    pub new_section: usize,
    pub new_calculation: bool,
    pub calculation_duration: f64,
    /* private fields */
}

Fields§

§degrees_of_freedom: usize§new_position: Vec<f64>§new_velocity: Vec<f64>§new_acceleration: Vec<f64>§time: f64§new_section: usize§new_calculation: bool§calculation_duration: f64

Implementations§

Source§

impl OutputParameter

Source

pub fn new_direct(dofs: usize) -> Self

Examples found in repository?
examples/01_position.rs (line 7)
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 7)
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(dofs: usize, waypoints: usize) -> Self

Examples found in repository?
examples/03_waypoints.rs (line 11)
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 pass_to_input(&self, input: &mut InputParameter)

Examples found in repository?
examples/01_position.rs (line 28)
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 28)
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 39)
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 trajectory(&self) -> TrajectoryRef<'_>

Examples found in repository?
examples/01_position.rs (line 31)
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 31)
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 42)
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}

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.