ArduPlane: move guided timeout to guided mode

Signed-off-by: Ryan Friedman <25047695+Ryanf55@users.noreply.github.com>
This commit is contained in:
Ryan Friedman 2024-12-24 17:49:41 -07:00
parent 73dbd8ce1d
commit 3555db0827
4 changed files with 35 additions and 10 deletions

View File

@ -1028,6 +1028,10 @@ const AP_Param::Info Plane::var_info[] = {
// @Path: mode_takeoff.cpp
GOBJECT(mode_takeoff, "TKOFF_", ModeTakeoff),
// @Group: GUIDED_
// @Path: mode_guided.cpp
GOBJECT(mode_guided, "GUIDED_", ModeGuided),
#if AP_PLANE_GLIDER_PULLUP_ENABLED
// @Group: PUP_
// @Path: pullup.cpp
@ -1303,14 +1307,6 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = {
// @User: Standard
AP_GROUPINFO("RNGFND_LND_ORNT", 36, ParametersG2, rangefinder_land_orient, ROTATION_PITCH_270),
#endif
// @Param: GUID_TIMEOUT
// @DisplayName: Guided mode timeout
// @Description: Guided mode timeout after which vehicle will return to guided loiter if no updates are received from caller. Only applicable during any combination of velocity, acceleration, angle control, and/or angular rate control
// @Units: s
// @Range: 0.01 5
// @User: Advanced
AP_GROUPINFO("GUID_TIMEOUT", 37, ParametersG2, guided_timeout, 3.0),
AP_GROUPEND
};

View File

@ -363,6 +363,7 @@ public:
k_param_pullup = 270,
k_param_quicktune,
k_param_mode_guided,
};
AP_Int16 format_version;
@ -566,7 +567,6 @@ public:
// guided yaw heading PID
AC_PID guidedHeading{5000.0, 0.0, 0.0, 0 , 10.0, 5.0, 5.0 , 5.0 , 0.0};
#endif
AP_Float guided_timeout;
#if AP_SCRIPTING_ENABLED && AP_FOLLOW_ENABLED

View File

@ -308,6 +308,8 @@ class ModeGuided : public Mode
{
public:
ModeGuided();
Number mode_number() const override { return Number::GUIDED; }
const char *name() const override { return "GUIDED"; }
const char *name4() const override { return "GUID"; }
@ -336,6 +338,9 @@ public:
// Only used for velocity, acceleration, angle control, and angular rate control.
uint32_t get_timeout_ms() const;
// var_info for holding parameter information
static const struct AP_Param::GroupInfo var_info[];
protected:
bool _enter() override;
@ -345,6 +350,7 @@ protected:
#endif
private:
AP_Float guided_timeout;
float active_radius_m;
};

View File

@ -1,6 +1,29 @@
#include "mode.h"
#include "Plane.h"
/*
mode guided parameters
*/
const AP_Param::GroupInfo ModeGuided::var_info[] = {
// @Param: _TIMEOUT
// @DisplayName: Guided mode timeout
// @Description: Guided mode timeout after which vehicle will return to guided loiter if no updates are received from caller. Only applicable during any combination of velocity, acceleration, angle control, and/or angular rate control
// @Units: s
// @Range: 0.01 5
// @User: Advanced
AP_GROUPINFO("TIMEOUT", 1, ModeGuided, guided_timeout, 3.0),
AP_GROUPEND
};
ModeGuided::ModeGuided() :
Mode()
{
AP_Param::setup_object_defaults(this, var_info);
}
bool ModeGuided::_enter()
{
plane.guided_throttle_passthru = false;
@ -161,5 +184,5 @@ void ModeGuided::update_target_altitude()
uint32_t ModeGuided::get_timeout_ms() const
{
return constrain_float(plane.g2.guided_timeout, 0.01, 5.0) * 1000;
return constrain_float(guided_timeout, 0.01, 5.0) * 1000;
}