HAL_SITL: support simulator RC input

This commit is contained in:
Andrew Tridgell 2016-05-04 12:50:02 +10:00
parent 3b0cd9f101
commit 9081310ff1
2 changed files with 13 additions and 2 deletions

View File

@ -26,7 +26,10 @@ uint16_t RCInput::read(uint8_t ch)
if (ch >= SITL_RC_INPUT_CHANNELS) {
return 0;
}
return _override[ch]? _override[ch] : _sitlState->pwm_input[ch];
if (_override[ch]) {
return _override[ch];
}
return _sitlState->pwm_input[ch];
}
uint8_t RCInput::read(uint16_t* periods, uint8_t len)
@ -35,7 +38,7 @@ uint8_t RCInput::read(uint16_t* periods, uint8_t len)
len = SITL_RC_INPUT_CHANNELS;
}
for (uint8_t i=0; i<len; i++) {
periods[i] = _override[i]? _override[i] : _sitlState->pwm_input[i];
periods[i] = read(i);
}
return 8;
}

View File

@ -204,6 +204,10 @@ void SITL_State::_fdm_input(void)
uint8_t i;
for (i=0; i<size/2; i++) {
// setup the pwm input for the RC channel inputs
if (i < _sitl->state.rcin_chan_count) {
// we're using rc from simulator
continue;
}
if (pwm_pkt.pwm[i] != 0) {
pwm_input[i] = pwm_pkt.pwm[i];
}
@ -268,6 +272,10 @@ void SITL_State::_fdm_input_local(void)
if (_sitl) {
sitl_model->fill_fdm(_sitl->state);
_sitl->update_rate_hz = sitl_model->get_rate_hz();
for (uint8_t i=0; i< _sitl->state.rcin_chan_count; i++) {
pwm_input[i] = 1000 + _sitl->state.rcin[i]*1000;
}
}
if (gimbal != NULL) {