1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

OP-596 - GCSController output Fix

The GCSController widget now outputs the correct throttle range (0..1) on the ManualControlCommand.Throttle.

(Also, some empty lines cleaning.)
This commit is contained in:
Nuno Guedes 2013-04-20 16:48:23 +01:00
parent 5e942bbd6d
commit 8fef89d55c
2 changed files with 7 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,10 @@ void GCSControlGadget::manualControlCommandUpdated(UAVObject * obj) {
double pitch = obj->getField("Pitch")->getDouble();
double yaw = obj->getField("Yaw")->getDouble();
double throttle = obj->getField("Throttle")->getDouble();
if (throttle >= -1.0 && throttle <= 1.0) // necessary against incorect values from not configured joysticks
throttle = -1.0 + (throttle * 2.0); // convert ManualControlCommand.Throttle range (0..1) to the widget's throttle stick range (-1..+1)
// Remap RPYT to left X/Y and right X/Y depending on mode
switch (controlsMode) {
case 1:
@ -187,6 +189,9 @@ void GCSControlGadget::sticksChangedLocally(double leftX, double leftY, double r
if (((GCSControlGadgetWidget *)m_widget)->getGCSControl()==false || ((GCSControlGadgetWidget *)m_widget)->getUDPControl())
return;
if (newThrottle != oldThrottle)
newThrottle = (newThrottle+1.0)/2.0; // convert widget's throttle stick range (-1..+1) to ManualControlCommand.Throttle range (0..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
{