pub struct Copp3ProblemBuilder<'a, M: RobotTorque> {
pub robot: &'a mut Robot<M>,
pub objectives: &'a [CoppObjective<'a>],
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 Copp3Problem.
§Why mutable?
COPP3 uses the same third-order linearization cache as TOPP3. The builder
takes &mut Robot<M> because
build_with_linearization converts nonconvex
jerk rows into affine rows around a_linearization and stores those rows in
robot.constraints.
Rebuild the problem whenever the linearization profile changes.
§Example
The example below builds a COPP3 problem with time and thermal objectives, including the required third-order linearization profile.
use copp::robot::Robot;
use copp::solver::copp3_socp::{Copp3ProblemBuilder, CoppObjective};
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 normalize = [1.0, 1.0];
let objectives = [
CoppObjective::Time(1.0),
CoppObjective::ThermalEnergy(0.1, &normalize),
];
let _problem = Copp3ProblemBuilder::new(
&mut robot,
&objectives,
0,
&a_linearization,
(0.0, 0.0),
(0.0, 0.0),
)
.build_with_linearization()?;Fields§
§robot: &'a mut Robot<M>A robot with torque implemented, which defines the constraints and dynamic of the problem.
objectives: &'a [CoppObjective<'a>]Objectives for COPP3 optimization.
idx_s_start: usizeThe starting index along the path (reached).
a_linearization: &'a [f64]Linearization reference profile for third-order constraints.
a_boundary: (f64, f64)a_boundary=(a_start,a_final) - The initial and final acceleration at the start and end of the path.
b_boundary: (f64, f64)b_boundary=(b_start,b_final) - The initial and final boundary conditions for b.
num_stationary_max: (usize, usize)User-input upper bound of stationary intervals at (start, end).
a_linearization_floor: f64Denominator 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, M: RobotTorque> Copp3ProblemBuilder<'a, M>
impl<'a, M: RobotTorque> Copp3ProblemBuilder<'a, M>
Sourcepub fn new(
robot: &'a mut Robot<M>,
objectives: &'a [CoppObjective<'a>],
idx_s_start: usize,
a_linearization: &'a [f64],
a_boundary: (f64, f64),
b_boundary: (f64, f64),
) -> Self
pub fn new( robot: &'a mut Robot<M>, objectives: &'a [CoppObjective<'a>], idx_s_start: usize, a_linearization: &'a [f64], a_boundary: (f64, f64), b_boundary: (f64, f64), ) -> Self
Create a COPP3 builder with required fields.
Defaults:
num_stationary_max = (1, 1)a_linearization_floor = 1E-10
Sourcepub fn with_num_stationary_max(self, num_stationary_max: usize) -> Self
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.
Sourcepub fn with_num_stationary_max_pair(
self,
num_stationary_max: (usize, usize),
) -> Self
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.
Sourcepub fn with_a_linearization_floor(self, floor: f64) -> Self
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.
Sourcepub fn build_with_linearization(self) -> Result<Copp3Problem<'a, M>, CoppError>
pub fn build_with_linearization(self) -> Result<Copp3Problem<'a, M>, CoppError>
Build a validated COPP3 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§
impl<'a, M> Freeze for Copp3ProblemBuilder<'a, M>
impl<'a, M> RefUnwindSafe for Copp3ProblemBuilder<'a, M>where
M: RefUnwindSafe,
impl<'a, M> Send for Copp3ProblemBuilder<'a, M>where
M: Send,
impl<'a, M> Sync for Copp3ProblemBuilder<'a, M>where
M: Sync,
impl<'a, M> Unpin for Copp3ProblemBuilder<'a, M>
impl<'a, M> !UnwindSafe for Copp3ProblemBuilder<'a, M>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.