Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Termit dev #3

Merged
merged 20 commits into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,7 @@ Qt*-linux*.tar.*
# vitepress - user guide
node_modules/
docs/.vitepress/cache/
docs/.vitepress/dist/
docs/.vitepress/dist/

# all zip builds
*.zip
3 changes: 3 additions & 0 deletions custom-example/qgroundcontrol.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<file alias="GPSIndicator.qml">../src/ui/toolbar/GPSIndicator.qml</file>
<file alias="GPSRTKIndicator.qml">../src/ui/toolbar/GPSRTKIndicator.qml</file>
<file alias="JoystickIndicator.qml">../src/ui/toolbar/JoystickIndicator.qml</file>
<file alias="DayLightActions.qml">../src/ui/toolbar/DayLightActions.qml</file>
<file alias="NightLightActions.qml">../src/ui/toolbar/NightLightActions.qml</file>
<file alias="LinkIndicator.qml">../src/ui/toolbar/LinkIndicator.qml</file>
<file alias="MainToolBarIndicators.qml">../src/ui/toolbar/MainToolBarIndicators.qml</file>
<file alias="MessageIndicator.qml">../src/ui/toolbar/MessageIndicator.qml</file>
Expand Down Expand Up @@ -335,6 +337,7 @@
<file alias="Vehicle/EscStatusFactGroup.json">../src/Vehicle/EscStatusFactGroup.json</file>
<file alias="Vehicle/EstimatorStatusFactGroup.json">../src/Vehicle/EstimatorStatusFactGroup.json</file>
<file alias="Vehicle/GPSFact.json">../src/Vehicle/GPSFact.json</file>
<file alias="Vehicle/ServoStatusFactGroup.json">../src/Vehicle/ServoStatusFactGroup.json</file>
<file alias="Vehicle/GPSRTKFact.json">../src/Vehicle/GPSRTKFact.json</file>
<file alias="Vehicle/SetpointFact.json">../src/Vehicle/SetpointFact.json</file>
<file alias="Vehicle/LocalPositionFact.json">../src/Vehicle/LocalPositionFact.json</file>
Expand Down
2 changes: 2 additions & 0 deletions qgcimages.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@
<file alias="HITL.svg">src/AutoPilotPlugins/PX4/Images/HITL.svg</file>
<file alias="Home.svg">src/FlightMap/Images/Home.svg</file>
<file alias="Joystick.png">src/ui/toolbar/Images/Joystick.png</file>
<file alias="SimpleLight.png">src/ui/toolbar/Images/SimpleLight.png</file>
<file alias="NightLight.png">src/ui/toolbar/Images/NightLight.png</file>
<file alias="LandMode.svg">src/AutoPilotPlugins/PX4/Images/LandMode.svg</file>
<file alias="LandModeCopter.svg">src/AutoPilotPlugins/PX4/Images/LandModeCopter.svg</file>
<file alias="LightsComponentIcon.png">src/AutoPilotPlugins/APM/Images/LightsComponentIcon.png</file>
Expand Down
5 changes: 5 additions & 0 deletions qgroundcontrol.pro
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ INCLUDEPATH += \
src/Geo \
src/GPS \
src/Joystick \
src/Servo \
src/PlanView \
src/MissionManager \
src/PositionManager \
Expand Down Expand Up @@ -588,6 +589,7 @@ HEADERS += \
src/Compression/QGCZlib.h \
src/FirmwarePlugin/PX4/px4_custom_mode.h \
src/FollowMe/FollowMe.h \
src/Servo/ServoControl.h \
src/Joystick/Joystick.h \
src/Joystick/JoystickManager.h \
src/Joystick/JoystickMavCommand.h \
Expand Down Expand Up @@ -739,6 +741,7 @@ HEADERS += \
src/Vehicle/VehicleLocalPositionSetpointFactGroup.h \
src/Vehicle/VehicleGPSFactGroup.h \
src/Vehicle/VehicleGPS2FactGroup.h \
src/Vehicle/VehicleServoFactGroup.h \
src/Vehicle/VehicleLinkManager.h \
src/Vehicle/VehicleSetpointFactGroup.h \
src/Vehicle/VehicleTemperatureFactGroup.h \
Expand Down Expand Up @@ -856,6 +859,7 @@ SOURCES += \
src/KMLDomDocument.cc \
src/KMLHelper.cc \
src/LogCompressor.cc \
src/Servo/ServoControl.cc \
src/MissionManager/CameraCalc.cc \
src/MissionManager/CameraSection.cc \
src/MissionManager/CameraSpec.cc \
Expand Down Expand Up @@ -995,6 +999,7 @@ SOURCES += \
src/Vehicle/VehicleEstimatorStatusFactGroup.cc \
src/Vehicle/VehicleLocalPositionFactGroup.cc \
src/Vehicle/VehicleLocalPositionSetpointFactGroup.cc \
src/Vehicle/VehicleServoFactGroup.cc \
src/Vehicle/VehicleGPSFactGroup.cc \
src/Vehicle/VehicleGPS2FactGroup.cc \
src/Vehicle/VehicleLinkManager.cc \
Expand Down
3 changes: 3 additions & 0 deletions qgroundcontrol.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<file alias="GPSIndicator.qml">src/ui/toolbar/GPSIndicator.qml</file>
<file alias="GPSRTKIndicator.qml">src/ui/toolbar/GPSRTKIndicator.qml</file>
<file alias="JoystickIndicator.qml">src/ui/toolbar/JoystickIndicator.qml</file>
<file alias="DayLightActions.qml">src/ui/toolbar/DayLightActions.qml</file>
<file alias="NightLightActions.qml">src/ui/toolbar/NightLightActions.qml</file>
<file alias="LinkIndicator.qml">src/ui/toolbar/LinkIndicator.qml</file>
<file alias="MainToolBarIndicators.qml">src/ui/toolbar/MainToolBarIndicators.qml</file>
<file alias="MessageIndicator.qml">src/ui/toolbar/MessageIndicator.qml</file>
Expand Down Expand Up @@ -336,6 +338,7 @@
<file alias="Vehicle/EscStatusFactGroup.json">src/Vehicle/EscStatusFactGroup.json</file>
<file alias="Vehicle/EstimatorStatusFactGroup.json">src/Vehicle/EstimatorStatusFactGroup.json</file>
<file alias="Vehicle/GPSFact.json">src/Vehicle/GPSFact.json</file>
<file alias="Vehicle/ServoStatusFactGroup.json">src/Vehicle/ServoStatusFactGroup.json</file>
<file alias="Vehicle/GPSRTKFact.json">src/Vehicle/GPSRTKFact.json</file>
<file alias="Vehicle/SetpointFact.json">src/Vehicle/SetpointFact.json</file>
<file alias="Vehicle/LocalPositionFact.json">src/Vehicle/LocalPositionFact.json</file>
Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ add_subdirectory(FlightMap)
add_subdirectory(FollowMe)
add_subdirectory(Geo)
add_subdirectory(GPS)
add_subdirectory(Servo)
add_subdirectory(Joystick)
if (${QGC_GST_MICROHARD_ENABLED})
add_subdirectory(Microhard)
Expand Down Expand Up @@ -178,6 +179,7 @@ target_link_libraries(qgc
Geo
gps
Joystick
ServoControl
MissionManager
PositionManager
QmlControls
Expand Down
3 changes: 3 additions & 0 deletions src/FirmwarePlugin/FirmwarePlugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,13 @@ const QVariantList& FirmwarePlugin::toolIndicators(const Vehicle*)
_toolIndicatorList = QVariantList({
QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/MessageIndicator.qml")),
QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/GPSIndicator.qml")),
QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/JoystickIndicator.qml")),
QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/TelemetryRSSIIndicator.qml")),
QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/RCRSSIIndicator.qml")),
QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/BatteryIndicator.qml")),
QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/RemoteIDIndicator.qml")),
QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/DayLightActions.qml")),
QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/NightLightActions.qml")),
});
}
return _toolIndicatorList;
Expand Down
11 changes: 11 additions & 0 deletions src/FlightDisplay/GuidedActionsController.qml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ Item {
readonly property int actionChangeSpeed: 25
readonly property int actionGripper: 26
readonly property int actionSetHome: 27
readonly property int actionJoystickChangeStatus: 28
readonly property int actionDayLight: 29
readonly property int actionNightLight: 30

property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
property bool _useChecklist: QGroundControl.settingsManager.appSettings.useChecklist.rawValue && QGroundControl.corePlugin.options.preFlightChecklistUrl.toString().length
Expand Down Expand Up @@ -615,6 +618,14 @@ Item {
break
case actionSetHome:
_activeVehicle.doSetHome(actionData)
case actionJoystickChangeStatus:
_activeVehicle.setJoystickEnabled(actionData)
break
case actionDayLight:
_activeVehicle.setDayLightEnabled(actionData)
break
case actionNightLight:
_activeVehicle.setNightLightEnabled(actionData)
break
default:
console.warn(qsTr("Internal error: unknown actionCode"), actionCode)
Expand Down
14 changes: 14 additions & 0 deletions src/Servo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

add_library(ServoControl
ServoControl.cc
ServoControl.h
${EXTRA_SRC}
)

target_link_libraries(ServoControl
PUBLIC
qgc
)

target_include_directories(ServoControl PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

89 changes: 89 additions & 0 deletions src/Servo/ServoControl.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/****************************************************************************
*
* (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/


#include<iostream>
#include "Vehicle.h"
#include "ServoControl.h"

#define SERVO_PWM_ON 2000
#define SERVO_PWM_OFF 1000

#define DAY_LIGHT_SERVO 11
#define NIGHT_LIGHT_SERVO 3


ServoControl::ServoControl(QObject *parent, Vehicle *vehicle)
: QObject(parent), _vehicle(vehicle)
{
}

void ServoControl::setDayLightEnabled(bool enabled, int _defaultComponentId) {
if (!enabled) {
dayLightDisable(_defaultComponentId);
} else {
dayLightEnable(_defaultComponentId);
}
};

void ServoControl::setNightLightEnabled(bool enabled, int _defaultComponentId) {
if (!enabled) {
nightLightDisable(_defaultComponentId);
} else {
nightLightEnable(_defaultComponentId);
}
};

// ----------------------------------------------------------------------------
void ServoControl::dayLightEnable(int _defaultComponentId) {
// _defaultComponentId
_vehicle->sendCommand(
_defaultComponentId,
MAV_CMD_DO_SET_SERVO,
true,
DAY_LIGHT_SERVO,
SERVO_PWM_ON
);
};

// ----------------------------------------------------------------------------
void ServoControl::dayLightDisable(int _defaultComponentId) {
// _defaultComponentId
_vehicle->sendCommand(
_defaultComponentId,
MAV_CMD_DO_SET_SERVO,
true,
DAY_LIGHT_SERVO,
SERVO_PWM_OFF
);
};

// ----------------------------------------------------------------------------
void ServoControl::nightLightEnable(int _defaultComponentId) {
// _defaultComponentId
_vehicle->sendCommand(
_defaultComponentId,
MAV_CMD_DO_SET_SERVO,
true,
NIGHT_LIGHT_SERVO,
SERVO_PWM_ON
);
};

// ----------------------------------------------------------------------------
void ServoControl::nightLightDisable(int _defaultComponentId) {
// _defaultComponentId
_vehicle->sendCommand(
_defaultComponentId,
MAV_CMD_DO_SET_SERVO,
true,
NIGHT_LIGHT_SERVO,
SERVO_PWM_OFF
);
};
37 changes: 37 additions & 0 deletions src/Servo/ServoControl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/****************************************************************************
*
* (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/


#pragma once

#include "QGCLoggingCategory.h"
#include "QGCMAVLink.h"
#include <QString>
#include <QMap>

class Vehicle;

class ServoControl : public QObject
{
Q_OBJECT

public:
ServoControl(QObject* parent, Vehicle* vehicle);

Q_INVOKABLE void setDayLightEnabled(bool, int);
Q_INVOKABLE void setNightLightEnabled(bool, int);

void dayLightEnable(int);
void dayLightDisable(int);
void nightLightEnable(int);
void nightLightDisable(int);
private:
Vehicle* _vehicle;
};

2 changes: 2 additions & 0 deletions src/Vehicle/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ add_library(Vehicle
VehicleLocalPositionSetpointFactGroup.h
VehicleGPSFactGroup.cc
VehicleGPSFactGroup.h
VehicleServoFactGroup.cc
VehicleServoFactGroup.h
VehicleGPS2FactGroup.cc
VehicleGPS2FactGroup.h
VehicleGeneratorFactGroup.cc
Expand Down
19 changes: 19 additions & 0 deletions src/Vehicle/ServoStatusFactGroup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"version": 1,
"fileType": "FactMetaData",
"QGC.MetaData.Facts":
[
{
"name": "dayLight",
"shortDesc": "Status of day light",
"type": "bool",
"default": false
},
{
"name": "nightLight",
"shortDesc": "Status of night light",
"type": "bool",
"default": false
}
]
}
18 changes: 18 additions & 0 deletions src/Vehicle/Vehicle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#include<iostream>

#include <QTime>
#include <QDateTime>
Expand Down Expand Up @@ -99,6 +100,7 @@ const char* Vehicle::_hobbsFactName = "hobbs";
const char* Vehicle::_throttlePctFactName = "throttlePct";
const char* Vehicle::_imuTempFactName = "imuTemp";

const char* Vehicle::_servoFactGroupName = "servo";
const char* Vehicle::_gpsFactGroupName = "gps";
const char* Vehicle::_gps2FactGroupName = "gps2";
const char* Vehicle::_windFactGroupName = "wind";
Expand Down Expand Up @@ -165,6 +167,7 @@ Vehicle::Vehicle(LinkInterface* link,
, _hobbsFact (0, _hobbsFactName, FactMetaData::valueTypeString)
, _throttlePctFact (0, _throttlePctFactName, FactMetaData::valueTypeUint16)
, _imuTempFact (0, _imuTempFactName, FactMetaData::valueTypeInt16)
, _servoFactGroup (this)
, _gpsFactGroup (this)
, _gps2FactGroup (this)
, _windFactGroup (this)
Expand Down Expand Up @@ -316,6 +319,7 @@ Vehicle::Vehicle(MAV_AUTOPILOT firmwareType,
, _hobbsFact (0, _hobbsFactName, FactMetaData::valueTypeString)
, _throttlePctFact (0, _throttlePctFactName, FactMetaData::valueTypeUint16)
, _imuTempFact (0, _imuTempFactName, FactMetaData::valueTypeInt16)
, _servoFactGroup (this)
, _gpsFactGroup (this)
, _gps2FactGroup (this)
, _windFactGroup (this)
Expand Down Expand Up @@ -391,6 +395,7 @@ void Vehicle::_commonInit()
_ftpManager = new FTPManager (this);
_imageProtocolManager = new ImageProtocolManager ();
_vehicleLinkManager = new VehicleLinkManager (this);
_servoControl = new ServoControl (this, this);

connect(_standardModes, &StandardModes::modesUpdated, this, &Vehicle::flightModesChanged);
connect(_standardModes, &StandardModes::modesUpdated, this, [this](){ Vehicle::flightModeChanged(flightMode()); });
Expand Down Expand Up @@ -456,6 +461,7 @@ void Vehicle::_commonInit()
_hobbsFact.setRawValue(QVariant(QString("0000:00:00")));
_addFact(&_hobbsFact, _hobbsFactName);

_addFactGroup(&_servoFactGroup, _servoFactGroupName);
_addFactGroup(&_gpsFactGroup, _gpsFactGroupName);
_addFactGroup(&_gps2FactGroup, _gps2FactGroupName);
_addFactGroup(&_windFactGroup, _windFactGroupName);
Expand Down Expand Up @@ -715,6 +721,8 @@ void Vehicle::_mavlinkMessageReceived(LinkInterface* link, mavlink_message_t mes
case MAVLINK_MSG_ID_GPS_RAW_INT:
_handleGpsRawInt(message);
break;
// case MAVLINK_MSG_ID_SERVO_OUTPUT_RAW:
// _handleServoOutputRaw(message);
case MAVLINK_MSG_ID_GLOBAL_POSITION_INT:
_handleGlobalPositionInt(message);
break;
Expand Down Expand Up @@ -2118,6 +2126,16 @@ void Vehicle::resetErrorLevelMessages()
}
}

void Vehicle::setDayLightEnabled(bool enabled)
{
_servoControl->setDayLightEnabled(enabled, _defaultComponentId);
}

void Vehicle::setNightLightEnabled(bool enabled)
{
_servoControl->setNightLightEnabled(enabled, _defaultComponentId);
}

// this function called in three cases:
// 1. On constructor of vehicle, to see if we should enable a joystick
// 2. When there is a new active joystick
Expand Down
Loading
Loading