pub struct PlannerManager {
pub current_planner: PlannerType,
}Expand description
Manages different trajectory planners and switches between them
§Example
use nalgebra::Vector3;
use peng_quad::PlannerManager;
let initial_position = Vector3::new(0.0, 0.0, 1.0);
let initial_yaw = 0.0;
let planner_manager = PlannerManager::new(initial_position, initial_yaw);Fields§
§current_planner: PlannerTypeThe current planner
Implementations§
Source§impl PlannerManager
Implementation of the PlannerManager
impl PlannerManager
Implementation of the PlannerManager
Sourcepub fn new(initial_position: Vector3<f32>, initial_yaw: f32) -> Self
pub fn new(initial_position: Vector3<f32>, initial_yaw: f32) -> Self
Creates a new PlannerManager with an initial hover planner
§Arguments
initial_position- The initial position for hoveringinitial_yaw- The initial yaw angle for hovering
§Returns
- A new PlannerManager instance
§Example
use nalgebra::Vector3;
use peng_quad::PlannerManager;
let initial_position = Vector3::new(0.0, 0.0, 1.0);
let initial_yaw = 0.0;
let planner_manager = PlannerManager::new(initial_position, initial_yaw);Sourcepub fn set_planner(&mut self, new_planner: PlannerType)
pub fn set_planner(&mut self, new_planner: PlannerType)
Sets a new planner
§Arguments
new_planner- The new planner to be set
§Example
use nalgebra::Vector3;
use peng_quad::{PlannerManager, CirclePlanner, PlannerType};
let initial_position = Vector3::new(0.0, 0.0, 1.0);
let initial_yaw = 0.0;
let mut planner_manager = PlannerManager::new(initial_position, initial_yaw);
let new_planner = CirclePlanner {
center: Vector3::new(0.0, 0.0, 1.0),
radius: 1.0,
angular_velocity: 1.0,
start_yaw: 0.0,
end_yaw: 0.0,
start_time: 0.0,
duration: 10.0,
ramp_time: 1.0,
start_position: Vector3::new(0.0, 0.0, 1.0),
};
planner_manager.set_planner(PlannerType::Circle(new_planner));Sourcepub fn update(
&mut self,
current_position: Vector3<f32>,
current_orientation: UnitQuaternion<f32>,
current_velocity: Vector3<f32>,
time: f32,
obstacles: &[Obstacle],
) -> Result<(Vector3<f32>, Vector3<f32>, f32), SimulationError>
pub fn update( &mut self, current_position: Vector3<f32>, current_orientation: UnitQuaternion<f32>, current_velocity: Vector3<f32>, time: f32, obstacles: &[Obstacle], ) -> Result<(Vector3<f32>, Vector3<f32>, f32), SimulationError>
Updates the current planner and returns the desired position, velocity, and yaw
§Arguments
current_position- The current position of the quadrotorcurrent_orientation- The current orientation of the quadrotorcurrent_velocity- The current velocity of the quadrotortime- The current simulation time
§Returns
- A tuple containing the desired position, velocity, and yaw angle
§Errors
- Returns a SimulationError if the current planner is not finished
§Example
use nalgebra::{Vector3, UnitQuaternion};
use peng_quad::{PlannerManager, SimulationError};
let initial_position = Vector3::new(0.0, 0.0, 1.0);
let initial_yaw = 0.0;
let mut planner_manager = PlannerManager::new(initial_position, initial_yaw);
let current_position = Vector3::new(0.0, 0.0, 1.0);
let current_orientation = UnitQuaternion::from_euler_angles(0.0, 0.0, 0.0);
let current_velocity = Vector3::new(0.0, 0.0, 0.0);
let obstacles = vec![];
let time = 0.0;
let result = planner_manager.update(current_position, current_orientation, current_velocity, time, &obstacles);
match result {
Ok((target_position, target_velocity, target_yaw)) => {
println!("Target Position: {:?}", target_position);
println!("Target Velocity: {:?}", target_velocity);
println!("Target Yaw: {:?}", target_yaw);
}
Err(SimulationError) => {
log::error!("Error: Planner is not finished");
}
}Auto Trait Implementations§
impl Freeze for PlannerManager
impl RefUnwindSafe for PlannerManager
impl Send for PlannerManager
impl Sync for PlannerManager
impl Unpin for PlannerManager
impl UnsafeUnpin for PlannerManager
impl UnwindSafe for PlannerManager
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
Mutably borrows from an owned value. Read more
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>,
Casts the value.
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>
Casts the value.
§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>
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 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>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
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>,
Applies the layer to a service and wraps it in [
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>
Performs the conversion.
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
Performs the conversion.
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>,
Casts the value.
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)
Casts the value.
§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>,
Casts the value.
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
Casts the value.
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>,
Casts the value.
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
Casts the value.
§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>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
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
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
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.Source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
Source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
Source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
Source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
Source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.