Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Ardupilot
GitHub Repository: Ardupilot/ardupilot
Path: blob/master/ArduPlane/AP_ExternalControl_Plane.cpp
9448 views
1
/*
2
external control library for plane
3
*/
4
5
6
#include "AP_ExternalControl_Plane.h"
7
#if AP_EXTERNAL_CONTROL_ENABLED
8
9
#include "Plane.h"
10
11
/*
12
Sets the target global position for a loiter point.
13
*/
14
bool AP_ExternalControl_Plane::set_global_position(const Location& loc)
15
{
16
17
// set_target_location already checks if plane is ready for external control.
18
// It doesn't check if flying or armed, just that it's in guided mode.
19
return plane.set_target_location(loc);
20
}
21
22
/*
23
Sets the target airspeed.
24
*/
25
bool AP_ExternalControl_Plane::set_airspeed(const float airspeed)
26
{
27
#if AP_PLANE_OFFBOARD_GUIDED_SLEW_ENABLED
28
// The command is only valid in guided mode.
29
if (plane.control_mode != &plane.mode_guided) {
30
return false;
31
}
32
33
// Assume the user wanted maximum acceleration.
34
const float acc_instant = 0.0;
35
return plane.mode_guided.handle_change_airspeed(airspeed, acc_instant);
36
#else
37
return false;
38
#endif
39
}
40
41
#endif // AP_EXTERNAL_CONTROL_ENABLED
42
43