1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

OP-1122 OP-1158 - renamed uavobject FlightPlan to PathPlan

+review OPReview-609
This commit is contained in:
Philippe Renon 2014-01-13 22:21:34 +01:00
parent 76ee48bc44
commit 7f2c24db2b
8 changed files with 74 additions and 74 deletions

View File

@ -31,7 +31,7 @@
#include "openpilot.h"
#include "flightplan.h"
#include "pathplan.h"
#include "flightstatus.h"
#include "airspeedstate.h"
#include "pathaction.h"
@ -60,7 +60,7 @@ static void statusUpdated(UAVObjEvent *ev);
static void updatePathDesired();
static void setWaypoint(uint16_t num);
static uint8_t checkFlightPlan();
static uint8_t checkPathPlan();
static uint8_t pathConditionCheck();
static uint8_t conditionNone();
static uint8_t conditionTimeOut();
@ -105,7 +105,7 @@ int32_t PathPlannerStart()
*/
int32_t PathPlannerInitialize()
{
FlightPlanInitialize();
PathPlanInitialize();
PathActionInitialize();
PathStatusInitialize();
PathDesiredInitialize();
@ -132,16 +132,16 @@ static void pathPlannerTask()
bool endCondition = false;
// check flight plan validity early to raise alarm
// check path plan validity early to raise alarm
// even if not in guided mode
uint8_t validFlightPlan = checkFlightPlan();
uint8_t validPathPlan = checkPathPlan();
FlightStatusData flightStatus;
FlightStatusGet(&flightStatus);
if (flightStatus.FlightMode != FLIGHTSTATUS_FLIGHTMODE_PATHPLANNER) {
pathplanner_active = false;
if (!validFlightPlan) {
// unverified flight plans are only a warning while we are not in pathplanner mode
if (!validPathPlan) {
// unverified path plans are only a warning while we are not in pathplanner mode
// so it does not prevent arming. However manualcontrols safety check
// shall test for this warning when pathplan is on the flight mode selector
// thus a valid flight plan is a prerequirement for arming
@ -157,7 +157,7 @@ static void pathPlannerTask()
PathDesiredGet(&pathDesired);
static uint8_t failsafeRTHset = 0;
if (!validFlightPlan) {
if (!validPathPlan) {
// At this point the craft is in PathPlanner mode, so pilot has no manual control capability.
// Failsafe: behave as if in return to base mode
// what to do in this case is debatable, it might be better to just
@ -258,18 +258,18 @@ static void pathPlannerTask()
}
// safety check for path plan integrity
static uint8_t checkFlightPlan()
static uint8_t checkPathPlan()
{
uint16_t i;
uint16_t waypointCount;
uint16_t actionCount;
uint8_t flightCrc;
FlightPlanData flightPlan;
uint8_t pathCrc;
PathPlanData pathPlan;
FlightPlanGet(&flightPlan);
PathPlanGet(&pathPlan);
waypointCount = flightPlan.WaypointCount;
actionCount = flightPlan.PathActionCount;
waypointCount = pathPlan.WaypointCount;
actionCount = pathPlan.PathActionCount;
// check count consistency
if (waypointCount > UAVObjGetNumInstances(WaypointHandle())) {
@ -282,20 +282,20 @@ static uint8_t checkFlightPlan()
}
// check CRC
flightCrc = 0;
pathCrc = 0;
for (i = 0; i < waypointCount; i++) {
flightCrc = UAVObjUpdateCRC(WaypointHandle(), i, flightCrc);
pathCrc = UAVObjUpdateCRC(WaypointHandle(), i, pathCrc);
}
for (i = 0; i < actionCount; i++) {
flightCrc = UAVObjUpdateCRC(PathActionHandle(), i, flightCrc);
pathCrc = UAVObjUpdateCRC(PathActionHandle(), i, pathCrc);
}
if (flightCrc != flightPlan.Crc) {
PIOS_DEBUGLOG_Printf("FlighPlan : bad CRC (%d / %d)!", flightCrc, flightPlan.Crc);
if (pathCrc != pathPlan.Crc) {
PIOS_DEBUGLOG_Printf("FlighPlan : bad CRC (%d / %d)!", pathCrc, pathPlan.Crc);
return false;
}
// everything ok (hopefully...)
PIOS_DEBUGLOG_Printf("FlighPlan : passed consistency check.", flightCrc, flightPlan.Crc);
PIOS_DEBUGLOG_Printf("FlighPlan : passed consistency check.", pathCrc, pathPlan.Crc);
return true;
}
@ -368,12 +368,12 @@ void updatePathDesired()
// helper function to go to a specific waypoint
static void setWaypoint(uint16_t num)
{
FlightPlanData flightPlan;
PathPlanData pathPlan;
FlightPlanGet(&flightPlan);
PathPlanGet(&pathPlan);
// here it is assumed that the flight plan has been validated (waypoint count is consistent)
if (num >= flightPlan.WaypointCount) {
// here it is assumed that the path plan has been validated (waypoint count is consistent)
if (num >= pathPlan.WaypointCount) {
// path plans wrap around
num = 0;
}

View File

@ -43,7 +43,6 @@ UAVOBJSRCFILENAMES += debuglogentry
UAVOBJSRCFILENAMES += flightbatterysettings
UAVOBJSRCFILENAMES += firmwareiapobj
UAVOBJSRCFILENAMES += flightbatterystate
UAVOBJSRCFILENAMES += flightplan
UAVOBJSRCFILENAMES += flightplancontrol
UAVOBJSRCFILENAMES += flightplansettings
UAVOBJSRCFILENAMES += flightplanstatus
@ -71,6 +70,7 @@ UAVOBJSRCFILENAMES += overosyncstats
UAVOBJSRCFILENAMES += overosyncsettings
UAVOBJSRCFILENAMES += pathaction
UAVOBJSRCFILENAMES += pathdesired
UAVOBJSRCFILENAMES += pathplan
UAVOBJSRCFILENAMES += pathstatus
UAVOBJSRCFILENAMES += positionstate
UAVOBJSRCFILENAMES += ratedesired

View File

@ -44,7 +44,6 @@ UAVOBJSRCFILENAMES += airspeedstate
UAVOBJSRCFILENAMES += flightbatterysettings
UAVOBJSRCFILENAMES += firmwareiapobj
UAVOBJSRCFILENAMES += flightbatterystate
UAVOBJSRCFILENAMES += flightplan
UAVOBJSRCFILENAMES += flightplancontrol
UAVOBJSRCFILENAMES += flightplansettings
UAVOBJSRCFILENAMES += flightplanstatus
@ -71,6 +70,7 @@ UAVOBJSRCFILENAMES += overosyncstats
UAVOBJSRCFILENAMES += overosyncsettings
UAVOBJSRCFILENAMES += pathaction
UAVOBJSRCFILENAMES += pathdesired
UAVOBJSRCFILENAMES += pathplan
UAVOBJSRCFILENAMES += pathstatus
UAVOBJSRCFILENAMES += positionstate
UAVOBJSRCFILENAMES += ratedesired

View File

@ -41,32 +41,32 @@ ModelUavoProxy::ModelUavoProxy(QObject *parent, flightDataModel *model) : QObjec
successCountdown = 0;
}
void ModelUavoProxy::sendFlightPlan()
void ModelUavoProxy::sendPathPlan()
{
modelToObjects();
FlightPlan *flightPlan = FlightPlan::GetInstance(objMngr, 0);
connect(flightPlan, SIGNAL(transactionCompleted(UAVObject *, bool)),
this, SLOT(flightPlanElementSent(UAVObject *, bool)), Qt::UniqueConnection);
PathPlan *pathPlan = PathPlan::GetInstance(objMngr, 0);
connect(pathPlan, SIGNAL(transactionCompleted(UAVObject *, bool)),
this, SLOT(pathPlanElementSent(UAVObject *, bool)), Qt::UniqueConnection);
Waypoint *waypoint = Waypoint::GetInstance(objMngr, 0);
connect(waypoint, SIGNAL(transactionCompleted(UAVObject *, bool)),
this, SLOT(flightPlanElementSent(UAVObject *, bool)), Qt::UniqueConnection);
this, SLOT(pathPlanElementSent(UAVObject *, bool)), Qt::UniqueConnection);
PathAction *action = PathAction::GetInstance(objMngr, 0);
connect(action, SIGNAL(transactionCompleted(UAVObject *, bool)),
this, SLOT(flightPlanElementSent(UAVObject *, bool)), Qt::UniqueConnection);
this, SLOT(pathPlanElementSent(UAVObject *, bool)), Qt::UniqueConnection);
// we will start 3 update all
completionCountdown = 3;
successCountdown = completionCountdown;
flightPlan->updated();
pathPlan->updated();
waypoint->updatedAll();
action->updatedAll();
}
void ModelUavoProxy::flightPlanElementSent(UAVObject *obj, bool success)
void ModelUavoProxy::pathPlanElementSent(UAVObject *obj, bool success)
{
obj->disconnect(this);
@ -74,37 +74,37 @@ void ModelUavoProxy::flightPlanElementSent(UAVObject *obj, bool success)
successCountdown -= success ? 1 : 0;
if (completionCountdown == 0) {
qDebug() << "ModelUavoProxy::flightPlanSent - completed" << (successCountdown == 0);
qDebug() << "ModelUavoProxy::pathPlanSent - completed" << (successCountdown == 0);
if (successCountdown == 0) {
QMessageBox::information(NULL, tr("Flight Plan Upload Successful"), tr("Flight plan upload was successful."));
QMessageBox::information(NULL, tr("Path Plan Upload Successful"), tr("Path plan upload was successful."));
}
else {
QMessageBox::critical(NULL, tr("Flight Plan Upload Failed"), tr("Failed to upload the flight plan !"));
QMessageBox::critical(NULL, tr("Path Plan Upload Failed"), tr("Failed to upload the path plan !"));
}
}
}
void ModelUavoProxy::receiveFlightPlan()
void ModelUavoProxy::receivePathPlan()
{
FlightPlan *flightPlan = FlightPlan::GetInstance(objMngr, 0);
connect(flightPlan, SIGNAL(transactionCompleted(UAVObject *, bool)), this, SLOT(flightPlanElementReceived(UAVObject *, bool)));
PathPlan *pathPlan = PathPlan::GetInstance(objMngr, 0);
connect(pathPlan, SIGNAL(transactionCompleted(UAVObject *, bool)), this, SLOT(pathPlanElementReceived(UAVObject *, bool)));
Waypoint *waypoint = Waypoint::GetInstance(objMngr, 0);
connect(waypoint, SIGNAL(transactionCompleted(UAVObject *, bool)), this, SLOT(flightPlanElementReceived(UAVObject *, bool)));
connect(waypoint, SIGNAL(transactionCompleted(UAVObject *, bool)), this, SLOT(pathPlanElementReceived(UAVObject *, bool)));
PathAction *action = PathAction::GetInstance(objMngr, 0);
connect(action, SIGNAL(transactionCompleted(UAVObject *, bool)), this, SLOT(flightPlanElementReceived(UAVObject *, bool)));
connect(action, SIGNAL(transactionCompleted(UAVObject *, bool)), this, SLOT(pathPlanElementReceived(UAVObject *, bool)));
// we will start 3 update requests
completionCountdown = 3;
successCountdown = completionCountdown;
flightPlan->requestUpdate();
pathPlan->requestUpdate();
waypoint->requestUpdateAll();
action->requestUpdateAll();
}
void ModelUavoProxy::flightPlanElementReceived(UAVObject *obj, bool success)
void ModelUavoProxy::pathPlanElementReceived(UAVObject *obj, bool success)
{
obj->disconnect(this);
@ -112,14 +112,14 @@ void ModelUavoProxy::flightPlanElementReceived(UAVObject *obj, bool success)
successCountdown -= success ? 1 : 0;
if (completionCountdown == 0) {
qDebug() << "ModelUavoProxy::flightPlanReceived - completed" << (successCountdown == 0);
qDebug() << "ModelUavoProxy::pathPlanReceived - completed" << (successCountdown == 0);
if (successCountdown == 0) {
if (objectsToModel()) {
QMessageBox::information(NULL, tr("Flight Plan Download Successful"), tr("Flight plan download was successful."));
QMessageBox::information(NULL, tr("Path Plan Download Successful"), tr("Path plan download was successful."));
}
}
else {
QMessageBox::critical(NULL, tr("Flight Plan Download Failed"), tr("Failed to download the flight plan !"));
QMessageBox::critical(NULL, tr("Path Plan Download Failed"), tr("Failed to download the path plan !"));
}
}
}
@ -204,15 +204,15 @@ bool ModelUavoProxy::modelToObjects()
}
}
// Update FlightPlan
FlightPlan *flightPlan = FlightPlan::GetInstance(objMngr);
FlightPlan::DataFields flightPlanData = flightPlan->getData();
// Update PathPlan
PathPlan *pathPlan = PathPlan::GetInstance(objMngr);
PathPlan::DataFields pathPlanData = pathPlan->getData();
flightPlanData.WaypointCount = waypointCount;
flightPlanData.PathActionCount = actionCount;
flightPlanData.Crc = computeFlightPlanCrc(waypointCount, actionCount);
pathPlanData.WaypointCount = waypointCount;
pathPlanData.PathActionCount = actionCount;
pathPlanData.Crc = computePathPlanCrc(waypointCount, actionCount);
flightPlan->setData(flightPlanData);
pathPlan->setData(pathPlanData);
return true;
}
@ -299,23 +299,23 @@ bool ModelUavoProxy::objectsToModel()
// the list of objects can end with "garbage" instances due to previous flightpath
// they need to be ignored
FlightPlan *flightPlan = FlightPlan::GetInstance(objMngr);
FlightPlan::DataFields flightPlanData = flightPlan->getData();
PathPlan *pathPlan = PathPlan::GetInstance(objMngr);
PathPlan::DataFields pathPlanData = pathPlan->getData();
int waypointCount = flightPlanData.WaypointCount;
int actionCount = flightPlanData.PathActionCount;
int waypointCount = pathPlanData.WaypointCount;
int actionCount = pathPlanData.PathActionCount;
// consistency check
if (waypointCount > objMngr->getNumInstances(Waypoint::OBJID)) {
QMessageBox::critical(NULL, tr("Flight Plan Download Failed"), tr("Flight plan way point count error !"));
QMessageBox::critical(NULL, tr("Path Plan Download Failed"), tr("Path plan way point count error !"));
return false;
}
if (actionCount > objMngr->getNumInstances(PathAction::OBJID)) {
QMessageBox::critical(NULL, tr("Flight Plan Download Failed"), tr("Flight plan path action count error !"));
QMessageBox::critical(NULL, tr("Path Plan Download Failed"), tr("Path plan path action count error !"));
return false;
}
if (flightPlanData.Crc != computeFlightPlanCrc(waypointCount, actionCount)) {
QMessageBox::critical(NULL, tr("Flight Plan Upload Failed"), tr("Flight plan CRC error !"));
if (pathPlanData.Crc != computePathPlanCrc(waypointCount, actionCount)) {
QMessageBox::critical(NULL, tr("Path Plan Upload Failed"), tr("Path plan CRC error !"));
return false;
}
@ -456,7 +456,7 @@ void ModelUavoProxy::pathActionToModel(int i, PathAction::DataFields &data) {
myModel->setData(index, data.ModeParameters[3]);
}
quint8 ModelUavoProxy::computeFlightPlanCrc(int waypointCount, int actionCount) {
quint8 ModelUavoProxy::computePathPlanCrc(int waypointCount, int actionCount) {
quint8 crc = 0;
for (int i = 0; i < waypointCount; ++i) {
Waypoint* waypoint = Waypoint::GetInstance(objMngr, i);

View File

@ -29,7 +29,7 @@
#include "flightdatamodel.h"
#include "flightplan.h"
#include "pathplan.h"
#include "pathaction.h"
#include "waypoint.h"
@ -42,8 +42,8 @@ public:
explicit ModelUavoProxy(QObject *parent, flightDataModel *model);
public slots:
void sendFlightPlan();
void receiveFlightPlan();
void sendPathPlan();
void receivePathPlan();
private:
UAVObjectManager *objMngr;
@ -66,11 +66,11 @@ private:
void waypointToModel(int i, Waypoint::DataFields &data);
void pathActionToModel(int i, PathAction::DataFields &data);
quint8 computeFlightPlanCrc(int waypointCount, int actionCount);
quint8 computePathPlanCrc(int waypointCount, int actionCount);
private slots:
void flightPlanElementSent(UAVObject *, bool success);
void flightPlanElementReceived(UAVObject *, bool success);
void pathPlanElementSent(UAVObject *, bool success);
void pathPlanElementReceived(UAVObject *, bool success);
};
#endif // MODELUAVOPROXY_H

View File

@ -228,8 +228,8 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent)
UAVProxy = new ModelUavoProxy(this, model);
// sending and receiving is asynchronous
// TODO : buttons should be disabled while a send or receive is in progress
connect(table, SIGNAL(sendPathPlanToUAV()), UAVProxy, SLOT(sendFlightPlan()));
connect(table, SIGNAL(receivePathPlanFromUAV()), UAVProxy, SLOT(receiveFlightPlan()));
connect(table, SIGNAL(sendPathPlanToUAV()), UAVProxy, SLOT(sendPathPlan()));
connect(table, SIGNAL(receivePathPlanFromUAV()), UAVProxy, SLOT(receivePathPlan()));
#endif
magicWayPoint = m_map->magicWPCreate();
magicWayPoint->setVisible(false);

View File

@ -77,6 +77,7 @@ HEADERS += \
$$UAVOBJECT_SYNTHETICS/gpssettings.h \
$$UAVOBJECT_SYNTHETICS/pathaction.h \
$$UAVOBJECT_SYNTHETICS/pathdesired.h \
$$UAVOBJECT_SYNTHETICS/pathplan.h \
$$UAVOBJECT_SYNTHETICS/pathstatus.h \
$$UAVOBJECT_SYNTHETICS/gpsvelocitysensor.h \
$$UAVOBJECT_SYNTHETICS/positionstate.h \
@ -97,7 +98,6 @@ HEADERS += \
$$UAVOBJECT_SYNTHETICS/i2cstats.h \
$$UAVOBJECT_SYNTHETICS/flightbatterysettings.h \
$$UAVOBJECT_SYNTHETICS/taskinfo.h \
$$UAVOBJECT_SYNTHETICS/flightplan.h \
$$UAVOBJECT_SYNTHETICS/flightplanstatus.h \
$$UAVOBJECT_SYNTHETICS/flightplansettings.h \
$$UAVOBJECT_SYNTHETICS/flightplancontrol.h \
@ -171,6 +171,7 @@ SOURCES += \
$$UAVOBJECT_SYNTHETICS/gpssettings.cpp \
$$UAVOBJECT_SYNTHETICS/pathaction.cpp \
$$UAVOBJECT_SYNTHETICS/pathdesired.cpp \
$$UAVOBJECT_SYNTHETICS/pathplan.cpp \
$$UAVOBJECT_SYNTHETICS/pathstatus.cpp \
$$UAVOBJECT_SYNTHETICS/gpsvelocitysensor.cpp \
$$UAVOBJECT_SYNTHETICS/positionstate.cpp \
@ -191,7 +192,6 @@ SOURCES += \
$$UAVOBJECT_SYNTHETICS/i2cstats.cpp \
$$UAVOBJECT_SYNTHETICS/flightbatterysettings.cpp \
$$UAVOBJECT_SYNTHETICS/taskinfo.cpp \
$$UAVOBJECT_SYNTHETICS/flightplan.cpp \
$$UAVOBJECT_SYNTHETICS/flightplanstatus.cpp \
$$UAVOBJECT_SYNTHETICS/flightplansettings.cpp \
$$UAVOBJECT_SYNTHETICS/flightplancontrol.cpp \

View File

@ -1,5 +1,5 @@
<xml>
<object name="FlightPlan" singleinstance="true" settings="false" category="Navigation">
<object name="PathPlan" singleinstance="true" settings="false" category="Navigation">
<description>Flight plan informations</description>
<field name="WaypointCount" units="" type="uint16" elements="1" default="0" />