Skip to content

Commit 980de3d

Browse files
committed
ArduPlane: support target airspeed command from DDS
* Similar to MAV_CMD_GUIDED_CHANGE_SPEED Signed-off-by: Ryan Friedman <[email protected]>
1 parent a798be9 commit 980de3d

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

ArduPlane/AP_ExternalControl_Plane.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,25 @@ bool AP_ExternalControl_Plane::set_global_position(const Location& loc)
1919
return plane.set_target_location(loc);
2020
}
2121

22+
/*
23+
Sets the target global position for a loiter point.
24+
*/
25+
bool AP_ExternalControl_Plane::set_airspeed(const float airspeed)
26+
{
27+
#if AP_PLANE_OFFBOARD_GUIDED_SLEW_ENABLED
28+
// command is only valid in guided mode
29+
if (plane.control_mode != &plane.mode_guided) {
30+
return false;
31+
}
32+
33+
if (airspeed > plane.aparm.airspeed_max || airspeed < plane.aparm.airspeed_min) {
34+
return false;
35+
}
36+
plane.guided_state.target_airspeed_cm = airspeed * 100;
37+
return true;
38+
#else
39+
return false;
40+
#endif
41+
}
42+
2243
#endif // AP_EXTERNAL_CONTROL_ENABLED

ArduPlane/AP_ExternalControl_Plane.h

+6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ class AP_ExternalControl_Plane : public AP_ExternalControl {
1616
Sets the target global position for a loiter point.
1717
*/
1818
bool set_global_position(const Location& loc) override WARN_IF_UNUSED;
19+
20+
/*
21+
Sets the target airspeed.
22+
*/
23+
bool set_airspeed(const float airspeed) override WARN_IF_UNUSED;
24+
1925
};
2026

2127
#endif // AP_EXTERNAL_CONTROL_ENABLED

0 commit comments

Comments
 (0)