Autopilot graph === ###### tags: `autopilot` # block diagram ![](https://i.imgur.com/uNvLpeF.png) ## Code autopilot.c ```C=222 switch(autopilot.mode) { case AUTOPILOT_MANUAL_FLIGHT_MODE: case AUTOPILOT_HOVERING_MODE: break; case AUTOPILOT_TRAJECTORY_FOLLOWING_MODE: autopilot_trajectory_following_handler(); break; case AUTOPILOT_LANDING_MODE: autopilot_landing_handler(curr_pos_enu); break; case AUTOPILOT_TAKEOFF_MODE: autopilot_takeoff_handler(); break; case AUTOPILOT_WAIT_NEXT_WAYPOINT_MODE: autopilot_wait_next_waypoint_handler(); break; case AUTOPILOT_FOLLOW_WAYPOINT_MODE: autopilot_follow_waypoint_handler(curr_pos_enu); break; ``` ## appendix: motor lock situations multirotor_geometry_ctrl.c ``` C=629 lock_motor |= check_motor_lock_condition(rc->throttle < 10.0f && autopilot_get_mode() == AUTOPILOT_MANUAL_FLIGHT_MODE); //lock motor if desired height is lower than threshold value in the takeoff mode lock_motor |= check_motor_lock_condition(pos_des_enu[2] < 0.10f && autopilot_get_mode() == AUTOPILOT_TAKEOFF_MODE); //lock motor if current position is very close to ground in the hovering mode lock_motor |= check_motor_lock_condition(curr_pos_enu[2] < 0.10f && autopilot_get_mode() == AUTOPILOT_HOVERING_MODE); //lock motor if motors are locked by autopilot lock_motor |= check_motor_lock_condition(autopilot_get_mode() == AUTOPILOT_MOTOR_LOCKED_MODE); //lock motor if radio safety botton is on lock_motor |= check_motor_lock_condition(rc->safety == true); if(lock_motor == false) { mr_geometry_ctrl_thrust_allocation(control_moments, control_force); } else { motor_halt(); } ```