|
|
|
@ -313,43 +313,89 @@ void AP_MotorsUGV::setup_safety_output()
@@ -313,43 +313,89 @@ void AP_MotorsUGV::setup_safety_output()
|
|
|
|
|
SRV_Channels::set_failsafe_limit(SRV_Channel::k_throttleRight, SRV_Channel::SRV_CHANNEL_LIMIT_ZERO_PWM); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool AP_MotorsUGV::output_test(motor_test_order motor_seq) |
|
|
|
|
// test steering or throttle output as a percentage of the total (range -100 to +100)
|
|
|
|
|
// used in response to DO_MOTOR_TEST mavlink command
|
|
|
|
|
bool AP_MotorsUGV::output_test_pct(motor_test_order motor_seq, float pct) |
|
|
|
|
{ |
|
|
|
|
// check if the motor_seq is valid
|
|
|
|
|
if (motor_seq > THROTTLE_RIGHT) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
_throttle = constrain_float(_throttle, -100.0f, 100.0f); |
|
|
|
|
pct = constrain_float(pct, -100.0f, 100.0f); |
|
|
|
|
|
|
|
|
|
switch (motor_seq) { |
|
|
|
|
case THROTTLE: { |
|
|
|
|
if (!SRV_Channels::function_assigned(SRV_Channel::k_throttle)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
output_throttle(SRV_Channel::k_throttle, pct); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case STEERING: { |
|
|
|
|
if (!SRV_Channels::function_assigned(SRV_Channel::k_steering)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
SRV_Channels::set_output_scaled(SRV_Channel::k_steering, pct * 45.0f); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case THROTTLE_LEFT: { |
|
|
|
|
if (!SRV_Channels::function_assigned(SRV_Channel::k_throttleLeft)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
output_throttle(SRV_Channel::k_throttleLeft, pct); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case THROTTLE_RIGHT: { |
|
|
|
|
if (!SRV_Channels::function_assigned(SRV_Channel::k_throttleRight)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
output_throttle(SRV_Channel::k_throttleRight, pct); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
default: |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
SRV_Channels::calc_pwm(); |
|
|
|
|
hal.rcout->cork(); |
|
|
|
|
SRV_Channels::output_ch_all(); |
|
|
|
|
hal.rcout->push(); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// test steering or throttle output using a pwm value
|
|
|
|
|
bool AP_MotorsUGV::output_test_pwm(motor_test_order motor_seq, float pwm) |
|
|
|
|
{ |
|
|
|
|
// check if the motor_seq is valid
|
|
|
|
|
if (motor_seq > THROTTLE_RIGHT) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
switch (motor_seq) { |
|
|
|
|
case THROTTLE: { |
|
|
|
|
if (!SRV_Channels::function_assigned(SRV_Channel::k_throttle)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
SRV_Channels::set_output_scaled(SRV_Channel::k_throttle, _throttle); |
|
|
|
|
SRV_Channels::set_output_pwm(SRV_Channel::k_throttle, pwm); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case STEERING: { |
|
|
|
|
if (!SRV_Channels::function_assigned(SRV_Channel::k_steering)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
SRV_Channels::set_output_scaled(SRV_Channel::k_steering, _throttle); |
|
|
|
|
SRV_Channels::set_output_pwm(SRV_Channel::k_steering, pwm); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case THROTTLE_LEFT: { |
|
|
|
|
if (!SRV_Channels::function_assigned(SRV_Channel::k_throttleLeft)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
const float motorLeft = brushed_scaler((_throttle * 0.01f), _throttleLeft_servo); |
|
|
|
|
SRV_Channels::set_output_scaled(SRV_Channel::k_throttleLeft, 1000.0f * motorLeft); |
|
|
|
|
SRV_Channels::set_output_pwm(SRV_Channel::k_throttleLeft, pwm); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case THROTTLE_RIGHT: { |
|
|
|
|
if (!SRV_Channels::function_assigned(SRV_Channel::k_throttleRight)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
const float motorRight = brushed_scaler((_throttle * 0.01f), _throttleRight_servo); |
|
|
|
|
SRV_Channels::set_output_scaled(SRV_Channel::k_throttleRight, 1000.0f * motorRight); |
|
|
|
|
SRV_Channels::set_output_pwm(SRV_Channel::k_throttleRight, pwm); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
default: |
|
|
|
@ -360,4 +406,4 @@ bool AP_MotorsUGV::output_test(motor_test_order motor_seq)
@@ -360,4 +406,4 @@ bool AP_MotorsUGV::output_test(motor_test_order motor_seq)
|
|
|
|
|
SRV_Channels::output_ch_all(); |
|
|
|
|
hal.rcout->push(); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|