@@ -37,6 +37,7 @@ This file is part of the PIXHAWK project
*
* @author Lorenz Meier <mavteam@student.ethz.ch>
* @author Andreas Romer <mavteam@student.ethz.ch>
* @author Julian Oes <julian@oes.ch>
*/
#ifndef _JOYSTICKINPUT_H_
...
...
@@ -56,6 +57,8 @@ This file is part of the PIXHAWK project
structJoystickSettings{
QMap<int,bool>axesInverted;///< Whether each axis should be used inverted from what was reported.
QMap<int,bool>axesLimited;///< Whether each axis should be limited to only the positive range. Currently this only applies to the throttle axis, but is kept generic here to possibly support other axes.
QMap<int,float>axesMaxRange;///< The maximum values per axis
QMap<int,float>axesMinRange;///< The minimum values per axis
QMap<int,int>buttonActions;///< The index of the action associated with every button.
};
Q_DECLARE_METATYPE(JoystickSettings)
...
...
@@ -86,6 +89,19 @@ public:
JOYSTICK_INPUT_MAPPING_THROTTLE=4
};
/**
* @brief The JOYSTICK_MODE enum stores the values for each item in the mode combobox.
* This should match the order of items in the mode combobox in JoystickWidget.ui.
*/
enumJOYSTICK_MODE
{
JOYSTICK_MODE_ATTITUDE=0,
JOYSTICK_MODE_POSITION=1,
JOYSTICK_MODE_FORCE=2,
JOYSTICK_MODE_VELOCITY=3,
JOYSTICK_MODE_MANUAL=4
};
/**
* @brief Load joystick-specific settings.
*/
...
...
@@ -109,6 +125,11 @@ public:
returnisEnabled;
}
boolcalibrating()const
{
returnisCalibrating;
}
intgetMappingThrottleAxis()const
{
returnthrottleAxis;
...
...
@@ -154,6 +175,11 @@ public:
returnnumJoysticks;
}
JOYSTICK_MODEgetMode()const
{
returnmode;
}
QStringgetJoystickNameById(intid)const
{
returnQString(SDL_JoystickName(id));
...
...
@@ -162,16 +188,17 @@ public:
floatgetCurrentValueForAxis(intaxis)const;
boolgetInvertedForAxis(intaxis)const;
boolgetRangeLimitForAxis(intaxis)const;
floatgetAxisRangeLimitMinForAxis(intaxis)const;
floatgetAxisRangeLimitMaxForAxis(intaxis)const;
intgetActionForButton(intbutton)const;
constdoublesdlJoystickMin;
constdoublesdlJoystickMax;
protected:
doublecalibrationPositive[10];
doublecalibrationNegative[10];
boolisEnabled;///< Track whether the system should emit the higher-level signals: joystickChanged & actionTriggered.
boolisCalibrating;///< Track if calibration in progress
booldone;
SDL_Joystick*joystick;
...
...
@@ -194,6 +221,9 @@ protected:
intjoystickNumAxes;
intjoystickNumButtons;
// mode of joystick (attitude, position, force, ... (see JOYSTICK_MODE enum))
JOYSTICK_MODEmode;
// Track axis/button settings based on a Joystick/AutopilotType/SystemType triplet.
// This is only a double-map, because settings are stored/loaded based on joystick
// name first, so only the settings for the current joystick need to be stored at any given time.
...
...
@@ -223,8 +253,9 @@ signals:
* @param throttle Throttle, -100%:-1.0, 0%: 0.0, 100%: 1.0. If the roll axis isn't defined, NaN is transmit instead.
* @param xHat hat vector in forward-backward direction, +1 forward, 0 center, -1 backward
* @param yHat hat vector in left-right direction, -1 left, 0 center, +1 right
* @param mode (setpoint type) see JOYSTICK_MODE enum