1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

Merge remote-tracking branch 'origin/OP-596_GCSController_output_fix' into next

This commit is contained in:
Fredrik Arvidsson 2013-05-05 18:59:49 +02:00
commit 25fa8746e4
2 changed files with 25 additions and 6 deletions

View File

@ -75,8 +75,6 @@ void GCSControlGadget::loadConfiguration(IUAVGadgetConfiguration* config)
// control_sock->close();
control_sock->bind(GCSControlConfig->getUDPControlHost(), GCSControlConfig->getUDPControlPort(),QUdpSocket::ShareAddress);
controlsMode = GCSControlConfig->getControlsMode();
int i;
@ -102,6 +100,20 @@ void GCSControlGadget::manualControlCommandUpdated(UAVObject * obj) {
double pitch = obj->getField("Pitch")->getDouble();
double yaw = obj->getField("Yaw")->getDouble();
double throttle = obj->getField("Throttle")->getDouble();
// necessary against having the wrong joystick profile chosen, which shows weird values
if (throttle > -1.0 && throttle <= 1.0) {
// convert ManualControlCommand.Throttle range (0..1) to the widget's throttle stick range (-1..+1)
throttle = -1.0 + (throttle * 2.0);
} else {
// with the safety value (line 206), this helps keep the sticks insde the margins
if (throttle <= -1.0) {
throttle = -1.0;
} else {
throttle = 1.0;
}
}
// Remap RPYT to left X/Y and right X/Y depending on mode
switch (controlsMode) {
case 1:
@ -187,6 +199,17 @@ void GCSControlGadget::sticksChangedLocally(double leftX, double leftY, double r
if (((GCSControlGadgetWidget *)m_widget)->getGCSControl()==false || ((GCSControlGadgetWidget *)m_widget)->getUDPControl())
return;
//if (newThrottle != oldThrottle) {
// convert widget's throttle stick range (-1..+1) to ManualControlCommand.Throttle range (0..1)
newThrottle = (newThrottle + 1.0) / 2.0;
// safety value to stop the motors from spinning at 0% throttle
if (newThrottle <= 0.01 ) {
newThrottle = -1;
}
//}
if((newThrottle != oldThrottle) || (newPitch != oldPitch) || (newYaw != oldYaw) || (newRoll != oldRoll)) {
if (buttonRollControl==0)obj->getField("Roll")->setDouble(newRoll);
if (buttonPitchControl==0)obj->getField("Pitch")->setDouble(newPitch);

View File

@ -70,9 +70,6 @@ GCSControlGadgetWidget::GCSControlGadgetWidget(QWidget *parent) : QLabel(parent)
// Connect object updated event from UAVObject to also update check boxes and dropdown
connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(mccChanged(UAVObject*)));
leftX = 0;
leftY = 0;
rightX = 0;
@ -129,7 +126,6 @@ void GCSControlGadgetWidget::toggleControl(int state)
UAVObject::SetGcsTelemetryUpdateMode(mdata, UAVObject::UPDATEMODE_ONCHANGE);
mdata.gcsTelemetryUpdatePeriod = 100;
m_gcscontrol->checkBoxUDPControl->setEnabled(true);
}
else
{