mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-22 08:38:36 -04:00
Plane: implement get and set target location
This commit is contained in:
parent
d192544107
commit
9f92aad711
@ -699,4 +699,42 @@ void Plane::publish_osd_info()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// set target location (for use by scripting)
|
||||||
|
bool Plane::set_target_location(const Location& target_loc)
|
||||||
|
{
|
||||||
|
if (plane.control_mode != &plane.mode_guided) {
|
||||||
|
// only accept position updates when in GUIDED mode
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
plane.guided_WP_loc = target_loc;
|
||||||
|
// add home alt if needed
|
||||||
|
if (plane.guided_WP_loc.relative_alt) {
|
||||||
|
plane.guided_WP_loc.alt += plane.home.alt;
|
||||||
|
plane.guided_WP_loc.relative_alt = 0;
|
||||||
|
}
|
||||||
|
plane.set_guided_WP();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set target location (for use by scripting)
|
||||||
|
bool Plane::get_target_location(Location& target_loc)
|
||||||
|
{
|
||||||
|
switch (control_mode->mode_number()) {
|
||||||
|
case Mode::Number::RTL:
|
||||||
|
case Mode::Number::AVOID_ADSB:
|
||||||
|
case Mode::Number::GUIDED:
|
||||||
|
case Mode::Number::AUTO:
|
||||||
|
case Mode::Number::LOITER:
|
||||||
|
case Mode::Number::QLOITER:
|
||||||
|
case Mode::Number::QLAND:
|
||||||
|
case Mode::Number::QRTL:
|
||||||
|
target_loc = next_WP_loc;
|
||||||
|
return true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
AP_HAL_MAIN_CALLBACKS(&plane);
|
AP_HAL_MAIN_CALLBACKS(&plane);
|
||||||
|
@ -1040,6 +1040,8 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
void failsafe_check(void);
|
void failsafe_check(void);
|
||||||
|
bool set_target_location(const Location& target_loc) override;
|
||||||
|
bool get_target_location(Location& target_loc) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Plane plane;
|
extern Plane plane;
|
||||||
|
Loading…
Reference in New Issue
Block a user