pub trait Planner {
// Required methods
fn plan(
&self,
current_position: Vector3<f32>,
current_velocity: Vector3<f32>,
time: f32,
) -> (Vector3<f32>, Vector3<f32>, f32);
fn is_finished(
&self,
current_position: Vector3<f32>,
time: f32,
) -> Result<bool, SimulationError>;
}
Expand description
Trait defining the interface for trajectory planners
§Example
use nalgebra::Vector3;
use peng_quad::{Planner, SimulationError};
struct TestPlanner;
impl Planner for TestPlanner {
fn plan(
&self,
current_position: Vector3<f32>,
current_velocity: Vector3<f32>,
time: f32,
) -> (Vector3<f32>, Vector3<f32>, f32) {
(Vector3::new(0.0, 0.0, 0.0), Vector3::new(0.0, 0.0, 0.0), 0.0)
}
fn is_finished(
&self,
current_position: Vector3<f32>,
time: f32,
) -> Result<bool, SimulationError> {
Ok(true)
}
}
Required Methods§
Sourcefn 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)
Plans the trajectory based on the current state and time
§Arguments
current_position
- The current position 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
§Example
use nalgebra::Vector3;
use peng_quad::{Planner, SimulationError};
struct TestPlanner;
impl Planner for TestPlanner {
fn plan(
&self,
current_position: Vector3<f32>,
current_velocity: Vector3<f32>,
time: f32,
) -> (Vector3<f32>, Vector3<f32>, f32) {
(Vector3::new(0.0, 0.0, 0.0), Vector3::new(0.0, 0.0, 0.0), 0.0)
}
fn is_finished(
&self,
current_position: Vector3<f32>,
time: f32,
) -> Result<bool, SimulationError> {
Ok(true)
}
}
Sourcefn 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>
Checks if the current trajectory is finished
§Arguments
current_position
- The current position of the quadrotortime
- The current simulation time
§Returns
true
if the trajectory is finished,false
otherwise
§Example
use nalgebra::Vector3;
use peng_quad::{Planner, SimulationError};
struct TestPlanner;
impl Planner for TestPlanner {
fn plan(
&self,
current_position: Vector3<f32>,
current_velocity: Vector3<f32>,
time: f32,
) -> (Vector3<f32>, Vector3<f32>, f32) {
(Vector3::new(0.0, 0.0, 0.0), Vector3::new(0.0, 0.0, 0.0), 0.0)
}
fn is_finished(
&self,
current_position: Vector3<f32>,
time: f32,
) -> Result<bool, SimulationError> {
Ok(true)
}
}
Implementors§
impl Planner for CirclePlanner
Implementation of the Planner trait for CirclePlanner
impl Planner for HoverPlanner
Implementation of the Planner
trait for the HoverPlanner
impl Planner for LandingPlanner
Implementation of the Planner trait for ‘LandingPlanner’
impl Planner for LissajousPlanner
Implementation of the planner trait for Lissajous curve trajectories
impl Planner for MinimumJerkLinePlanner
Implementation of the planner trait for minimum jerk line planner
impl Planner for MinimumSnapWaypointPlanner
Implement the Planner
trait for MinimumSnapWaypointPlanner
impl Planner for ObstacleAvoidancePlanner
Implementation of the Planner trait for ObstacleAvoidancePlanner
impl Planner for QPpolyTrajPlanner
Implement the Planner
trait for QPpolyTrajPlanner