APM:Libraries
|
Object managing Mission. More...
#include <AP_Mission.h>
Classes | |
struct | Altitude_Wait |
struct | Cam_Trigg_Distance |
struct | Change_Speed_Command |
struct | Conditional_Delay_Command |
struct | Conditional_Distance_Command |
union | Content |
struct | Digicam_Configure |
struct | Digicam_Control |
struct | Do_Engine_Control |
struct | Do_VTOL_Transition |
struct | Gripper_Command |
struct | Guided_Limits_Command |
struct | Jump_Command |
struct | jump_tracking_struct |
struct | Mission_Command |
struct | Mission_Flags |
struct | Mount_Control |
struct | Navigation_Delay_Command |
struct | Repeat_Relay_Command |
struct | Repeat_Servo_Command |
struct | Set_Relay_Command |
struct | Set_Servo_Command |
struct | Set_Yaw_Speed |
struct | Winch_Command |
struct | Yaw_Command |
Public Types | |
enum | mission_state { MISSION_STOPPED =0, MISSION_RUNNING =1, MISSION_COMPLETE =2 } |
Public Member Functions | |
FUNCTOR_TYPEDEF (mission_cmd_fn_t, bool, const Mission_Command &) | |
FUNCTOR_TYPEDEF (mission_complete_fn_t, void) | |
AP_Mission (AP_AHRS &ahrs, mission_cmd_fn_t cmd_start_fn, mission_cmd_fn_t cmd_verify_fn, mission_complete_fn_t mission_complete_fn) | |
AP_Mission (const AP_Mission &other)=delete | |
AP_Mission & | operator= (const AP_Mission &)=delete |
void | init () |
init - initialises this library including checks the version in eeprom matches this library More... | |
mission_state | state () const |
status - returns the status of the mission (i.e. Mission_Started, Mission_Complete, Mission_Stopped More... | |
uint16_t | num_commands () const |
uint16_t | num_commands_max () const |
num_commands_max - returns maximum number of commands that can be stored More... | |
void | start () |
void | stop () |
stop - stops mission execution. subsequent calls to update() will have no effect until the mission is started or resumed More... | |
void | resume () |
void | start_or_resume () |
start_or_resume - if MIS_AUTORESTART=0 this will call resume(), otherwise it will call start() More... | |
bool | starts_with_takeoff_cmd () |
check mission starts with a takeoff command More... | |
void | reset () |
reset - reset mission to the first command More... | |
bool | clear () |
void | truncate (uint16_t index) |
truncate - truncate any mission items beyond given index More... | |
void | update () |
bool | add_cmd (Mission_Command &cmd) |
bool | replace_cmd (uint16_t index, Mission_Command &cmd) |
const Mission_Command & | get_current_nav_cmd () const |
get_current_nav_cmd - returns the current "navigation" command More... | |
uint16_t | get_current_nav_index () const |
uint16_t | get_prev_nav_cmd_id () const |
uint16_t | get_prev_nav_cmd_index () const |
uint16_t | get_prev_nav_cmd_with_wp_index () const |
bool | get_next_nav_cmd (uint16_t start_index, Mission_Command &cmd) |
int32_t | get_next_ground_course_cd (int32_t default_angle) |
const Mission_Command & | get_current_do_cmd () const |
get_current_do_cmd - returns active "do" command More... | |
bool | set_current_cmd (uint16_t index) |
bool | read_cmd_from_storage (uint16_t index, Mission_Command &cmd) const |
bool | write_cmd_to_storage (uint16_t index, Mission_Command &cmd) |
void | write_home_to_storage () |
uint32_t | last_change_time_ms (void) const |
uint16_t | get_landing_sequence_start () |
bool | jump_to_landing_sequence (void) |
Static Public Member Functions | |
static bool | is_nav_cmd (const Mission_Command &cmd) |
is_nav_cmd - returns true if the command's id is a "navigation" command, false if "do" or "conditional" command More... | |
static MAV_MISSION_RESULT | mavlink_to_mission_cmd (const mavlink_mission_item_t &packet, AP_Mission::Mission_Command &cmd) |
static MAV_MISSION_RESULT | mavlink_int_to_mission_cmd (const mavlink_mission_item_int_t &packet, AP_Mission::Mission_Command &cmd) |
static MAV_MISSION_RESULT | mavlink_cmd_long_to_mission_cmd (const mavlink_command_long_t &packet, AP_Mission::Mission_Command &cmd) |
static bool | mission_cmd_to_mavlink (const AP_Mission::Mission_Command &cmd, mavlink_mission_item_t &packet) |
static bool | mission_cmd_to_mavlink_int (const AP_Mission::Mission_Command &cmd, mavlink_mission_item_int_t &packet) |
Static Public Attributes | |
static const struct AP_Param::GroupInfo | var_info [] |
Private Member Functions | |
void | complete () |
complete - mission is marked complete and clean-up performed including calling the mission_complete_fn More... | |
bool | advance_current_nav_cmd () |
void | advance_current_do_cmd () |
bool | get_next_cmd (uint16_t start_index, Mission_Command &cmd, bool increment_jump_num_times_if_found) |
bool | get_next_do_cmd (uint16_t start_index, Mission_Command &cmd) |
void | init_jump_tracking () |
int16_t | get_jump_times_run (const Mission_Command &cmd) |
get_jump_times_run - returns number of times the jump command has been run More... | |
void | increment_jump_times_run (Mission_Command &cmd) |
increment_jump_times_run - increments the recorded number of times the jump command has been run More... | |
void | check_eeprom_version () |
Static Private Member Functions | |
static MAV_MISSION_RESULT | sanity_check_params (const mavlink_mission_item_int_t &packet) |
sanity checks that the masked fields are not NaN's or infinite More... | |
Private Attributes | |
struct AP_Mission::Mission_Flags | _flags |
const AP_AHRS & | _ahrs |
AP_Int16 | _cmd_total |
AP_Int8 | _restart |
AP_Int16 | _options |
mission_cmd_fn_t | _cmd_start_fn |
mission_cmd_fn_t | _cmd_verify_fn |
mission_complete_fn_t | _mission_complete_fn |
struct Mission_Command | _nav_cmd |
struct Mission_Command | _do_cmd |
uint16_t | _prev_nav_cmd_id |
uint16_t | _prev_nav_cmd_index |
uint16_t | _prev_nav_cmd_wp_index |
struct AP_Mission::jump_tracking_struct | _jump_tracking [AP_MISSION_MAX_NUM_DO_JUMP_COMMANDS] |
uint32_t | _last_change_time_ms |
Static Private Attributes | |
static StorageAccess | _storage |
Object managing Mission.
Definition at line 45 of file AP_Mission.h.
Enumerator | |
---|---|
MISSION_STOPPED | |
MISSION_RUNNING | |
MISSION_COMPLETE |
Definition at line 312 of file AP_Mission.h.
|
inline |
|
delete |
bool AP_Mission::add_cmd | ( | Mission_Command & | cmd | ) |
public command methodsadd_cmd - adds a command to the end of the command list and writes to storage returns true if successfully added, false on failure cmd.index is updated with it's new position in the mission
Definition at line 254 of file AP_Mission.cpp.
Referenced by GCS_MAVLINK::handle_mission_item(), MissionTest::init_mission(), MissionTest::init_mission_endless_loop(), MissionTest::init_mission_ends_with_do_commands(), MissionTest::init_mission_ends_with_jump_command(), MissionTest::init_mission_jump_to_nonnav(), MissionTest::init_mission_no_nav_commands(), MissionTest::init_mission_starts_with_do_commands(), num_commands(), MissionTest::run_max_cmd_test(), MissionTest::run_replace_cmd_test(), MissionTest::run_resume_test(), MissionTest::run_set_current_cmd_test(), and MissionTest::run_set_current_cmd_while_stopped_test().
|
private |
advance_current_do_cmd - moves current do command forward accounts for do-jump commands returns true if successfully advanced (can it ever be unsuccessful?)
advance_current_do_cmd - moves current do command forward accounts for do-jump commands
Definition at line 1462 of file AP_Mission.cpp.
Referenced by update().
|
private |
advance_current_nav_cmd - moves current nav command forward do command will also be loaded accounts for do-jump commands
Definition at line 1381 of file AP_Mission.cpp.
Referenced by start(), and update().
|
private |
check_eeprom_version - checks version of missions stored in eeprom matches this library command list will be cleared if they do not match
Definition at line 1669 of file AP_Mission.cpp.
Referenced by init().
bool AP_Mission::clear | ( | void | ) |
clear - clears out mission returns true if mission was running so it could not be cleared
Definition at line 175 of file AP_Mission.cpp.
Referenced by check_eeprom_version(), GCS_MAVLINK::handle_mission_clear_all(), init(), MissionTest::init_mission(), MissionTest::init_mission_endless_loop(), MissionTest::init_mission_ends_with_do_commands(), MissionTest::init_mission_ends_with_jump_command(), MissionTest::init_mission_jump_to_nonnav(), MissionTest::init_mission_no_nav_commands(), MissionTest::init_mission_starts_with_do_commands(), and num_commands().
|
private |
complete - mission is marked complete and clean-up performed including calling the mission_complete_fn
private methods
Definition at line 1368 of file AP_Mission.cpp.
Referenced by set_current_cmd(), start(), and update().
AP_Mission::FUNCTOR_TYPEDEF | ( | mission_cmd_fn_t | , |
bool | , | ||
const Mission_Command & | |||
) |
AP_Mission::FUNCTOR_TYPEDEF | ( | mission_complete_fn_t | , |
void | |||
) |
|
inline |
get_current_do_cmd - returns active "do" command
Definition at line 418 of file AP_Mission.h.
|
inline |
get_current_nav_cmd - returns the current "navigation" command
Definition at line 384 of file AP_Mission.h.
Referenced by AP_AdvancedFailsafe::check(), GCS_MAVLINK::handle_mission_request(), and AP_Landing::restart_landing_sequence().
|
inline |
get_current_nav_index - returns the current "navigation" command index Note that this will return 0 if there is no command. This is used in MAVLink reporting of the mission command
Definition at line 389 of file AP_Mission.h.
Referenced by AP_Landing::restart_landing_sequence(), and GCS_MAVLINK::try_send_mission_message().
|
private |
get_jump_times_run - returns number of times the jump command has been run
get_jump_times_run - returns number of times the jump command has been run return is signed to be consistent with do-jump cmd's repeat count which can be -1 (to signify to repeat forever)
Definition at line 1615 of file AP_Mission.cpp.
Referenced by get_next_cmd().
uint16_t AP_Mission::get_landing_sequence_start | ( | ) |
Definition at line 1693 of file AP_Mission.cpp.
Referenced by jump_to_landing_sequence(), last_change_time_ms(), and AP_Landing::restart_landing_sequence().
|
private |
get_next_cmd - gets next command found at or after start_index returns true if found, false if not found (i.e. mission complete) accounts for do_jump commands increment_jump_num_times_if_found should be set to true if advancing the active navigation command
Definition at line 1504 of file AP_Mission.cpp.
Referenced by advance_current_nav_cmd(), get_next_do_cmd(), get_next_nav_cmd(), and set_current_cmd().
|
private |
get_next_do_cmd - gets next "do" or "conditional" command after start_index returns true if found, false if not found stops and returns false if it hits another navigation command before it finds the first do or conditional command accounts for do_jump commands but never increments the jump's num_times_run (get_next_nav_cmd is responsible for this)
get_next_do_cmd - gets next "do" or "conditional" command after start_index returns true if found, false if not found stops and returns false if it hits another navigation command before it finds the first do or conditional command accounts for do_jump commands but never increments the jump's num_times_run (advance_current_nav_cmd is responsible for this)
Definition at line 1578 of file AP_Mission.cpp.
Referenced by advance_current_do_cmd().
int32_t AP_Mission::get_next_ground_course_cd | ( | int32_t | default_angle | ) |
get the ground course of the next navigation leg in centidegrees from 0 36000. Return default_angle if next navigation leg cannot be determined
Definition at line 321 of file AP_Mission.cpp.
Referenced by get_prev_nav_cmd_with_wp_index().
bool AP_Mission::get_next_nav_cmd | ( | uint16_t | start_index, |
Mission_Command & | cmd | ||
) |
get_next_nav_cmd - gets next "navigation" command found at or after start_index returns true if found, false if not found (i.e. reached end of mission command list) accounts for do_jump commands
get_next_nav_cmd - gets next "navigation" command found at or after start_index returns true if found, false if not found (i.e. reached end of mission command list) accounts for do_jump commands but never increments the jump's num_times_run (advance_current_nav_cmd is responsible for this)
Definition at line 293 of file AP_Mission.cpp.
Referenced by get_next_ground_course_cd(), get_prev_nav_cmd_with_wp_index(), and starts_with_takeoff_cmd().
|
inline |
get_prev_nav_cmd_id - returns the previous "navigation" command id if there was no previous nav command it returns AP_MISSION_CMD_ID_NONE we do not return the entire command to save on RAM
Definition at line 395 of file AP_Mission.h.
Referenced by AP_Landing::type_slope_verify_land().
|
inline |
get_prev_nav_cmd_index - returns the previous "navigation" commands index (i.e. position in the mission command list) if there was no previous nav command it returns AP_MISSION_CMD_INDEX_NONE we do not return the entire command to save on RAM
Definition at line 400 of file AP_Mission.h.
|
inline |
get_prev_nav_cmd_with_wp_index - returns the previous "navigation" commands index that contains a waypoint (i.e. position in the mission command list) if there was no previous nav command it returns AP_MISSION_CMD_INDEX_NONE we do not return the entire command to save on RAM
Definition at line 405 of file AP_Mission.h.
Referenced by AP_Landing::restart_landing_sequence().
|
private |
increment_jump_times_run - increments the recorded number of times the jump command has been run
Definition at line 1641 of file AP_Mission.cpp.
Referenced by get_next_cmd().
void AP_Mission::init | ( | void | ) |
init - initialises this library including checks the version in eeprom matches this library
public mission methods
Definition at line 45 of file AP_Mission.cpp.
|
private |
jump handling methods
Definition at line 1606 of file AP_Mission.cpp.
Referenced by reset(), and set_current_cmd().
|
static |
is_nav_cmd - returns true if the command's id is a "navigation" command, false if "do" or "conditional" command
Definition at line 284 of file AP_Mission.cpp.
Referenced by advance_current_nav_cmd(), get_next_do_cmd(), get_next_nav_cmd(), num_commands(), MissionTest::print_mission(), set_current_cmd(), MissionTest::start_cmd(), and MissionTest::verify_cmd().
bool AP_Mission::jump_to_landing_sequence | ( | void | ) |
Definition at line 1727 of file AP_Mission.cpp.
Referenced by last_change_time_ms().
|
inline |
|
static |
Definition at line 1019 of file AP_Mission.cpp.
Referenced by get_current_do_cmd().
|
static |
Definition at line 577 of file AP_Mission.cpp.
Referenced by get_current_do_cmd(), GCS_MAVLINK::handle_mission_item(), and mavlink_to_mission_cmd().
|
static |
Definition at line 922 of file AP_Mission.cpp.
Referenced by get_current_do_cmd(), GCS_MAVLINK::handle_mission_item(), and mavlink_cmd_long_to_mission_cmd().
|
static |
Definition at line 973 of file AP_Mission.cpp.
Referenced by get_current_do_cmd(), GCS_MAVLINK::handle_mission_request(), and DataFlash_Backend::Log_Write_Mission_Cmd().
|
static |
Definition at line 1037 of file AP_Mission.cpp.
Referenced by get_current_do_cmd(), GCS_MAVLINK::handle_mission_request(), and mission_cmd_to_mavlink().
|
inline |
num_commands - returns total number of commands in the mission this number includes offset 0, the home location
Definition at line 330 of file AP_Mission.h.
Referenced by get_landing_sequence_start(), GCS_MAVLINK::handle_mission_item(), GCS_MAVLINK::handle_mission_request(), GCS_MAVLINK::handle_mission_request_list(), GCS_MAVLINK::handle_mission_write_partial_list(), DataFlash_Backend::Log_Write_Mission_Cmd(), MissionTest::print_mission(), and MissionTest::run_max_cmd_test().
uint16_t AP_Mission::num_commands_max | ( | void | ) | const |
num_commands_max - returns maximum number of commands that can be stored
Definition at line 1684 of file AP_Mission.cpp.
Referenced by GCS_MAVLINK::handle_mission_count(), num_commands(), MissionTest::run_max_cmd_test(), MissionTest::setup(), and write_cmd_to_storage().
|
delete |
bool AP_Mission::read_cmd_from_storage | ( | uint16_t | index, |
Mission_Command & | cmd | ||
) | const |
load_cmd_from_storage - load command from storage true is return if successful
Definition at line 453 of file AP_Mission.cpp.
Referenced by get_current_do_cmd(), get_landing_sequence_start(), get_next_cmd(), GCS_MAVLINK::handle_mission_request(), MissionTest::print_mission(), AP_Landing::restart_landing_sequence(), resume(), and MissionTest::run_max_cmd_test().
bool AP_Mission::replace_cmd | ( | uint16_t | index, |
Mission_Command & | cmd | ||
) |
replace_cmd - replaces the command at position 'index' in the command list with the provided cmd replacing the current active command will have no effect until the command is restarted returns true if successfully replaced, false on failure
Definition at line 272 of file AP_Mission.cpp.
Referenced by GCS_MAVLINK::handle_mission_item(), num_commands(), and MissionTest::run_replace_cmd_test().
void AP_Mission::reset | ( | ) |
reset - reset mission to the first command
Definition at line 160 of file AP_Mission.cpp.
Referenced by num_commands(), and start().
void AP_Mission::resume | ( | ) |
resume - continues the mission execution from where we last left off previous running commands will be re-initialised
resume - continues the mission execution from where we last left off previous running commands will be re-initialized
Definition at line 86 of file AP_Mission.cpp.
Referenced by jump_to_landing_sequence(), num_commands(), MissionTest::run_resume_test(), MissionTest::run_set_current_cmd_while_stopped_test(), start_or_resume(), and AP_Landing::verify_abort_landing().
|
staticprivate |
sanity checks that the masked fields are not NaN's or infinite
Definition at line 533 of file AP_Mission.cpp.
Referenced by mavlink_int_to_mission_cmd().
bool AP_Mission::set_current_cmd | ( | uint16_t | index | ) |
Definition at line 339 of file AP_Mission.cpp.
Referenced by AP_AdvancedFailsafe::check(), get_current_do_cmd(), GCS_MAVLINK::handle_mission_set_current(), jump_to_landing_sequence(), AP_Landing::restart_landing_sequence(), MissionTest::run_set_current_cmd_test(), and MissionTest::run_set_current_cmd_while_stopped_test().
void AP_Mission::start | ( | void | ) |
start - resets current commands to point to the beginning of the mission To-Do: should we validate the mission first and return true/false?
Definition at line 65 of file AP_Mission.cpp.
Referenced by num_commands(), resume(), MissionTest::run_mission_test(), MissionTest::run_replace_cmd_test(), MissionTest::run_resume_test(), MissionTest::run_set_current_cmd_test(), MissionTest::run_set_current_cmd_while_stopped_test(), and start_or_resume().
void AP_Mission::start_or_resume | ( | ) |
start_or_resume - if MIS_AUTORESTART=0 this will call resume(), otherwise it will call start()
Definition at line 150 of file AP_Mission.cpp.
Referenced by num_commands().
bool AP_Mission::starts_with_takeoff_cmd | ( | ) |
check mission starts with a takeoff command
Definition at line 132 of file AP_Mission.cpp.
Referenced by num_commands().
|
inline |
status - returns the status of the mission (i.e. Mission_Started, Mission_Complete, Mission_Stopped
Definition at line 326 of file AP_Mission.h.
Referenced by jump_to_landing_sequence(), and MissionTest::run_set_current_cmd_while_stopped_test().
void AP_Mission::stop | ( | ) |
stop - stops mission execution. subsequent calls to update() will have no effect until the mission is started or resumed
Definition at line 79 of file AP_Mission.cpp.
Referenced by num_commands(), MissionTest::run_resume_test(), MissionTest::run_set_current_cmd_while_stopped_test(), and AP_Landing::verify_abort_landing().
void AP_Mission::truncate | ( | uint16_t | index | ) |
truncate - truncate any mission items beyond given index
trucate - truncate any mission items beyond index
Definition at line 197 of file AP_Mission.cpp.
Referenced by GCS_MAVLINK::handle_mission_count(), and num_commands().
void AP_Mission::update | ( | void | ) |
update - ensures the command queues are loaded with the next command and calls main programs command_init and command_verify functions to progress the mission should be called at 10hz or higher
Definition at line 206 of file AP_Mission.cpp.
Referenced by num_commands(), MissionTest::run_mission_test(), MissionTest::run_replace_cmd_test(), MissionTest::run_resume_test(), MissionTest::run_set_current_cmd_test(), and MissionTest::run_set_current_cmd_while_stopped_test().
bool AP_Mission::write_cmd_to_storage | ( | uint16_t | index, |
Mission_Command & | cmd | ||
) |
write_cmd_to_storage - write a command to storage cmd.index is used to calculate the storage location true is returned if successful
write_cmd_to_storage - write a command to storage index is used to calculate the storage location true is returned if successful
Definition at line 494 of file AP_Mission.cpp.
Referenced by add_cmd(), get_current_do_cmd(), replace_cmd(), and write_home_to_storage().
void AP_Mission::write_home_to_storage | ( | ) |
write_home_to_storage - writes the special purpose cmd 0 (home) to storage home is taken directly from ahrs
Definition at line 525 of file AP_Mission.cpp.
Referenced by get_current_do_cmd().
|
private |
Definition at line 527 of file AP_Mission.h.
Referenced by get_landing_sequence_start(), read_cmd_from_storage(), and write_home_to_storage().
|
private |
Definition at line 535 of file AP_Mission.h.
Referenced by advance_current_do_cmd(), advance_current_nav_cmd(), resume(), and set_current_cmd().
|
private |
Definition at line 530 of file AP_Mission.h.
Referenced by add_cmd(), advance_current_do_cmd(), clear(), get_jump_times_run(), get_next_cmd(), get_next_do_cmd(), get_next_nav_cmd(), num_commands(), read_cmd_from_storage(), replace_cmd(), set_current_cmd(), truncate(), and update().
|
private |
Definition at line 536 of file AP_Mission.h.
Referenced by update().
|
private |
Definition at line 541 of file AP_Mission.h.
Referenced by advance_current_do_cmd(), advance_current_nav_cmd(), AP_Mission(), clear(), get_current_do_cmd(), reset(), resume(), set_current_cmd(), and update().
|
private |
Referenced by advance_current_do_cmd(), advance_current_nav_cmd(), AP_Mission(), clear(), complete(), reset(), resume(), set_current_cmd(), start(), state(), stop(), and update().
|
private |
Referenced by get_jump_times_run(), increment_jump_times_run(), and init_jump_tracking().
|
private |
Definition at line 553 of file AP_Mission.h.
Referenced by init(), last_change_time_ms(), and write_cmd_to_storage().
|
private |
Definition at line 537 of file AP_Mission.h.
Referenced by complete().
|
private |
Definition at line 540 of file AP_Mission.h.
Referenced by advance_current_nav_cmd(), AP_Mission(), clear(), get_current_nav_cmd(), get_current_nav_index(), get_next_ground_course_cd(), reset(), resume(), set_current_cmd(), starts_with_takeoff_cmd(), and update().
|
private |
Definition at line 532 of file AP_Mission.h.
Referenced by init().
|
private |
Definition at line 542 of file AP_Mission.h.
Referenced by advance_current_nav_cmd(), get_prev_nav_cmd_id(), reset(), and set_current_cmd().
|
private |
Definition at line 543 of file AP_Mission.h.
Referenced by advance_current_nav_cmd(), get_prev_nav_cmd_index(), reset(), and set_current_cmd().
|
private |
Definition at line 544 of file AP_Mission.h.
Referenced by advance_current_nav_cmd(), get_prev_nav_cmd_with_wp_index(), reset(), and set_current_cmd().
|
private |
Definition at line 531 of file AP_Mission.h.
Referenced by start_or_resume(), and starts_with_takeoff_cmd().
|
staticprivate |
Definition at line 467 of file AP_Mission.h.
Referenced by check_eeprom_version(), num_commands_max(), read_cmd_from_storage(), and write_cmd_to_storage().
|
static |