pub fn create_planner(
step: &PlannerStepConfig,
quad: &Quadrotor,
time: f32,
obstacles: &[Obstacle],
) -> Result<PlannerType, SimulationError>
Expand description
Creates a planner based on the configuration
§Arguments
step
- The configuration for the planner step in ms unitquad
- The Quadrotor instancetime
- The current simulation timeobstacles
- The current obstacles in the simulation
§Returns
PlannerType
- The created planner
§Errors
- If the planner type is not recognized
§Example
use peng_quad::{PlannerType, Quadrotor, Obstacle, PlannerStepConfig, create_planner};
use nalgebra::Vector3;
let step = PlannerStepConfig {
step: 0,
planner_type: "MinimumJerkLine".to_string(),
params:
serde_yaml::from_str(r#"
end_position: [0.0, 0.0, 1.0]
end_yaw: 0.0
duration: 2.0
"#).unwrap(),
};
let time = 0.0;
let (time_step, mass, gravity, drag_coefficient) = (0.01, 1.3, 9.81, 0.01);
let inertia_matrix = [0.0347563, 0.0, 0.0, 0.0, 0.0458929, 0.0, 0.0, 0.0, 0.0977];
let quadrotor = Quadrotor::new(time_step, mass, gravity, drag_coefficient, inertia_matrix).unwrap();
let obstacles = vec![Obstacle::new(Vector3::new(0.0, 0.0, 0.0), Vector3::new(0.0, 0.0, 0.0), 1.0)];
let planner = create_planner(&step, &quadrotor, time, &obstacles).unwrap();
match planner {
PlannerType::MinimumJerkLine(_) => log::info!("Created MinimumJerkLine planner"),
_ => log::info!("Created another planner"),
}