Skip to content

Commit 6256789

Browse files
committed
Copter: avoid Guided submode change unless can change Loc to Vec-from-origin
ordering problem between changing the submode and setting a valid position
1 parent 6a0c12e commit 6256789

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

ArduCopter/mode_guided.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,13 @@ bool ModeGuided::set_destination(const Location& dest_loc, bool use_yaw, float y
456456
return true;
457457
}
458458

459+
// set position target and zero velocity and acceleration
460+
Vector3f pos_target_f;
461+
bool terrain_alt;
462+
if (!wp_nav->get_vector_NEU(dest_loc, pos_target_f, terrain_alt)) {
463+
return false;
464+
}
465+
459466
// if configured to use position controller for position control
460467
// ensure we are in position control mode
461468
if (guided_mode != SubMode::Pos) {
@@ -465,13 +472,6 @@ bool ModeGuided::set_destination(const Location& dest_loc, bool use_yaw, float y
465472
// set yaw state
466473
set_yaw_state(use_yaw, yaw_cd, use_yaw_rate, yaw_rate_cds, relative_yaw);
467474

468-
// set position target and zero velocity and acceleration
469-
Vector3f pos_target_f;
470-
bool terrain_alt;
471-
if (!wp_nav->get_vector_NEU(dest_loc, pos_target_f, terrain_alt)) {
472-
return false;
473-
}
474-
475475
// initialise terrain following if needed
476476
if (terrain_alt) {
477477
// get current alt above terrain

0 commit comments

Comments
 (0)