Commit c862245d authored by Gus Grubba's avatar Gus Grubba

Merge remote-tracking branch 'Mavlink/master' into MavlinkLogUploader

* Mavlink/master:
  Only run unit tests on pull requests
  MAVLink: Update to most recent spec
  PX4 param and airframe metadata update (#4169)
  Don't apply throttle deadband in ThrottleModeDownZero
  Use FTDI driver provided by ftdicjip.com
  AppImage update to libsdl2 (#4155)
  Minor formatting fix
  Added a second polygon. This polygon is updated from the first polygon at each mouse click and is what will ultimately be saved upon completion of drawing.
  Fixed a bug where a black line would be rendered when starting to draw a polygon.
  Fix brand image visibility calculation
  Remove FileManager unit test
  VTOL text change
  Update VTOL command text
  Update message
  Temp removal of Onboard File
  Changing label
  Making deadbands stupid-proof; general cleanup
  Cleanup & Sync
  Implementing throttle axis accumulator with deadband support
  Handle redirects in file downloads
parents dfbaf7f2 5c94cda4
......@@ -174,12 +174,14 @@ script:
#- ccache -s
# unit tests linux/osx
- if [[ "${SPEC}" = "linux-g++-64" && "${CONFIG}" = "debug" ]]; then
mkdir -p ~/.config/QtProject/ && cp ${TRAVIS_BUILD_DIR}/test/qtlogging.ini ~/.config/QtProject/ &&
./debug/QGroundControl --unittest;
elif [[ "${SPEC}" = "macx-clang" && "${CONFIG}" = "debug" ]]; then
mkdir -p ~/Library/Preferences/QtProject/ && cp ${TRAVIS_BUILD_DIR}/test/qtlogging.ini ~/Library/Preferences/QtProject/ &&
./debug/qgroundcontrol.app/Contents/MacOS/QGroundControl --unittest;
- if [ "${TRAVIS_BRANCH}" != "master" ]; then
if [[ "${SPEC}" = "linux-g++-64" && "${CONFIG}" = "debug" ]]; then
mkdir -p ~/.config/QtProject/ && cp ${TRAVIS_BUILD_DIR}/test/qtlogging.ini ~/.config/QtProject/ &&
./debug/QGroundControl --unittest;
elif [[ "${SPEC}" = "macx-clang" && "${CONFIG}" = "debug" ]]; then
mkdir -p ~/Library/Preferences/QtProject/ && cp ${TRAVIS_BUILD_DIR}/test/qtlogging.ini ~/Library/Preferences/QtProject/ &&
./debug/qgroundcontrol.app/Contents/MacOS/QGroundControl --unittest;
fi
fi
after_success:
......
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Everything -->
<!-- Allow anything connected -->
<usb-device />
<!-- 0x26AC / 0x11: PX4 FMU Pixhawk -->
<!--
<usb-device vendor-id="9900" product-id="17" />
-->
<!-- 0x0403 / 0x6001: FTDI FT232R UART -->
<!--
<usb-device vendor-id="1027" product-id="24577" />
-->
<!-- 0x0403 / 0x6015: FTDI FT231X -->
<!--
<usb-device vendor-id="1027" product-id="24597" />
-->
<!-- 0x2341 / Arduino -->
<!--
<usb-device vendor-id="9025" />
-->
<!-- 0x16C0 / 0x0483: Teensyduino -->
<!--
<usb-device vendor-id="5824" product-id="1155" />
-->
<!-- 0x10C4 / 0xEA60: CP210x UART Bridge -->
<!--
<usb-device vendor-id="4292" product-id="60000" />
-->
<!-- 0x067B / 0x2303: Prolific PL2303 -->
<!--
<usb-device vendor-id="1659" product-id="8963" />
-->
</resources>
......@@ -18,6 +18,10 @@
* Project home page: http://code.google.com/p/usb-serial-for-android/
*/
// IMPORTANT NOTE:
// This source has been modified from the original such that testIfSupported only tests for a vendor id
// match. If that matches it allows all product ids through. This provides for better match on unknown boards.
package com.hoho.android.usbserial.driver;
import android.hardware.usb.UsbDevice;
......@@ -230,21 +234,7 @@ public enum UsbSerialProber {
* @param supportedDevices map of vendor IDs to product ID(s)
* @return {@code true} if supported
*/
private static boolean testIfSupported(final UsbDevice usbDevice,
final Map<Integer, int[]> supportedDevices) {
final int[] supportedProducts = supportedDevices.get(
Integer.valueOf(usbDevice.getVendorId()));
if (supportedProducts == null) {
return false;
}
final int productId = usbDevice.getProductId();
for (int supportedProductId : supportedProducts) {
if (productId == supportedProductId) {
return true;
}
}
return false;
private static boolean testIfSupported(final UsbDevice usbDevice, final Map<Integer, int[]> supportedDevices) {
return supportedDevices.containsKey(usbDevice.getVendorId());
}
}
......@@ -68,6 +68,8 @@ public class UsbDeviceJNI extends QtActivity implements TextToSpeech.OnInitListe
private static TextToSpeech m_tts;
private static PowerManager.WakeLock m_wl;
public static Context m_context;
private final static UsbIoManager.Listener m_Listener =
new UsbIoManager.Listener()
{
......@@ -90,6 +92,10 @@ public class UsbDeviceJNI extends QtActivity implements TextToSpeech.OnInitListe
private static native void nativeDeviceException(int userDataA, String messageA);
private static native void nativeDeviceNewData(int userDataA, byte[] dataA);
// Native C++ functions called to log output
public static native void qgcLogDebug(String message);
public static native void qgcLogWarning(String message);
////////////////////////////////////////////////////////////////////////////////////////////////
//
// Constructor. Only used once to create the initial instance for the static functions.
......@@ -252,7 +258,7 @@ public class UsbDeviceJNI extends QtActivity implements TextToSpeech.OnInitListe
tempL = tempL + Integer.toString(deviceL.getVendorId()) + ":";
listL[countL] = tempL;
countL++;
//Log.i(TAG, "Found " + tempL);
qgcLogDebug("Found " + tempL);
}
}
......@@ -273,11 +279,13 @@ public class UsbDeviceJNI extends QtActivity implements TextToSpeech.OnInitListe
// calls like close(), read(), and write().
//
/////////////////////////////////////////////////////////////////////////////////////////////////
public static int open(String nameA, int userDataA)
public static int open(Context parentContext, String nameA, int userDataA)
{
int idL = BAD_PORT;
Log.i(TAG, "Getting device list");
m_context = parentContext;
//qgcLogDebug("Getting device list");
if (!getCurrentDevices())
return BAD_PORT;
......@@ -366,7 +374,7 @@ public class UsbDeviceJNI extends QtActivity implements TextToSpeech.OnInitListe
m_ioManager.remove(idL);
}
Log.e(TAG, "Port open exception");
qgcLogWarning("Port open exception: " + exA.getMessage());
return BAD_PORT;
}
}
......
......@@ -35,7 +35,8 @@ mkdir -p ${APPDIR}
cd ${TMPDIR}
wget -c --quiet http://ftp.us.debian.org/debian/pool/main/u/udev/udev_175-7.2_amd64.deb
wget -c --quiet http://ftp.us.debian.org/debian/pool/main/e/espeak/espeak_1.46.02-2_amd64.deb
wget -c --quiet http://ftp.us.debian.org/debian/pool/main/libs/libsdl1.2/libsdl1.2debian_1.2.15-5_amd64.deb
wget -c --quiet http://ftp.us.debian.org/debian/pool/main/libs/libsdl2/libsdl2-2.0-0_2.0.2%2bdfsg1-6_amd64.deb
cd ${APPDIR}
find ../ -name *.deb -exec dpkg -x {} . \;
......
Subproject commit e93ac62981a338a7c823364e7c4ff1077e3f8fc1
Subproject commit 13a478092fc9c2faa90c553c362e799ba3bad4e8
Subproject commit 36f37bde1df2dd36661fbcbd6ed5aaf0424c8269
Subproject commit 094e765e6353390ac2973023287b7022e696a57e
......@@ -46,10 +46,10 @@
#include <QtAndroidExtras/QtAndroidExtras>
#include <QtAndroidExtras/QAndroidJniObject>
#include <android/log.h>
#include "qserialport_android_p.h"
QGC_LOGGING_CATEGORY(AndroidSerialPortLog, "AndroidSerialPortLog")
QT_BEGIN_NAMESPACE
#define BAD_PORT 0
......@@ -91,6 +91,30 @@ static void jniDeviceException(JNIEnv *envA, jobject thizA, jint userDataA, jstr
}
}
static void jniLogDebug(JNIEnv *envA, jobject thizA, jstring messageA)
{
Q_UNUSED(thizA);
const char *stringL = envA->GetStringUTFChars(messageA, NULL);
QString logMessage = QString::fromUtf8(stringL);
envA->ReleaseStringUTFChars(messageA, stringL);
if (envA->ExceptionCheck())
envA->ExceptionClear();
qCDebug(AndroidSerialPortLog) << logMessage;
}
static void jniLogWarning(JNIEnv *envA, jobject thizA, jstring messageA)
{
Q_UNUSED(thizA);
const char *stringL = envA->GetStringUTFChars(messageA, NULL);
QString logMessage = QString::fromUtf8(stringL);
envA->ReleaseStringUTFChars(messageA, stringL);
if (envA->ExceptionCheck())
envA->ExceptionClear();
qWarning() << logMessage;
}
void cleanJavaException()
{
QAndroidJniEnvironment env;
......@@ -116,13 +140,15 @@ QSerialPortPrivate::QSerialPortPrivate(QSerialPort *q)
void QSerialPortPrivate::setNativeMethods(void)
{
__android_log_print(ANDROID_LOG_INFO, kJTag, "Registering Native Functions");
qCDebug(AndroidSerialPortLog) << "Registering Native Functions";
// REGISTER THE C++ FUNCTION WITH JNI
JNINativeMethod javaMethods[] {
{"nativeDeviceHasDisconnected", "(I)V", reinterpret_cast<void *>(jniDeviceHasDisconnected)},
{"nativeDeviceNewData", "(I[B)V", reinterpret_cast<void *>(jniDeviceNewData)},
{"nativeDeviceException", "(ILjava/lang/String;)V", reinterpret_cast<void *>(jniDeviceException)}
{"nativeDeviceHasDisconnected", "(I)V", reinterpret_cast<void *>(jniDeviceHasDisconnected)},
{"nativeDeviceNewData", "(I[B)V", reinterpret_cast<void *>(jniDeviceNewData)},
{"nativeDeviceException", "(ILjava/lang/String;)V", reinterpret_cast<void *>(jniDeviceException)},
{"qgcLogDebug", "(Ljava/lang/String;)V", reinterpret_cast<void *>(jniLogDebug)},
{"qgcLogWarning", "(Ljava/lang/String;)V", reinterpret_cast<void *>(jniLogWarning)}
};
QAndroidJniEnvironment jniEnv;
......@@ -133,36 +159,36 @@ void QSerialPortPrivate::setNativeMethods(void)
jclass objectClass = jniEnv->FindClass(kJniClassName);
if(!objectClass) {
__android_log_print(ANDROID_LOG_ERROR, kJTag, "Couldn't find class: %s", kJniClassName);
qWarning() << "Couldn't find class:" << kJniClassName;
return;
}
jint val = jniEnv->RegisterNatives(objectClass, javaMethods, sizeof(javaMethods) / sizeof(javaMethods[0]));
__android_log_print(ANDROID_LOG_INFO, kJTag, "Native Functions Registered");
if (val < 0) {
qWarning() << "Error registering methods: " << val;
} else {
qCDebug(AndroidSerialPortLog) << "Native Functions Registered";
}
if (jniEnv->ExceptionCheck()) {
jniEnv->ExceptionDescribe();
jniEnv->ExceptionClear();
}
if (val < 0) {
__android_log_print(ANDROID_LOG_ERROR, kJTag, "Error registering methods");
}
}
bool QSerialPortPrivate::open(QIODevice::OpenMode mode)
{
rwMode = mode;
__android_log_print(ANDROID_LOG_INFO, kJTag, "Opening %s", systemLocation.toLatin1().data());
qCDebug(AndroidSerialPortLog) << "Opening" << systemLocation.toLatin1().data();
__android_log_print(ANDROID_LOG_INFO, kJTag, "Calling Java Open");
QAndroidJniObject jnameL = QAndroidJniObject::fromString(systemLocation);
cleanJavaException();
deviceId = QAndroidJniObject::callStaticMethod<jint>(
kJniClassName,
"open",
"(Ljava/lang/String;I)I",
"(Landroid/content/Context;Ljava/lang/String;I)I",
QtAndroid::androidActivity().object(),
jnameL.object<jstring>(),
(jint)this);
cleanJavaException();
......@@ -171,20 +197,11 @@ bool QSerialPortPrivate::open(QIODevice::OpenMode mode)
if (deviceId == BAD_PORT)
{
__android_log_print(ANDROID_LOG_ERROR, kJTag, "Error opening %s", systemLocation.toLatin1().data());
qWarning() << "Error opening %s" << systemLocation.toLatin1().data();
q_ptr->setError(QSerialPort::DeviceNotFoundError);
return false;
}
__android_log_print(ANDROID_LOG_INFO, kJTag, "Calling Java getDeviceHandle");
cleanJavaException();
descriptor = QAndroidJniObject::callStaticMethod<jint>(
kJniClassName,
"getDeviceHandle",
"(I)I",
deviceId);
cleanJavaException();
if (rwMode == QIODevice::WriteOnly)
stopReadThread();
......@@ -196,7 +213,7 @@ void QSerialPortPrivate::close()
if (deviceId == BAD_PORT)
return;
__android_log_print(ANDROID_LOG_INFO, kJTag, "Closing %s", systemLocation.toLatin1().data());
qCDebug(AndroidSerialPortLog) << "Closing" << systemLocation.toLatin1().data();
cleanJavaException();
jboolean resultL = QAndroidJniObject::callStaticMethod<jboolean>(
kJniClassName,
......
......@@ -49,6 +49,9 @@
#include <QtCore/qstringlist.h>
#include <QtCore/qthread.h>
#include "QGCLoggingCategory.h"
Q_DECLARE_LOGGING_CATEGORY(AndroidSerialPortLog)
QT_BEGIN_NAMESPACE
......
......@@ -104,8 +104,9 @@ SetupPage {
QGCLabel {
anchors.fill: parent
wrapMode: Text.WordWrap
text: qsTr("Clicking “Apply” will save the changes you have made to your airframe configuration. ") +
qsTr("Your vehicle will also be restarted in order to complete the process.")
text: qsTr("Clicking “Apply” will save the changes you have made to your airframe configuration.<br><br>\
All vehicle parameters other than Radio Calibration will be reset.<br><br>\
Your vehicle will also be restarted in order to complete the process.")
}
}
}
......
......@@ -197,7 +197,8 @@ Map {
property alias drawingPolygon: polygonDrawer.hoverEnabled
property bool adjustingPolygon: false
property bool polygonReady: polygonDrawerPolygon.path.length > 3 ///< true: enough points have been captured to create a closed polygon
property bool polygonReady: polygonDrawerPolygonSet.path.length > 2 ///< true: enough points have been captured to create a closed polygon
property bool justClicked: false
property var _callbackObject
......@@ -220,8 +221,7 @@ Map {
return false
}
var polygonPath = polygonDrawerPolygon.path
polygonPath.pop() // get rid of drag coordinate
var polygonPath = polygonDrawerPolygonSet.path
_cancelCapturePolygon()
polygonDrawer._callbackObject.polygonCaptureFinished(polygonPath)
return true
......@@ -322,10 +322,13 @@ Map {
polygonDrawerNextPoint.path = [ bogusCoord, bogusCoord ]
polygonDrawerPolygon.path = [ ]
polygonDrawerNextPoint.path = [ ]
polygonDrawerPolygonSet.path = [ bogusCoord, bogusCoord ]
polygonDrawerPolygonSet.path = [ ]
}
onClicked: {
if (mouse.button == Qt.LeftButton) {
polygonDrawer.justClicked = true
if (polygonDrawerPolygon.path.length > 2) {
// Make sure the new line doesn't intersect the existing polygon
var lastSegment = polygonDrawerPolygon.path.length - 2
......@@ -349,8 +352,7 @@ Map {
// Update finalized coordinate
polygonPath[polygonDrawerPolygon.path.length - 1] = clickCoordinate
}
// Add next drag coordinate
polygonPath.push(clickCoordinate)
polygonDrawerPolygonSet.path = polygonPath
polygonDrawerPolygon.path = polygonPath
} else if (polygonDrawer.polygonReady) {
finishCapturePolygon()
......@@ -360,14 +362,18 @@ Map {
onPositionChanged: {
if (polygonDrawerPolygon.path.length) {
var dragCoordinate = _map.toCoordinate(Qt.point(mouse.x, mouse.y))
var polygonPath = polygonDrawerPolygon.path
if (polygonDrawer.justClicked){
polygonPath.push(dragCoordinate)
polygonDrawer.justClicked = false
}
// Update drag line
polygonDrawerNextPoint.path = [ polygonDrawerPolygon.path[polygonDrawerPolygon.path.length - 2], dragCoordinate ]
// Update drag coordinate
var polygonPath = polygonDrawerPolygon.path
polygonPath[polygonDrawerPolygon.path.length - 1] = dragCoordinate
polygonDrawerPolygon.path = polygonPath
}
}
}
......@@ -377,14 +383,20 @@ Map {
id: polygonDrawerPolygon
color: "blue"
opacity: 0.5
visible: polygonDrawer.drawingPolygon
visible: polygonDrawerPolygon.path.length > 2
}
MapPolygon {
id: polygonDrawerPolygonSet
color: 'green'
opacity: 0.5
visible: polygonDrawer.polygonReady
}
/// Next line for polygon
MapPolyline {
id: polygonDrawerNextPoint
line.color: "green"
line.width: 5
line.width: 3
visible: polygonDrawer.drawingPolygon
}
......
......@@ -23,6 +23,8 @@ const char* Joystick::_calibratedSettingsKey = "Calibrated1"; // Increment
const char* Joystick::_buttonActionSettingsKey = "ButtonActionName%1";
const char* Joystick::_throttleModeSettingsKey = "ThrottleMode";
const char* Joystick::_exponentialSettingsKey = "Exponential";
const char* Joystick::_accumulatorSettingsKey = "Accumulator";
const char* Joystick::_deadbandSettingsKey = "Deadband";
const char* Joystick::_rgFunctionSettingsKey[Joystick::maxFunction] = {
"RollAxis",
......@@ -46,6 +48,8 @@ Joystick::Joystick(const QString& name, int axisCount, int buttonCount, int hatC
, _lastButtonBits(0)
, _throttleMode(ThrottleModeCenterZero)
, _exponential(false)
, _accumulator(false)
, _deadband(false)
, _activeVehicle(NULL)
, _pollingStartedForCalibration(false)
, _multiVehicleManager(multiVehicleManager)
......@@ -86,16 +90,19 @@ void Joystick::_loadSettings(void)
_calibrated = settings.value(_calibratedSettingsKey, false).toBool();
_exponential = settings.value(_exponentialSettingsKey, false).toBool();
_accumulator = settings.value(_accumulatorSettingsKey, false).toBool();
_deadband = settings.value(_deadbandSettingsKey, false).toBool();
_throttleMode = (ThrottleMode_t)settings.value(_throttleModeSettingsKey, ThrottleModeCenterZero).toInt(&convertOk);
badSettings |= !convertOk;
qCDebug(JoystickLog) << "_loadSettings calibrated:throttlemode:exponential:badsettings" << _calibrated << _throttleMode << _exponential << badSettings;
qCDebug(JoystickLog) << "_loadSettings calibrated:throttlemode:exponential:deadband:badsettings" << _calibrated << _throttleMode << _exponential << _deadband << badSettings;
QString minTpl ("Axis%1Min");
QString maxTpl ("Axis%1Max");
QString trimTpl ("Axis%1Trim");
QString revTpl ("Axis%1Rev");
QString deadbndTpl ("Axis%1Deadbnd");
for (int axis=0; axis<_axisCount; axis++) {
Calibration_t* calibration = &_rgCalibration[axis];
......@@ -109,9 +116,13 @@ void Joystick::_loadSettings(void)
calibration->max = settings.value(maxTpl.arg(axis), 32767).toInt(&convertOk);
badSettings |= !convertOk;
calibration->deadband = settings.value(deadbndTpl.arg(axis), 0).toInt(&convertOk);
badSettings |= !convertOk;
calibration->reversed = settings.value(revTpl.arg(axis), false).toBool();
qCDebug(JoystickLog) << "_loadSettings axis:min:max:trim:reversed:badsettings" << axis << calibration->min << calibration->max << calibration->center << calibration->reversed << badSettings;
qCDebug(JoystickLog) << "_loadSettings axis:min:max:trim:reversed:deadband:badsettings" << axis << calibration->min << calibration->max << calibration->center << calibration->reversed << calibration->deadband << badSettings;
}
for (int function=0; function<maxFunction; function++) {
......@@ -145,14 +156,17 @@ void Joystick::_saveSettings(void)
settings.setValue(_calibratedSettingsKey, _calibrated);
settings.setValue(_exponentialSettingsKey, _exponential);
settings.setValue(_accumulatorSettingsKey, _accumulator);
settings.setValue(_deadbandSettingsKey, _deadband);
settings.setValue(_throttleModeSettingsKey, _throttleMode);
qCDebug(JoystickLog) << "_saveSettings calibrated:throttlemode" << _calibrated << _throttleMode;
qCDebug(JoystickLog) << "_saveSettings calibrated:throttlemode:deadband" << _calibrated << _throttleMode << _deadband;
QString minTpl ("Axis%1Min");
QString maxTpl ("Axis%1Max");
QString trimTpl ("Axis%1Trim");
QString revTpl ("Axis%1Rev");
QString deadbndTpl ("Axis%1Deadbnd");
for (int axis=0; axis<_axisCount; axis++) {
Calibration_t* calibration = &_rgCalibration[axis];
......@@ -161,14 +175,16 @@ void Joystick::_saveSettings(void)
settings.setValue(minTpl.arg(axis), calibration->min);
settings.setValue(maxTpl.arg(axis), calibration->max);
settings.setValue(revTpl.arg(axis), calibration->reversed);
settings.setValue(deadbndTpl.arg(axis), calibration->deadband);
qCDebug(JoystickLog) << "_saveSettings name:axis:min:max:trim:reversed"
qCDebug(JoystickLog) << "_saveSettings name:axis:min:max:trim:reversed:deadband"
<< _name
<< axis
<< calibration->min
<< calibration->max
<< calibration->center
<< calibration->reversed;
<< calibration->reversed
<< calibration->deadband;
}
for (int function=0; function<maxFunction; function++) {
......@@ -183,7 +199,7 @@ void Joystick::_saveSettings(void)
}
/// Adjust the raw axis value to the -1:1 range given calibration information
float Joystick::_adjustRange(int value, Calibration_t calibration)
float Joystick::_adjustRange(int value, Calibration_t calibration, bool withDeadbands)
{
float valueNormalized;
float axisLength;
......@@ -199,6 +215,12 @@ float Joystick::_adjustRange(int value, Calibration_t calibration)
axisLength = calibration.center - calibration.min;
}
if (withDeadbands) {
if (valueNormalized>calibration.deadband) valueNormalized-=calibration.deadband;
else if (valueNormalized<-calibration.deadband) valueNormalized+=calibration.deadband;
else valueNormalized = 0.f;
}
float axisPercent = valueNormalized / axisLength;
float correctedValue = axisBasis * axisPercent;
......@@ -208,13 +230,14 @@ float Joystick::_adjustRange(int value, Calibration_t calibration)
}
#if 0
qCDebug(JoystickLog) << "_adjustRange corrected:value:min:max:center:reversed:basis:normalized:length"
qCDebug(JoystickLog) << "_adjustRange corrected:value:min:max:center:reversed:deadband:basis:normalized:length"
<< correctedValue
<< value
<< calibration.min
<< calibration.max
<< calibration.center
<< calibration.center
<< calibration.reversed
<< calibration.deadband
<< axisBasis
<< valueNormalized
<< axisLength;
......@@ -265,16 +288,25 @@ void Joystick::run(void)
if (_calibrationMode != CalibrationModeCalibrating) {
int axis = _rgFunctionAxis[rollFunction];
float roll = _adjustRange(_rgAxisValues[axis], _rgCalibration[axis]);
float roll = _adjustRange(_rgAxisValues[axis], _rgCalibration[axis], _deadband);
axis = _rgFunctionAxis[pitchFunction];
float pitch = _adjustRange(_rgAxisValues[axis], _rgCalibration[axis]);
float pitch = _adjustRange(_rgAxisValues[axis], _rgCalibration[axis], _deadband);
axis = _rgFunctionAxis[yawFunction];
float yaw = _adjustRange(_rgAxisValues[axis], _rgCalibration[axis]);
float yaw = _adjustRange(_rgAxisValues[axis], _rgCalibration[axis],_deadband);
axis = _rgFunctionAxis[throttleFunction];
float throttle = _adjustRange(_rgAxisValues[axis], _rgCalibration[axis]);
float throttle = _adjustRange(_rgAxisValues[axis], _rgCalibration[axis], _throttleMode==ThrottleModeDownZero?false:_deadband);
if ( _accumulator ) {
static float throttle_accu = 0.f;
throttle_accu += throttle*(40/1000.f); //for throttle to change from min to max it will take 1000ms (40ms is a loop time)
throttle_accu = std::max(static_cast<float>(-1.f), std::min(throttle_accu, static_cast<float>(1.f)));
throttle = throttle_accu;
}
float roll_limited = std::max(static_cast<float>(-M_PI_4), std::min(roll, static_cast<float>(M_PI_4)));
float pitch_limited = std::max(static_cast<float>(-M_PI_4), std::min(pitch, static_cast<float>(M_PI_4)));
......@@ -512,6 +544,11 @@ void Joystick::setThrottleMode(int mode)
}
_throttleMode = (ThrottleMode_t)mode;
if (_throttleMode == ThrottleModeDownZero) {
setAccumulator(false);
}
_saveSettings();
emit throttleModeChanged(_throttleMode);
}
......@@ -529,6 +566,31 @@ void Joystick::setExponential(bool expo)
emit exponentialChanged(_exponential);
}
bool Joystick::accumulator(void)
{
return _accumulator;
}
void Joystick::setAccumulator(bool accu)
{
_accumulator = accu;
_saveSettings();
emit accumulatorChanged(_accumulator);
}
bool Joystick::deadband(void)
{
return _deadband;
}
void Joystick::setDeadband(bool deadband)
{
_deadband = deadband;
_saveSettings();
}
void Joystick::startCalibrationMode(CalibrationMode_t mode)
{
if (mode == CalibrationModeOff) {
......
......@@ -34,6 +34,7 @@ public:
int min;
int max;
int center;
int deadband;
bool reversed;
} Calibration_t;
......@@ -65,7 +66,8 @@ public:
Q_INVOKABLE QString getButtonAction(int button);
Q_PROPERTY(int throttleMode READ throttleMode WRITE setThrottleMode NOTIFY throttleModeChanged)
Q_PROPERTY(int exponential READ exponential WRITE setExponential NOTIFY exponentialChanged)
Q_PROPERTY(bool exponential READ exponential WRITE setExponential NOTIFY exponentialChanged)
Q_PROPERTY(bool accumulator READ accumulator WRITE setAccumulator NOTIFY accumulatorChanged)
// Property accessors
......@@ -93,6 +95,12 @@ public:
bool exponential(void);
void setExponential(bool expo);
bool accumulator(void);
void setAccumulator(bool accu);
bool deadband(void);
void setDeadband(bool accu);
typedef enum {
CalibrationModeOff, // Not calibrating
CalibrationModeMonitor, // Monitors are active, continue to send to vehicle if already polling
......@@ -118,6 +126,8 @@ signals:
void exponentialChanged(bool exponential);
void accumulatorChanged(bool accumulator);
void enabledChanged(bool enabled);
/// Signal containing new joystick information
......@@ -133,7 +143,7 @@ signals:
protected:
void _saveSettings(void);
void _loadSettings(void);
float _adjustRange(int value, Calibration_t calibration);
float _adjustRange(int value, Calibration_t calibration, bool withDeadbands);
void _buttonAction(const QString& action);
bool _validAxis(int axis);
bool _validButton(int button);
......@@ -175,6 +185,8 @@ protected:
ThrottleMode_t _throttleMode;
bool _exponential;
bool _accumulator;
bool _deadband;
Vehicle* _activeVehicle;
bool _pollingStartedForCalibration;
......@@ -189,6 +201,8 @@ private:
static const char* _buttonActionSettingsKey;
static const char* _throttleModeSettingsKey;
static const char* _exponentialSettingsKey;
static const char* _accumulatorSettingsKey;
static const char* _deadbandSettingsKey;
};
#endif
......@@ -308,8 +308,8 @@
{
"id": 84,
"rawName": "MAV_CMD_NAV_VTOL_TAKEOFF",
"friendlyName": "VTOL takeoff",
"description": "Takeoff from ground using VTOL mode.",
"friendlyName": "VTOL takeoff and transition",
"description": "Takeoff in VTOL mode, transition to forward flight and fly to the specified location.",
"specifiesCoordinate": true,
"friendlyEdit": true,
"category": "VTOL",
......@@ -323,8 +323,8 @@
{
"id": 85,
"rawName": "MAV_CMD_NAV_VTOL_LAND",
"friendlyName": "VTOL land",
"description": "Land using VTOL mode.",
"friendlyName": "VTOL transition and land",
"description": "Transition to VTOL mode and land.",
"specifiesCoordinate": true,
"friendlyEdit": true,
"category": "VTOL",
......@@ -975,7 +975,7 @@
"id": 3000,
"rawName": "MAV_CMD_DO_VTOL_TRANSITION",
"friendlyName": "VTOL Transition",
"description": "Perform flight mode transition",
"description": "Perform flight mode transition.",
"category": "VTOL",
"param1": {
"label": "Mode:",
......
......@@ -72,7 +72,7 @@ SetupPage {
Item {
property int axisValue: 0
property int deadbandValue: 0
property int __lastAxisValue: 0
readonly property int __axisValueMaxJitter: 100
......@@ -87,6 +87,20 @@ SetupPage {
color: __barColor
}
// Deadband
Rectangle {
id: deadbandBar
anchors.verticalCenter: parent.verticalCenter
x: _deadbandPosition
width: _deadbandWidth
height: parent.height / 2
color: "#8c161a"
property real _percentDeadband: ((2 * deadbandValue) / (32768.0 * 2))
property real _deadbandWidth: parent.width * _percentDeadband
property real _deadbandPosition: (parent.width - _deadbandWidth) / 2
}
// Center point
Rectangle {
anchors.horizontalCenter: parent.horizontalCenter
......@@ -126,13 +140,15 @@ SetupPage {
duration: 1500
}
/*
// Axis value debugger
/*
QGCLabel {
anchors.fill: parent
text: axisValue
}
*/
}
} // Component - axisMonitorDisplayComponent
......@@ -180,6 +196,8 @@ SetupPage {
target: controller
onRollAxisValueChanged: rollLoader.item.axisValue = value
onRollAxisDeadbandChanged: rollLoader.item.deadbandValue = value
}
}
......@@ -210,6 +228,9 @@ SetupPage {
target: controller
onPitchAxisValueChanged: pitchLoader.item.axisValue = value
onPitchAxisDeadbandChanged: pitchLoader.item.deadbandValue = value
}
}
......@@ -240,6 +261,8 @@ SetupPage {
target: controller
onYawAxisValueChanged: yawLoader.item.axisValue = value
onYawAxisDeadbandChanged: yawLoader.item.deadbandValue = value
}
}
......@@ -270,6 +293,8 @@ SetupPage {
target: controller
onThrottleAxisValueChanged: throttleLoader.item.axisValue = value
onThrottleAxisDeadbandChanged: throttleLoader.item.deadbandValue = value
}
}
} // Column - Attitude Control labels
......@@ -382,6 +407,21 @@ SetupPage {
onClicked: _activeJoystick.throttleMode = 0
}
Row {
x: 20
width: parent.width
spacing: ScreenTools.defaultFontPixelWidth
visible: _activeJoystick.throttleMode == 0
QGCCheckBox {
id: accumulator
checked: _activeJoystick.accumulator
text: qsTr("Spring loaded throttle smoothing")
onClicked: _activeJoystick.accumulator = checked
}
}
QGCRadioButton {
exclusiveGroup: throttleModeExclusiveGroup
text: qsTr("Full down stick is zero throttle")
......@@ -435,6 +475,20 @@ SetupPage {
onActivated: _activeVehicle.joystickMode = index
}
}
Row {
width: parent.width
spacing: ScreenTools.defaultFontPixelWidth
visible: advancedSettings.checked
QGCCheckBox {
id: deadband
checked: controller.deadbandToggle
text: qsTr("Deadbands")
onClicked: controller.deadbandToggle = checked
}
}
}
} // Column - left column
......@@ -697,3 +751,5 @@ SetupPage {
} // Item
} // Component - pageComponent
} // SetupPage
......@@ -210,6 +210,18 @@ void JoystickConfigController::cancelButtonClicked(void)
_stopCalibration();
}
bool JoystickConfigController::getDeadbandToggle() {
return _activeJoystick->deadband();
}
void JoystickConfigController::setDeadbandToggle(bool deadband) {
_activeJoystick->setDeadband(deadband);
_signalAllAttiudeValueChanges();
emit deadbandToggled(deadband);
}
void JoystickConfigController::_saveAllTrims(void)
{
// We save all trims as the first step. At this point no axes are mapped but it should still
......@@ -224,16 +236,28 @@ void JoystickConfigController::_saveAllTrims(void)
_advanceState();
}
void JoystickConfigController::_axisDeadbandChanged(int axis, int value)
{
value = abs(value)<_calValidMaxValue?abs(value):_calValidMaxValue;
_rgAxisInfo[axis].deadband = value;
qCDebug(JoystickConfigControllerLog) << "Axis:" << axis << "Deadband:" << _rgAxisInfo[axis].deadband;
}
/// @brief Waits for the sticks to be centered, enabling Next when done.
void JoystickConfigController::_inputCenterWaitBegin(Joystick::AxisFunction_t function, int axis, int value)
{
Q_UNUSED(function);
Q_UNUSED(axis);
Q_UNUSED(value);
// FIXME: Doesn't wait for center
//sensing deadband
if (abs(value)*1.1f>_rgAxisInfo[axis].deadband) { //add 10% on top of existing deadband
_axisDeadbandChanged(axis,abs(value)*1.1f);
}
_nextButton->setEnabled(true);
// FIXME: Doesn't wait for center
}
bool JoystickConfigController::_stickSettleComplete(int axis, int value)
......@@ -420,6 +444,7 @@ void JoystickConfigController::_resetInternalCalibrationValues(void)
struct AxisInfo* info = &_rgAxisInfo[i];
info->function = Joystick::maxFunction;
info->reversed = false;
info->deadband = 0;
info->axisMin = JoystickConfigController::_calCenterPoint;
info->axisMax = JoystickConfigController::_calCenterPoint;
info->axisTrim = JoystickConfigController::_calCenterPoint;
......@@ -457,7 +482,8 @@ void JoystickConfigController::_setInternalCalibrationValuesFromSettings(void)
info->axisMin = calibration.min;
info->axisMax = calibration.max;
info->reversed = calibration.reversed;
info->deadband = calibration.deadband;
qCDebug(JoystickConfigControllerLog) << "Read settings name:axis:min:max:trim:reversed" << joystick->name() << axis << info->axisMin << info->axisMax << info->axisTrim << info->reversed;
}
......@@ -512,6 +538,7 @@ void JoystickConfigController::_validateCalibration(void)
info->axisMin = _calDefaultMinValue;
info->axisMax = _calDefaultMaxValue;
info->axisTrim = info->axisMin + ((info->axisMax - info->axisMin) / 2);
info->deadband = 0;
info->reversed = false;
}
}
......@@ -534,6 +561,7 @@ void JoystickConfigController::_writeCalibration(void)
calibration.min = info->axisMin;
calibration.max = info->axisMax;
calibration.reversed = info->reversed;
calibration.deadband = info->deadband;
joystick->setCalibration(axis, calibration);
}
......@@ -664,6 +692,42 @@ int JoystickConfigController::throttleAxisValue(void)
}
}
int JoystickConfigController::rollAxisDeadband(void)
{
if ((_rgFunctionAxisMapping[Joystick::rollFunction] != _axisNoAxis) && (_activeJoystick->deadband())) {
return _rgAxisInfo[_rgFunctionAxisMapping[Joystick::rollFunction]].deadband;
} else {
return 0;
}
}
int JoystickConfigController::pitchAxisDeadband(void)
{
if ((_rgFunctionAxisMapping[Joystick::pitchFunction] != _axisNoAxis) && (_activeJoystick->deadband())) {
return _rgAxisInfo[_rgFunctionAxisMapping[Joystick::pitchFunction]].deadband;
} else {
return 0;
}
}
int JoystickConfigController::yawAxisDeadband(void)
{
if ((_rgFunctionAxisMapping[Joystick::yawFunction] != _axisNoAxis) && (_activeJoystick->deadband())) {
return _rgAxisInfo[_rgFunctionAxisMapping[Joystick::yawFunction]].deadband;
} else {
return 0;
}
}
int JoystickConfigController::throttleAxisDeadband(void)
{
if ((_rgFunctionAxisMapping[Joystick::throttleFunction] != _axisNoAxis) && (_activeJoystick->deadband())) {
return _rgAxisInfo[_rgFunctionAxisMapping[Joystick::throttleFunction]].deadband;
} else {
return 0;
}
}
bool JoystickConfigController::rollAxisMapped(void)
{
return _rgFunctionAxisMapping[Joystick::rollFunction] != _axisNoAxis;
......@@ -731,6 +795,11 @@ void JoystickConfigController::_signalAllAttiudeValueChanges(void)
emit pitchAxisReversedChanged(pitchAxisReversed());
emit yawAxisReversedChanged(yawAxisReversed());
emit throttleAxisReversedChanged(throttleAxisReversed());
emit rollAxisDeadbandChanged(rollAxisDeadband());
emit pitchAxisDeadbandChanged(pitchAxisDeadband());
emit yawAxisDeadbandChanged(yawAxisDeadband());
emit throttleAxisDeadbandChanged(throttleAxisDeadband());
}
void JoystickConfigController::_activeJoystickChanged(Joystick* joystick)
......
......@@ -51,29 +51,41 @@ public:
Q_PROPERTY(bool pitchAxisMapped READ pitchAxisMapped NOTIFY pitchAxisMappedChanged)
Q_PROPERTY(bool yawAxisMapped READ yawAxisMapped NOTIFY yawAxisMappedChanged)
Q_PROPERTY(bool throttleAxisMapped READ throttleAxisMapped NOTIFY throttleAxisMappedChanged)
Q_PROPERTY(int rollAxisValue READ rollAxisValue NOTIFY rollAxisValueChanged)
Q_PROPERTY(int pitchAxisValue READ pitchAxisValue NOTIFY pitchAxisValueChanged)
Q_PROPERTY(int yawAxisValue READ yawAxisValue NOTIFY yawAxisValueChanged)
Q_PROPERTY(int throttleAxisValue READ throttleAxisValue NOTIFY throttleAxisValueChanged)
Q_PROPERTY(int rollAxisDeadband READ rollAxisDeadband NOTIFY rollAxisDeadbandChanged)
Q_PROPERTY(int pitchAxisDeadband READ pitchAxisDeadband NOTIFY pitchAxisDeadbandChanged)
Q_PROPERTY(int yawAxisDeadband READ yawAxisDeadband NOTIFY yawAxisDeadbandChanged)
Q_PROPERTY(int throttleAxisDeadband READ throttleAxisDeadband NOTIFY throttleAxisDeadbandChanged)
Q_PROPERTY(int rollAxisReversed READ rollAxisReversed NOTIFY rollAxisReversedChanged)
Q_PROPERTY(int pitchAxisReversed READ pitchAxisReversed NOTIFY pitchAxisReversedChanged)
Q_PROPERTY(int yawAxisReversed READ yawAxisReversed NOTIFY yawAxisReversedChanged)
Q_PROPERTY(int throttleAxisReversed READ throttleAxisReversed NOTIFY throttleAxisReversedChanged)
Q_PROPERTY(bool deadbandToggle READ getDeadbandToggle WRITE setDeadbandToggle NOTIFY deadbandToggled)
Q_PROPERTY(QString imageHelp MEMBER _imageHelp NOTIFY imageHelpChanged)
Q_INVOKABLE void cancelButtonClicked(void);
Q_INVOKABLE void skipButtonClicked(void);
Q_INVOKABLE void nextButtonClicked(void);
Q_INVOKABLE void start(void);
int rollAxisValue(void);
int pitchAxisValue(void);
int yawAxisValue(void);
int throttleAxisValue(void);
int rollAxisDeadband(void);
int pitchAxisDeadband(void);
int yawAxisDeadband(void);
int throttleAxisDeadband(void);
bool rollAxisMapped(void);
bool pitchAxisMapped(void);
bool yawAxisMapped(void);
......@@ -84,11 +96,14 @@ public:
bool yawAxisReversed(void);
bool throttleAxisReversed(void);
bool getDeadbandToggle(void);
void setDeadbandToggle(bool);
int axisCount(void);
signals:
void axisValueChanged(int axis, int value);
void rollAxisMappedChanged(bool mapped);
void pitchAxisMappedChanged(bool mapped);
void yawAxisMappedChanged(bool mapped);
......@@ -98,11 +113,18 @@ signals:
void pitchAxisValueChanged(int value);
void yawAxisValueChanged(int value);
void throttleAxisValueChanged(int value);
void rollAxisDeadbandChanged(int value);
void pitchAxisDeadbandChanged(int value);
void yawAxisDeadbandChanged(int value);
void throttleAxisDeadbandChanged(int value);
void rollAxisReversedChanged(bool reversed);
void pitchAxisReversedChanged(bool reversed);
void yawAxisReversedChanged(bool reversed);
void throttleAxisReversedChanged(bool reversed);
void deadbandToggled(bool value);
void imageHelpChanged(QString source);
......@@ -112,6 +134,7 @@ signals:
private slots:
void _activeJoystickChanged(Joystick* joystick);
void _axisValueChanged(int axis, int value);
void _axisDeadbandChanged(int axis, int value);
private:
/// @brief The states of the calibration state machine.
......@@ -144,6 +167,7 @@ private:
int axisMin; ///< Minimum axis value
int axisMax; ///< Maximum axis value
int axisTrim; ///< Trim position
int deadband; ///< Deadband
};
Joystick* _activeJoystick;
......
......@@ -47,7 +47,6 @@ UT_REGISTER_TEST(MissionControllerTest)
UT_REGISTER_TEST(MissionManagerTest)
UT_REGISTER_TEST(RadioConfigTest)
UT_REGISTER_TEST(TCPLinkTest)
UT_REGISTER_TEST(FileManagerTest)
UT_REGISTER_TEST(ParameterManagerTest)
UT_REGISTER_TEST(MissionCommandTreeTest)
UT_REGISTER_TEST(LogDownloadTest)
......@@ -58,3 +57,6 @@ UT_REGISTER_TEST(LogDownloadTest)
// FIXME: Temporarily disabled until this can be stabilized
//UT_REGISTER_TEST(MainWindowTest)
// Onboard file support has been removed until it can be make to work correctly
//UT_REGISTER_TEST(FileManagerTest)
......@@ -301,12 +301,17 @@ void MainWindow::_buildCommonWidgets(void)
logPlayer = new QGCMAVLinkLogPlayer(statusBar());
statusBar()->addPermanentWidget(logPlayer);
// Populate widget menu
for (int i = 0, end = ARRAY_SIZE(rgDockWidgetNames); i < end; i++) {
if (i == ONBOARD_FILES) {
// Temporarily removed until twe can fix all the problems with it
continue;
}
const char* pDockWidgetName = rgDockWidgetNames[i];
// Add to menu
QAction* action = new QAction(tr(pDockWidgetName), this);
QAction* action = new QAction(pDockWidgetName, this);
action->setCheckable(true);
action->setData(i);
connect(action, &QAction::triggered, this, &MainWindow::_showDockWidgetAction);
......@@ -318,6 +323,11 @@ void MainWindow::_buildCommonWidgets(void)
/// Shows or hides the specified dock widget, creating if necessary
void MainWindow::_showDockWidget(const QString& name, bool show)
{
if (name == rgDockWidgetNames[ONBOARD_FILES]) {
// Temporarily disabled due to bugs
return;
}
// Create the inner widget if we need to
if (!_mapName2DockWidget.contains(name)) {
if(!_createInnerDockWidget(name)) {
......
......@@ -393,6 +393,7 @@ Rectangle {
property bool vehicleConnectionLost: activeVehicle ? activeVehicle.connectionLost : false
Loader {
id: indicatorLoader
source: activeVehicle && !parent.vehicleConnectionLost ? "MainToolBarIndicators.qml" : ""
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
......@@ -408,7 +409,6 @@ Rectangle {
anchors.right: disconnectButton.left
anchors.verticalCenter: parent.verticalCenter
visible: parent.vehicleConnectionLost
}
QGCButton {
......@@ -427,7 +427,7 @@ Rectangle {
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: parent.bottom
visible: parent.x < x && !disconnectButton.visible && source != ""
visible: x > indicatorLoader.x + indicatorLoader.width && !disconnectButton.visible && source != ""
fillMode: Image.PreserveAspectFit
source: activeVehicle ? activeVehicle.brandImage : ""
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment