mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 11:03:33 +08:00
VTOL preserve PWM min and max when enabling/disabling actuators
This commit is contained in:
@@ -48,7 +48,6 @@
|
||||
|
||||
Standard::Standard(VtolAttitudeControl *attc) :
|
||||
VtolType(attc),
|
||||
_flag_enable_mc_motors(true),
|
||||
_pusher_throttle(0.0f),
|
||||
_reverse_output(0.0f),
|
||||
_airspeed_trans_blend_margin(0.0f)
|
||||
@@ -300,11 +299,9 @@ void Standard::update_transition_state()
|
||||
|
||||
}
|
||||
|
||||
// in fw mode we need the multirotor motors to stop spinning, in backtransition mode we let them spin up again
|
||||
// in back transition we need to start the MC motors again
|
||||
if (_flag_enable_mc_motors) {
|
||||
set_max_mc(2000);
|
||||
set_idle_mc();
|
||||
_flag_enable_mc_motors = false;
|
||||
_flag_enable_mc_motors = !enable_mc_motors();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,9 +319,7 @@ void Standard::update_mc_state()
|
||||
|
||||
// enable MC motors here in case we transitioned directly to MC mode
|
||||
if (_flag_enable_mc_motors) {
|
||||
set_max_mc(2000);
|
||||
set_idle_mc();
|
||||
_flag_enable_mc_motors = false;
|
||||
_flag_enable_mc_motors = !enable_mc_motors();
|
||||
}
|
||||
|
||||
// if the thrust scale param is zero or the drone is on manual mode,
|
||||
@@ -403,11 +398,9 @@ void Standard::update_fw_state()
|
||||
{
|
||||
VtolType::update_fw_state();
|
||||
|
||||
// in fw mode we need the multirotor motors to stop spinning, in backtransition mode we let them spin up again
|
||||
// stop MC motors in FW mode
|
||||
if (!_flag_enable_mc_motors) {
|
||||
set_max_mc(950);
|
||||
set_idle_fw(); // force them to stop, not just idle
|
||||
_flag_enable_mc_motors = true;
|
||||
_flag_enable_mc_motors = disable_mc_motors();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -495,36 +488,3 @@ Standard::waiting_on_tecs()
|
||||
// keep thrust from transition
|
||||
_v_att_sp->thrust = _pusher_throttle;
|
||||
};
|
||||
|
||||
/**
|
||||
* Disable all multirotor motors when in fw mode.
|
||||
*/
|
||||
void
|
||||
Standard::set_max_mc(unsigned pwm_value)
|
||||
{
|
||||
int ret;
|
||||
unsigned servo_count;
|
||||
const char *dev = PWM_OUTPUT0_DEVICE_PATH;
|
||||
int fd = px4_open(dev, 0);
|
||||
|
||||
if (fd < 0) {
|
||||
PX4_WARN("can't open %s", dev);
|
||||
}
|
||||
|
||||
ret = px4_ioctl(fd, PWM_SERVO_GET_COUNT, (unsigned long)&servo_count);
|
||||
struct pwm_output_values pwm_values;
|
||||
memset(&pwm_values, 0, sizeof(pwm_values));
|
||||
|
||||
for (int i = 0; i < _params->vtol_motor_count; i++) {
|
||||
pwm_values.values[i] = pwm_value;
|
||||
pwm_values.channel_count = _params->vtol_motor_count;
|
||||
}
|
||||
|
||||
ret = px4_ioctl(fd, PWM_SERVO_SET_MAX_PWM, (long unsigned int)&pwm_values);
|
||||
|
||||
if (ret != OK) {
|
||||
PX4_WARN("failed setting max values");
|
||||
}
|
||||
|
||||
px4_close(fd);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user