MAVLink app: better yaw scaling

This commit is contained in:
Lorenz Meier 2015-05-28 11:48:56 -07:00
parent d7547d388f
commit 5ac5fae020
1 changed files with 17 additions and 1 deletions

View File

@ -937,9 +937,25 @@ MavlinkReceiver::handle_message_manual_control(mavlink_message_t *msg)
rc.rc_ppm_frame_length = 0;
rc.input_source = RC_INPUT_SOURCE_MAVLINK;
rc.rssi = RC_INPUT_RSSI_MAX;
/* roll */
rc.values[0] = man.x / 2 + 1500;
/* pitch */
rc.values[1] = man.y / 2 + 1500;
rc.values[2] = man.r / 2 + 1500;
/*
* yaw needs special handling as some joysticks have a circular mechanical mask,
* which makes the corner positions unreachable.
* scale yaw up and clip it to overcome this.
*/
rc.values[2] = man.r / 1.5f + 1500;
if (rc.values[2] > 2000) {
rc.values[2] = 2000;
} else if (rc.values[2] < 1000) {
rc.values[2] = 1000;
}
/* throttle */
rc.values[3] = man.z + 1000;
rc.values[4] = decode_switch_pos_n(man.buttons, 0) * 1000 + 1000;