pub struct QPpolyTrajPlanner {
pub coeff: DMatrix<f64>,
pub polyorder: usize,
pub min_deriv: usize,
pub smooth_upto: usize,
pub segment_times: Vec<f32>,
pub waypoints: Vec<Vec<f32>>,
pub max_velocity: f32,
pub max_acceleration: f32,
pub start_time: f32,
pub dt: f32,
}Expand description
Waypoint planner that generates a quadratic polynomial trajectory between waypoints
§Example
use peng_quad::QPpolyTrajPlanner;
use nalgebra::Vector3;
let waypoints: Vec<Vec<f32>> = vec![vec![0.0,0.0,1.0,0.0], vec![1.0,0.0,1.0,0.0]];
let segment_times = vec![6.0];
let min_deriv = 3;
let polyorder = 9;
let smooth_upto = 4;
let max_velocity = 4.0;
let max_acceleration = 3.0;
let dt = 0.1;
let start_time = 0.0;
let mut qp_planner = QPpolyTrajPlanner::new(waypoints,segment_times,polyorder, min_deriv, smooth_upto,max_velocity,max_acceleration, start_time, dt);Fields§
§coeff: DMatrix<f64>Matrix of coefficients for each segment and each dimension, organized as nrows: polyorder*segment_times.len(), ncols: 4 (for x, y, z, yaw)
polyorder: usizeOrder of the polynomial to be used in computing trajectory
min_deriv: usizeMinimize which derivative in the QP problem (1->Velocity, 2->Acceleration, 3->Snap, 4->Jerk. Please note that derivative value greater than 4 is not supported)
smooth_upto: usizeEnsure continuity upto which derivative. NOTE: This MUST be <= polynomial_order (1->Velocity, 2->Acceleration, 3->Snap, 4->Jerk. Please note that derivative value greater than 4 is not supported)
segment_times: Vec<f32>Vector of time values for each segment, which tells the planner how much time each segment should take to complete. Expressed in seconds.
waypoints: Vec<Vec<f32>>Waypoints for each segment. Note that there should be segment_times.len() + 1 values for waypoints, with the position of the quadrotor being the very first waypoint.
max_velocity: f32Maximum velocity constraint. Set to 0.0 to disregard inequality constraints. Please set reasonable values for this as it influences solver convergence or failure.
max_acceleration: f32Maximum acceleration constraint. Set to 0.0 to disregard inequality constraints. Please set reasonable values for this as it influences solver convergence or failure.
start_time: f32Time at which the simulation starts. This value has no bearing to QPpolyTraj itself, but is used during simulation since we use relative time internally when computing values.
dt: f32Step time used while generating inequality constraints. Has no bearing if max_velocity or max_acceleration is set to 0.0. Please set reasonable value for this as it has a huge impact on OSQP solve time.
Implementations§
Source§impl QPpolyTrajPlanner
impl QPpolyTrajPlanner
Sourcepub fn new(
waypoints: Vec<Vec<f32>>,
segment_times: Vec<f32>,
polyorder: usize,
min_deriv: usize,
smooth_upto: usize,
max_velocity: f32,
max_acceleration: f32,
start_time: f32,
dt: f32,
) -> Result<Self, SimulationError>
pub fn new( waypoints: Vec<Vec<f32>>, segment_times: Vec<f32>, polyorder: usize, min_deriv: usize, smooth_upto: usize, max_velocity: f32, max_acceleration: f32, start_time: f32, dt: f32, ) -> Result<Self, SimulationError>
Generate a new QPpolyTraj planner
§Arguments
waypoints- The waypoints for the trajectorysegment_times- The times for each segment of the trajectorypolyorder- The order of the polynomialmin_deriv- The minimum derivative to be consideredsmooth_upto- The maximum derivative to be consideredmax_velocity- The maximum velocitymax_acceleration- The maximum accelerationstart_time- The start time of the trajectorydt- The time step for the trajectory
§Errors
- Returns an error if the specified waypoints, segment times, smooth_upto or polyorder is invalid
§Examples
use peng_quad::QPpolyTrajPlanner;
use nalgebra::{DMatrix, DVector, Vector3};
let waypoints: Vec<Vec<f32>> = vec![vec![0.0, 0.0, 0.0, 0.0], vec![1.0, 1.0, 1.5, 1.5707963267948966], vec![-1.0, 1.0, 1.75, 3.141592653589793], vec![0.0, -1.0, 1.0, -1.5707963267948966], vec![0.0, 0.0, 0.5, 0.0]];
let segment_times = vec![5.0, 5.0, 5.0, 5.0];
let polyorder = 9;
let min_deriv = 3;
let smooth_upto = 4;
let max_velocity = 4.0;
let max_acceleration = 2.0;
let start_time = 0.0;
let dt = 0.1;
let mut qp_planner = QPpolyTrajPlanner::new(waypoints,segment_times,polyorder, min_deriv, smooth_upto,max_velocity,max_acceleration, start_time, dt).unwrap();Sourcepub fn evaluate_polynomial(
&self,
t: f32,
segment: usize,
) -> (Vector3<f32>, Vector3<f32>, f32, f32)
pub fn evaluate_polynomial( &self, t: f32, segment: usize, ) -> (Vector3<f32>, Vector3<f32>, f32, f32)
Compute the position, velocity, yaw, and yaw_rate for a given time t in given segment
§Arguments
t- The time at which to evaluate the polynomialsegment- The segment index for which to evaluate the polynomial
§Returns
- A tuple containing the position, velocity, yaw, and yaw_rate at time
tin segmentsegment
Trait Implementations§
Source§impl Planner for QPpolyTrajPlanner
Implement the Planner trait for QPpolyTrajPlanner
impl Planner for QPpolyTrajPlanner
Implement the Planner trait for QPpolyTrajPlanner
Source§fn plan(
&self,
_current_position: Vector3<f32>,
_current_velocity: Vector3<f32>,
time: f32,
) -> (Vector3<f32>, Vector3<f32>, f32)
fn plan( &self, _current_position: Vector3<f32>, _current_velocity: Vector3<f32>, time: f32, ) -> (Vector3<f32>, Vector3<f32>, f32)
Source§fn is_finished(
&self,
current_position: Vector3<f32>,
time: f32,
) -> Result<bool, SimulationError>
fn is_finished( &self, current_position: Vector3<f32>, time: f32, ) -> Result<bool, SimulationError>
Auto Trait Implementations§
impl Freeze for QPpolyTrajPlanner
impl RefUnwindSafe for QPpolyTrajPlanner
impl Send for QPpolyTrajPlanner
impl Sync for QPpolyTrajPlanner
impl Unpin for QPpolyTrajPlanner
impl UnsafeUnpin for QPpolyTrajPlanner
impl UnwindSafe for QPpolyTrajPlanner
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> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].Source§impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
Source§fn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
Source§impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
Source§fn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Source§impl<T> StrictAs for T
impl<T> StrictAs for T
Source§fn strict_as<Dst>(self) -> Dstwhere
T: StrictCast<Dst>,
fn strict_as<Dst>(self) -> Dstwhere
T: StrictCast<Dst>,
Source§impl<Src, Dst> StrictCastFrom<Src> for Dstwhere
Src: StrictCast<Dst>,
impl<Src, Dst> StrictCastFrom<Src> for Dstwhere
Src: StrictCast<Dst>,
Source§fn strict_cast_from(src: Src) -> Dst
fn strict_cast_from(src: Src) -> Dst
§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.