AP_Mission: special handling for cmd

This commit is contained in:
Randy Mackay 2014-02-28 11:58:27 +09:00
parent 37fe229ded
commit 87c7d19f83
2 changed files with 32 additions and 21 deletions

View File

@ -212,6 +212,12 @@ bool AP_Mission::read_cmd_from_storage(uint8_t index, Mission_Command& cmd) cons
return false; return false;
} }
// special handling for command #0 which is home
if (index == 0) {
cmd.index = 0;
cmd.id = MAV_CMD_NAV_WAYPOINT;
cmd.content.location = _ahrs.get_home();
}else{
// Find out proper location in memory by using the start_byte position + the index // Find out proper location in memory by using the start_byte position + the index
// we can load a command, we don't process it yet // we can load a command, we don't process it yet
// read WP position // read WP position
@ -240,6 +246,7 @@ bool AP_Mission::read_cmd_from_storage(uint8_t index, Mission_Command& cmd) cons
// set command from location's command // set command from location's command
// To-Do: remove id (and p1?) from Location structure // To-Do: remove id (and p1?) from Location structure
cmd.id = cmd.content.location.id; cmd.id = cmd.content.location.id;
}
// return success // return success
return true; return true;

View File

@ -79,7 +79,8 @@ public:
}; };
/// constructor /// constructor
AP_Mission(mission_cmd_fn_t cmd_start_fn, mission_cmd_fn_t cmd_verify_fn, mission_complete_fn_t mission_complete_fn) : 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) :
_ahrs(ahrs),
_cmd_start_fn(cmd_start_fn), _cmd_start_fn(cmd_start_fn),
_cmd_verify_fn(cmd_verify_fn), _cmd_verify_fn(cmd_verify_fn),
_mission_complete_fn(mission_complete_fn), _mission_complete_fn(mission_complete_fn),
@ -220,6 +221,9 @@ private:
/// increment_jump_times_run - increments the recorded number of times the jump command has been run /// increment_jump_times_run - increments the recorded number of times the jump command has been run
void increment_jump_times_run(Mission_Command& cmd); void increment_jump_times_run(Mission_Command& cmd);
// references to external libraries
const AP_AHRS& _ahrs; // used only for home position
// parameters // parameters
AP_Int16 _cmd_total; // total number of commands in the mission AP_Int16 _cmd_total; // total number of commands in the mission