diff --git a/libraries/AP_Motors/AP_MotorsMulticopter.cpp b/libraries/AP_Motors/AP_MotorsMulticopter.cpp index 0e057f7158..43dcde6257 100644 --- a/libraries/AP_Motors/AP_MotorsMulticopter.cpp +++ b/libraries/AP_Motors/AP_MotorsMulticopter.cpp @@ -162,6 +162,14 @@ const AP_Param::GroupInfo AP_MotorsMulticopter::var_info[] = { // @Increment: 0.1 // @User: Advanced AP_GROUPINFO("SPOOL_TIME", 36, AP_MotorsMulticopter, _spool_up_time, AP_MOTORS_SPOOL_UP_TIME_DEFAULT), + + // @Param: BOOST_SCALE + // @DisplayName: Motor boost scale + // @Description: This is a scaling factor for vehicles with a vertical booster motor used for extra lift. It is used with electric multicopters that have an internal combusion booster motor for longer endurance. The output to the BoostThrottle servo function is set to the current motor thottle times this scaling factor. A higher scaling factor will put more of the load on the booster motor. A value of 1 will set the BoostThrottle equal to the main throttle. + // @Range: 0 5 + // @Increment: 0.1 + // @User: Advanced + AP_GROUPINFO("BOOST_SCALE", 37, AP_MotorsMulticopter, _boost_scale, 0), AP_GROUPEND }; @@ -217,8 +225,21 @@ void AP_MotorsMulticopter::output() // convert rpy_thrust values to pwm output_to_motors(); + + // output any booster throttle + output_boost_throttle(); }; +// output booster throttle, if any +void AP_MotorsMulticopter::output_boost_throttle(void) +{ + if (_boost_scale > 0) { + float throttle = constrain_float(get_throttle() * _boost_scale, 0, 1); + SRV_Channels::set_output_scaled(SRV_Channel::k_boost_throttle, throttle*1000); + } +} + + // sends minimum values out to the motors void AP_MotorsMulticopter::output_min() { diff --git a/libraries/AP_Motors/AP_MotorsMulticopter.h b/libraries/AP_Motors/AP_MotorsMulticopter.h index e9ec1ae08a..ebc4619acc 100644 --- a/libraries/AP_Motors/AP_MotorsMulticopter.h +++ b/libraries/AP_Motors/AP_MotorsMulticopter.h @@ -137,6 +137,9 @@ protected: // apply any thrust compensation for the frame virtual void thrust_compensation(void) {} + // output booster throttle, if any + virtual void output_boost_throttle(void); + // save parameters as part of disarming void save_params_on_disarm(); @@ -168,6 +171,9 @@ protected: // time to spool motors to min throttle AP_Float _spool_up_time; + + // scaling for booster motor throttle + AP_Float _boost_scale; // motor output variables bool motor_enabled[AP_MOTORS_MAX_NUM_MOTORS]; // true if motor is enabled