pub fn update_planner(
planner_manager: &mut PlannerManager,
step: usize,
time: f32,
simulation_frequency: usize,
quad: &Quadrotor,
obstacles: &[Obstacle],
planner_config: &[PlannerStepConfig],
) -> Result<(), SimulationError>
Expand description
Updates the planner based on the current simulation step and configuration
§Arguments
planner_manager
- The PlannerManager instance to updatestep
- The current simulation step in ms unittime
- The current simulation time- `simulation_frequency’ - The simulation frequency in Hz
quad
- The Quadrotor instanceobstacles
- The current obstacles in the simulationplanner_config
- The planner configuration
§Errors
- If the planner could not be created
§Example
use peng_quad::{PlannerManager, Quadrotor, Obstacle, PlannerStepConfig, update_planner};
use nalgebra::Vector3;
let simulation_frequency = 1000;
let initial_position = Vector3::new(0.0, 0.0, 0.0);
let initial_yaw = 0.0;
let mut planner_manager = PlannerManager::new(initial_position, initial_yaw);
let step = 0;
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_config = vec![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(),
}];
update_planner(&mut planner_manager, step, time, simulation_frequency, &quadrotor, &obstacles, &planner_config).unwrap();