修改了状态管理代码

This commit is contained in:
chenlizhi
2023-11-28 09:52:36 +08:00
parent 1e9b71b673
commit bee3fea02d
3 changed files with 22 additions and 13 deletions

View File

@@ -17,6 +17,9 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR})
#find_package (jsoncpp NO_MODULE REQUIRED) #find_package (jsoncpp NO_MODULE REQUIRED)
find_package (GeographicLib REQUIRED)
include_directories(${GeographicLib_INCLUDE_DIRS})
include_directories(/usr/include/jsoncpp/) include_directories(/usr/include/jsoncpp/)
link_directories(/usr/local/lib/) link_directories(/usr/local/lib/)
@@ -26,7 +29,8 @@ TARGET_LINK_LIBRARIES(pStateManagement
${MOOS_LIBRARIES} ${MOOS_LIBRARIES}
${CMAKE_DL_LIBS} ${CMAKE_DL_LIBS}
${SYSTEM_LIBS} ${SYSTEM_LIBS}
${DUNE_LIB} ${DUNE_LIB}
${GeographicLib_LIBRARIES}
mbutil mbutil
m m
pthread pthread

View File

@@ -9,6 +9,7 @@
#include "MBUtils.h" #include "MBUtils.h"
#include "StateManagement.h" #include "StateManagement.h"
#include <json/json.h> #include <json/json.h>
#include <cmath>
using namespace std; using namespace std;
@@ -36,7 +37,6 @@ bool StateManagement::OnNewMail(MOOSMSG_LIST &NewMail)
for(p=NewMail.begin(); p!=NewMail.end(); p++) { for(p=NewMail.begin(); p!=NewMail.end(); p++) {
CMOOSMsg &msg = *p; CMOOSMsg &msg = *p;
#if 1 // Keep these around just for template
string key = msg.GetKey(); string key = msg.GetKey();
string comm = msg.GetCommunity(); string comm = msg.GetCommunity();
double dval = msg.GetDouble(); double dval = msg.GetDouble();
@@ -45,11 +45,10 @@ bool StateManagement::OnNewMail(MOOSMSG_LIST &NewMail)
double mtime = msg.GetTime(); double mtime = msg.GetTime();
bool mdbl = msg.IsDouble(); bool mdbl = msg.IsDouble();
bool mstr = msg.IsString(); bool mstr = msg.IsString();
#endif
Json::Value deviceState; Json::Value deviceState;
double manualState; double manualState;
double missionState; int missionState;
if(key == "uManual_enable_cmd") if(key == "uManual_enable_cmd")
{ {
@@ -75,18 +74,18 @@ bool StateManagement::OnNewMail(MOOSMSG_LIST &NewMail)
deviceState["opMode"] = opModeLists.external; deviceState["opMode"] = opModeLists.external;
} }
else if (fabs(manualState - 0) < 1e-6) //manualState=0 else if (fabs(manualState - 0) < 1e-6) //manualState=0
{ {
if(missionState == 0) switch (missionState)
{ {
case 0:
deviceState["opMode"] = opModeLists.error; deviceState["opMode"] = opModeLists.error;
} break;
if(missionState == 1) case 1:
{
deviceState["opMode"] = opModeLists.service; deviceState["opMode"] = opModeLists.service;
} break;
else if((missionState == 3) ) case 3:
{
deviceState["opMode"] = opModeLists.maneuver; deviceState["opMode"] = opModeLists.maneuver;
break;
} }
} }

View File

@@ -9,6 +9,12 @@
#define StateManagement_HEADER #define StateManagement_HEADER
#include "MOOS/libMOOS/MOOSLib.h" #include "MOOS/libMOOS/MOOSLib.h"
#include "MOOS/libMOOS/Thirdparty/AppCasting/AppCastingMOOSApp.h"
#include <DUNE/DUNE.hpp>
#include <GeographicLib/LocalCartesian.hpp>
#include <json/json.h>
#include <thread>
#include <chrono>
class StateManagement : public CMOOSApp class StateManagement : public CMOOSApp
{ {