Skip to main content

Topp3ProblemBuilder

Struct Topp3ProblemBuilder 

Source
pub struct Topp3ProblemBuilder<'a> {
    pub constraints: &'a mut Constraints,
    pub idx_s_start: usize,
    pub a_linearization: &'a [f64],
    pub a_boundary: (f64, f64),
    pub b_boundary: (f64, f64),
    pub num_stationary_max: (usize, usize),
    pub a_linearization_floor: f64,
}
Expand description

Builder for Topp3Problem, including optional in-build linearization.

§Side effect notice

build_with_linearization updates cached affine linearization data inside Constraints. Raw jerk constraints remain unchanged.

§Why mutable?

Third-order jerk rows are stored in nonconvex form after Robot::with_axial_jerk or Constraints::with_constraint_3order. build_with_linearization evaluates an affine approximation around a_linearization and writes the generated coefficients into the constraint cache. Rebuild the problem whenever the linearization profile changes.

§Example

The example below builds a TOPP3 problem and lets the builder linearize the third-order constraints.

use copp::robot::Robot;
use copp::solver::topp3_lp::Topp3ProblemBuilder;

let mut robot = Robot::with_capacity(2usize, 3);
let s = [0.0, 0.5, 1.0];
robot.with_s(s.as_slice())?;

let a_linearization = [0.0, 0.25, 0.0];
let _problem = Topp3ProblemBuilder::new(
    &mut robot,
    0,
    &a_linearization,
    (0.0, 0.0),
    (0.0, 0.0),
)
.build_with_linearization()?;

Fields§

§constraints: &'a mut Constraints

Mutable constraint storage used to build linearized TOPP3 problem data.

§idx_s_start: usize

Start station index of the optimization interval.

§a_linearization: &'a [f64]

Reference profile a[k] used to linearize third-order constraints.

§a_boundary: (f64, f64)

Boundary values of a=(a_start, a_final).

§b_boundary: (f64, f64)

Boundary values of b=(b_start, b_final).

§num_stationary_max: (usize, usize)

User-input upper bound of stationary intervals at (start, end).

§a_linearization_floor: f64

Denominator floor for stable evaluation of 1/sqrt(a_linearization) near a=0.

Effective usage in linearization is: $$ \frac{1}{\sqrt{\max(a_{lin}, a_{floor})}}. $$ Discrete code form: 1.0 / max(a_linearization, a_linearization_floor).sqrt().

More details are available in the Topp3Problem documentation.

Implementations§

Source§

impl<'a> Topp3ProblemBuilder<'a>

Source

pub fn new<M: RobotBasic>( robot: &'a mut Robot<M>, idx_s_start: usize, a_linearization: &'a [f64], a_boundary: (f64, f64), b_boundary: (f64, f64), ) -> Self

Create a TOPP3 builder with required fields.

Defaults:

  • num_stationary_max = (1, 1)
  • a_linearization_floor = 1E-10
Source

pub fn with_constraint( constraints: &'a mut Constraints, idx_s_start: usize, a_linearization: &'a [f64], a_boundary: (f64, f64), b_boundary: (f64, f64), ) -> Self

Create a TOPP3 builder with required fields.

Defaults:

  • num_stationary_max = (1, 1)
  • a_linearization_floor = 1E-10
Source

pub fn with_num_stationary_max(self, num_stationary_max: usize) -> Self

Set symmetric stationary upper bound: num_stationary_max=(n,n).

See module-level Stationary-boundary modeling note for guidance.

Source

pub fn with_num_stationary_max_pair( self, num_stationary_max: (usize, usize), ) -> Self

Set asymmetric stationary upper bound: num_stationary_max=(start,end).

See module-level Stationary-boundary modeling note for guidance.

Source

pub fn with_a_linearization_floor(self, floor: f64) -> Self

Set denominator floor used in third-order linearization near a = 0.

build_with_linearization applies 1.0 / max(a_linearization[k], floor).sqrt() when converting nonlinear jerk rows into affine rows.

Source

pub fn build_with_linearization(self) -> Result<Topp3Problem<'a>, CoppError>

Build a TOPP3 problem and linearize third-order constraints in one step.

This validates boundaries/interval/floor first, then writes linearized jerk buffers inside Constraints. The generated rows can be inspected with Constraints::get_jerk_linear_constraints.

§Rebuilding rule

If a later solver result is used as a new a_linearization, create a new builder and call build_with_linearization again before solving.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.