mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-01 09:24:10 +01:00
Merge remote-tracking branch 'origin/OP-596_GCSController_output_fix' into next
This commit is contained in:
commit
25fa8746e4
@ -75,8 +75,6 @@ void GCSControlGadget::loadConfiguration(IUAVGadgetConfiguration* config)
|
|||||||
// control_sock->close();
|
// control_sock->close();
|
||||||
control_sock->bind(GCSControlConfig->getUDPControlHost(), GCSControlConfig->getUDPControlPort(),QUdpSocket::ShareAddress);
|
control_sock->bind(GCSControlConfig->getUDPControlHost(), GCSControlConfig->getUDPControlPort(),QUdpSocket::ShareAddress);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
controlsMode = GCSControlConfig->getControlsMode();
|
controlsMode = GCSControlConfig->getControlsMode();
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
@ -102,6 +100,20 @@ void GCSControlGadget::manualControlCommandUpdated(UAVObject * obj) {
|
|||||||
double pitch = obj->getField("Pitch")->getDouble();
|
double pitch = obj->getField("Pitch")->getDouble();
|
||||||
double yaw = obj->getField("Yaw")->getDouble();
|
double yaw = obj->getField("Yaw")->getDouble();
|
||||||
double throttle = obj->getField("Throttle")->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
|
// Remap RPYT to left X/Y and right X/Y depending on mode
|
||||||
switch (controlsMode) {
|
switch (controlsMode) {
|
||||||
case 1:
|
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())
|
if (((GCSControlGadgetWidget *)m_widget)->getGCSControl()==false || ((GCSControlGadgetWidget *)m_widget)->getUDPControl())
|
||||||
return;
|
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((newThrottle != oldThrottle) || (newPitch != oldPitch) || (newYaw != oldYaw) || (newRoll != oldRoll)) {
|
||||||
if (buttonRollControl==0)obj->getField("Roll")->setDouble(newRoll);
|
if (buttonRollControl==0)obj->getField("Roll")->setDouble(newRoll);
|
||||||
if (buttonPitchControl==0)obj->getField("Pitch")->setDouble(newPitch);
|
if (buttonPitchControl==0)obj->getField("Pitch")->setDouble(newPitch);
|
||||||
|
@ -70,9 +70,6 @@ GCSControlGadgetWidget::GCSControlGadgetWidget(QWidget *parent) : QLabel(parent)
|
|||||||
// Connect object updated event from UAVObject to also update check boxes and dropdown
|
// Connect object updated event from UAVObject to also update check boxes and dropdown
|
||||||
connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(mccChanged(UAVObject*)));
|
connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(mccChanged(UAVObject*)));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
leftX = 0;
|
leftX = 0;
|
||||||
leftY = 0;
|
leftY = 0;
|
||||||
rightX = 0;
|
rightX = 0;
|
||||||
@ -129,7 +126,6 @@ void GCSControlGadgetWidget::toggleControl(int state)
|
|||||||
UAVObject::SetGcsTelemetryUpdateMode(mdata, UAVObject::UPDATEMODE_ONCHANGE);
|
UAVObject::SetGcsTelemetryUpdateMode(mdata, UAVObject::UPDATEMODE_ONCHANGE);
|
||||||
mdata.gcsTelemetryUpdatePeriod = 100;
|
mdata.gcsTelemetryUpdatePeriod = 100;
|
||||||
m_gcscontrol->checkBoxUDPControl->setEnabled(true);
|
m_gcscontrol->checkBoxUDPControl->setEnabled(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user