mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -04:00
Rover: magically set home when toggling first waypoint in
Currently the first toggle will put home in rather than the first waypoint
This commit is contained in:
parent
e393828702
commit
88575bd536
@ -78,6 +78,23 @@ void RC_Channel_Rover::do_aux_function_change_mode(Mode &mode,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RC_Channel_Rover::add_waypoint_for_current_loc()
|
||||||
|
{
|
||||||
|
// create new mission command
|
||||||
|
AP_Mission::Mission_Command cmd = {};
|
||||||
|
|
||||||
|
// set new waypoint to current location
|
||||||
|
cmd.content.location = rover.current_loc;
|
||||||
|
|
||||||
|
// make the new command to a waypoint
|
||||||
|
cmd.id = MAV_CMD_NAV_WAYPOINT;
|
||||||
|
|
||||||
|
// save command
|
||||||
|
if (rover.mode_auto.mission.add_cmd(cmd)) {
|
||||||
|
hal.console->printf("Added waypoint %u", (unsigned)rover.mode_auto.mission.num_commands());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void RC_Channel_Rover::do_aux_function(const aux_func_t ch_option, const aux_switch_pos_t ch_flag)
|
void RC_Channel_Rover::do_aux_function(const aux_func_t ch_option, const aux_switch_pos_t ch_flag)
|
||||||
{
|
{
|
||||||
switch (ch_option) {
|
switch (ch_option) {
|
||||||
@ -101,19 +118,11 @@ void RC_Channel_Rover::do_aux_function(const aux_func_t ch_option, const aux_swi
|
|||||||
|
|
||||||
// record the waypoint if not in auto mode
|
// record the waypoint if not in auto mode
|
||||||
if (rover.control_mode != &rover.mode_auto) {
|
if (rover.control_mode != &rover.mode_auto) {
|
||||||
// create new mission command
|
if (rover.mode_auto.mission.num_commands() == 0) {
|
||||||
AP_Mission::Mission_Command cmd = {};
|
// add a home location....
|
||||||
|
add_waypoint_for_current_loc();
|
||||||
// set new waypoint to current location
|
|
||||||
cmd.content.location = rover.current_loc;
|
|
||||||
|
|
||||||
// make the new command to a waypoint
|
|
||||||
cmd.id = MAV_CMD_NAV_WAYPOINT;
|
|
||||||
|
|
||||||
// save command
|
|
||||||
if (rover.mode_auto.mission.add_cmd(cmd)) {
|
|
||||||
hal.console->printf("Added waypoint %u", (unsigned)rover.mode_auto.mission.num_commands());
|
|
||||||
}
|
}
|
||||||
|
add_waypoint_for_current_loc();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -22,6 +22,7 @@ private:
|
|||||||
void do_aux_function_change_mode(Mode &mode,
|
void do_aux_function_change_mode(Mode &mode,
|
||||||
const aux_switch_pos_t ch_flag);
|
const aux_switch_pos_t ch_flag);
|
||||||
|
|
||||||
|
void add_waypoint_for_current_loc();
|
||||||
};
|
};
|
||||||
|
|
||||||
class RC_Channels_Rover : public RC_Channels
|
class RC_Channels_Rover : public RC_Channels
|
||||||
|
Loading…
Reference in New Issue
Block a user