HAL_PX4: prevent uavcan motor spin up while booting

This commit is contained in:
Andrew Tridgell 2015-06-07 09:07:47 +10:00
parent 6a33aeef67
commit d6af9fd0ee
2 changed files with 14 additions and 3 deletions

View File

@ -297,6 +297,12 @@ void PX4RCOutput::_publish_actuators(void)
{ {
struct actuator_direct_s actuators; struct actuator_direct_s actuators;
if (_esc_pwm_min == 0 ||
_esc_pwm_max == 0) {
// not initialised yet
return;
}
actuators.nvalues = _max_channel; actuators.nvalues = _max_channel;
if (actuators.nvalues > actuators.NUM_ACTUATORS_DIRECT) { if (actuators.nvalues > actuators.NUM_ACTUATORS_DIRECT) {
actuators.nvalues = actuators.NUM_ACTUATORS_DIRECT; actuators.nvalues = actuators.NUM_ACTUATORS_DIRECT;
@ -307,9 +313,14 @@ void PX4RCOutput::_publish_actuators(void)
if (actuators.nvalues > 8) { if (actuators.nvalues > 8) {
actuators.nvalues = 8; actuators.nvalues = 8;
} }
bool armed = hal.util->get_soft_armed();
actuators.timestamp = hrt_absolute_time(); actuators.timestamp = hrt_absolute_time();
for (uint8_t i=0; i<actuators.nvalues; i++) { for (uint8_t i=0; i<actuators.nvalues; i++) {
actuators.values[i] = (_period[i] - _esc_pwm_min) / (float)(_esc_pwm_max - _esc_pwm_min); if (!armed) {
actuators.values[i] = 0;
} else {
actuators.values[i] = (_period[i] - _esc_pwm_min) / (float)(_esc_pwm_max - _esc_pwm_min);
}
// actuator values are from -1 to 1 // actuator values are from -1 to 1
actuators.values[i] = actuators.values[i]*2 - 1; actuators.values[i] = actuators.values[i]*2 - 1;
} }

View File

@ -53,8 +53,8 @@ private:
orb_advert_t _actuator_direct_pub = NULL; orb_advert_t _actuator_direct_pub = NULL;
orb_advert_t _actuator_armed_pub = NULL; orb_advert_t _actuator_armed_pub = NULL;
uint16_t _esc_pwm_min = 1000; uint16_t _esc_pwm_min = 0;
uint16_t _esc_pwm_max = 2000; uint16_t _esc_pwm_max = 0;
void _init_alt_channels(void); void _init_alt_channels(void);
void _publish_actuators(void); void _publish_actuators(void);