From 790637ba007598448b0a5ebab1098c9f6120ec3f Mon Sep 17 00:00:00 2001 From: edouard Date: Mon, 20 Dec 2010 17:30:38 +0000 Subject: [PATCH] GCS Control gadget: invert the sign of pitch which was wrong. Bounding of values to -1/+1 so that it is not possible to put the red dots outside of the picture... git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2261 ebee16cc-31ac-478f-84a7-5cbb03baadba --- .../src/plugins/gcscontrol/gcscontrolgadget.cpp | 16 ++++++++-------- .../src/plugins/gcscontrol/joystickcontrol.cpp | 5 +++++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/ground/src/plugins/gcscontrol/gcscontrolgadget.cpp b/ground/src/plugins/gcscontrol/gcscontrolgadget.cpp index b93e7cbce..602dadb01 100644 --- a/ground/src/plugins/gcscontrol/gcscontrolgadget.cpp +++ b/ground/src/plugins/gcscontrol/gcscontrolgadget.cpp @@ -96,19 +96,19 @@ void GCSControlGadget::manualControlCommandUpdated(UAVObject * obj) { switch (controlsMode) { case 1: // Mode 1: LeftX = Yaw, LeftY = Pitch, RightX = Roll, RightY = Throttle - emit sticksChangedRemotely(yaw,pitch,roll,throttle); + emit sticksChangedRemotely(yaw,-pitch,roll,throttle); break; case 2: // Mode 2: LeftX = Yaw, LeftY = Throttle, RightX = Roll, RightY = Pitch - emit sticksChangedRemotely(yaw,throttle,roll,pitch); + emit sticksChangedRemotely(yaw,throttle,roll,-pitch); break; case 3: // Mode 3: LeftX = Roll, LeftY = Pitch, RightX = Yaw, RightY = Throttle - emit sticksChangedRemotely(roll,pitch,yaw,throttle); + emit sticksChangedRemotely(roll,-pitch,yaw,throttle); break; case 4: // Mode 4: LeftX = Roll, LeftY = Throttle, RightX = Yaw, RightY = Pitch; - emit sticksChangedRemotely(roll,throttle,yaw,pitch); + emit sticksChangedRemotely(roll,throttle,yaw,-pitch); break; } } @@ -133,28 +133,28 @@ void GCSControlGadget::sticksChangedLocally(double leftX, double leftY, double r case 1: // Mode 1: LeftX = Yaw, LeftY = Pitch, RightX = Roll, RightY = Throttle newRoll = rightX; - newPitch = leftY; + newPitch = -leftY; newYaw = leftX; newThrottle = rightY; break; case 2: // Mode 2: LeftX = Yaw, LeftY = Throttle, RightX = Roll, RightY = Pitch newRoll = rightX; - newPitch = rightY; + newPitch = -rightY; newYaw = leftX; newThrottle = leftY; break; case 3: // Mode 3: LeftX = Roll, LeftY = Pitch, RightX = Yaw, RightY = Throttle newRoll = leftX; - newPitch = leftY; + newPitch = -leftY; newYaw = rightX; newThrottle = rightY; break; case 4: // Mode 4: LeftX = Roll, LeftY = Throttle, RightX = Yaw, RightY = Pitch; newRoll = leftX; - newPitch = rightY; + newPitch = -rightY; newYaw = rightX; newThrottle = leftY; break; diff --git a/ground/src/plugins/gcscontrol/joystickcontrol.cpp b/ground/src/plugins/gcscontrol/joystickcontrol.cpp index 5681b0993..4698ebd89 100644 --- a/ground/src/plugins/gcscontrol/joystickcontrol.cpp +++ b/ground/src/plugins/gcscontrol/joystickcontrol.cpp @@ -95,6 +95,11 @@ void JoystickControl::mouseMoveEvent(QMouseEvent *event) double Y = - (point.y() / sceneSize.height() - .5) * 2; double X = (point.x() / sceneSize.width() - .5) * 2; + if (Y<-1) Y = -1; + if (Y> 1) Y = 1; + if (X<-1) X = -1; + if (X> 1) X = 1; + emit positionClicked(X, Y); }