Rover: add STICK_MIXNG param

This commit is contained in:
Tom Pittenger 2019-04-20 16:10:51 -07:00 committed by Tom Pittenger
parent a798f9eb27
commit d1f7485e14
5 changed files with 17 additions and 3 deletions

View File

@ -32,13 +32,11 @@ MAV_MODE GCS_MAVLINK_Rover::base_mode() const
_base_mode |= MAV_MODE_FLAG_GUIDED_ENABLED;
}
#if defined(ENABLE_STICK_MIXING) && (ENABLE_STICK_MIXING == ENABLED) // TODO ???? Remove !
if (control_mode->stick_mixing_enabled()) {
if (rover.g2.stick_mixing > 0 && rover.control_mode != &rover.mode_initializing) {
// all modes except INITIALISING have some form of manual
// override if stick mixing is enabled
_base_mode |= MAV_MODE_FLAG_MANUAL_INPUT_ENABLED;
}
#endif
#if HIL_MODE != HIL_MODE_DISABLED
_base_mode |= MAV_MODE_FLAG_HIL_ENABLED;

View File

@ -701,6 +701,13 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = {
AP_SUBGROUPINFO(scripting, "SCR_", 41, ParametersG2, AP_Scripting),
#endif
// @Param: STICK_MIXING
// @DisplayName: Stick Mixing
// @Description: When enabled, this adds steering user stick input in auto modes, allowing the user to have some degree of control without changing modes.
// @Values: 0:Disabled,1:Enabled
// @User: Advanced
AP_GROUPINFO("STICK_MIXING", 42, ParametersG2, stick_mixing, 0),
AP_GROUPEND
};

View File

@ -397,6 +397,9 @@ public:
// balance both pitch trim
AP_Float bal_pitch_trim;
// stick mixing for auto modes
AP_Int8 stick_mixing;
#ifdef ENABLE_SCRIPTING
AP_Scripting scripting;
#endif // ENABLE_SCRIPTING

View File

@ -557,6 +557,10 @@ void Mode::calc_stopping_location(Location& stopping_loc)
void Mode::set_steering(float steering_value)
{
if (allows_stick_mixing() && g2.stick_mixing > 0) {
steering_value = channel_steer->stick_mixing((int16_t)steering_value);
}
steering_value = constrain_float(steering_value, -4500.0f, 4500.0f);
g2.motors.set_steering(steering_value);
}

View File

@ -73,6 +73,8 @@ public:
// returns true if vehicle can be armed or disarmed from the transmitter in this mode
virtual bool allows_arming_from_transmitter() { return !is_autopilot_mode(); }
bool allows_stick_mixing() const { return is_autopilot_mode(); }
//
// attributes for mavlink system status reporting
//