|
@@ -5,12 +5,14 @@
|
|
|
#include <QStringList>
|
|
|
#include <math.h>
|
|
|
#include <iomanip>
|
|
|
+#include <thread>
|
|
|
|
|
|
#include "modulecomm.h"
|
|
|
#include "rawpic.pb.h"
|
|
|
#include "chassis.pb.h"
|
|
|
#include "platform_feedback.pb.h"
|
|
|
#include "gpsimu.pb.h"
|
|
|
+#include "math/gnss_coordinate_convert.h" //for calculate totalPathLength
|
|
|
|
|
|
extern std::string gstrserverip;
|
|
|
extern std::string gstruploadPort;
|
|
@@ -19,6 +21,9 @@ extern std::string gstrid;
|
|
|
extern std::string gstrplateNumber;
|
|
|
extern std::string gvehicleType;
|
|
|
|
|
|
+extern double gspeedWantAvg; // m/s
|
|
|
+extern double gwaitTime; // s
|
|
|
+
|
|
|
extern char stryamlpath[256];
|
|
|
|
|
|
extern uint8_t gShift_Status;//3 p 4 r 5 n 6 d
|
|
@@ -366,6 +371,7 @@ void DataExchangeClient::ListenGPSIMUMsg(const char * strdata,const unsigned int
|
|
|
}
|
|
|
|
|
|
double GPS_Speed = sqrt(xdata.ve()*xdata.ve()+xdata.vd()*xdata.vd()+xdata.vn()*xdata.vn());
|
|
|
+ if (GPS_Speed < 0.01)GPS_Speed = 0.0;
|
|
|
|
|
|
gMutex_GPSIMU.lock();
|
|
|
GPSRTKStatus = xdata.rtk_state();
|
|
@@ -467,6 +473,24 @@ void DataExchangeClient::ListenTraceMapMsg(const char * strdata,const unsigned i
|
|
|
pathPoints.append(onePoint);
|
|
|
// std::cout<<pathPoints.at(i).index()<<std::endl;
|
|
|
}
|
|
|
+// std::cout<<"get a tracemap"<<std::endl;
|
|
|
+
|
|
|
+ totalPathLength = 0.0;
|
|
|
+ double localPositionX = 0.0;
|
|
|
+ double localPositionNextX = 0.0;
|
|
|
+ double localPositionY = 0.0;
|
|
|
+ double localPositionNextY = 0.0;
|
|
|
+ for(int i = 0;i < npoint - 1;i++)
|
|
|
+ {
|
|
|
+ GaussProjCal(simpletrace[i].gps_lat,simpletrace[i].gps_lng,&localPositionX,&localPositionY);
|
|
|
+ GaussProjCal(simpletrace[i+1].gps_lat,simpletrace[i+1].gps_lng,&localPositionNextX,&localPositionNextY);
|
|
|
+ double deltaX = localPositionNextX - localPositionX;
|
|
|
+ double deltaY = localPositionNextY - localPositionY;
|
|
|
+ totalPathLength += sqrt(deltaX*deltaX + deltaY*deltaY);
|
|
|
+ }
|
|
|
+
|
|
|
+ arrivedTime = totalPathLength/gspeedWantAvg;
|
|
|
+ waitTime = gwaitTime;
|
|
|
|
|
|
emit path_Updated();
|
|
|
}
|
|
@@ -484,8 +508,8 @@ std::string DataExchangeClient::uploadVehicleInfo(void)
|
|
|
gMutex_Chassis.unlock();
|
|
|
|
|
|
gMutex_PlatformFeedback.lock();
|
|
|
- request.set_statusfeedback(statusFeedback);
|
|
|
- request.set_modefeedback(modeFeedback);
|
|
|
+ request.set_statusfeedback(statusFeedback);//statusFeedback
|
|
|
+ request.set_modefeedback(modeFeedback);//modeFeedback
|
|
|
request.set_shiftfeedback(shiftFeedback);
|
|
|
request.set_steeringwheelanglefeedback(steeringWheelAngleFeedback);
|
|
|
request.set_throttlefeedback(throttleFeedback);
|
|
@@ -522,8 +546,10 @@ std::string DataExchangeClient::uploadVehicleInfo(void)
|
|
|
request.set_sensorstatuscamrear(sensorStatusCamRear);
|
|
|
request.set_sensorstatuscamleft(sensorStatusCamLeft);
|
|
|
request.set_sensorstatuscamright(sensorStatusCamRight);
|
|
|
- request.set_isarrived(isArrived);
|
|
|
+ request.set_isarrived(isArrived);//isArrived
|
|
|
request.set_platenumber(plateNumber);
|
|
|
+ request.set_usestatusfeedback(useStatus);
|
|
|
+ request.set_remainpathlength(remainPathLength);
|
|
|
request.set_classfeedback(vehicleType);
|
|
|
|
|
|
// Container for the data we expect from the server.
|
|
@@ -569,6 +595,9 @@ std::string DataExchangeClient::uploadPath(void)
|
|
|
request.add_pathpoints();
|
|
|
request.mutable_pathpoints(i)->operator =(pathPoints.at(i));
|
|
|
}
|
|
|
+ request.set_arrivedtime(arrivedTime);
|
|
|
+ request.set_waittime(waitTime);
|
|
|
+ request.set_totalpathlength(totalPathLength);
|
|
|
|
|
|
// Container for the data we expect from the server.
|
|
|
Empty reply;
|
|
@@ -663,18 +692,32 @@ void DataExchangeClient::updateData(uint64_t timeInterval_ms)
|
|
|
sensorStatusCamLeft = false;
|
|
|
sensorStatusCamRight = false;
|
|
|
|
|
|
- isArrived = 0; //0 no destination 1 not arrived 2 arrived
|
|
|
+// isArrived = 0; ///< 0 no destination 1 not arrived 2 arrived
|
|
|
|
|
|
plateNumber = gstrplateNumber;
|
|
|
|
|
|
+// modeFeedback = CtrlMode::CMD_REMOTE; ///< mode Feedback
|
|
|
+
|
|
|
+ useStatus = org::jeecg::defsDetails::grpc::UseStatus::ENABLING;
|
|
|
+ if(useStatus == org::jeecg::defsDetails::grpc::UseStatus::DEACTIVATING)
|
|
|
+ {
|
|
|
+ remainPathLength = 0.0;
|
|
|
+ isArrived = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ remainPathLength -= (speed * timeInterval_ms/1000.0);
|
|
|
+ if(remainPathLength <= 0.0)
|
|
|
+ {
|
|
|
+ remainPathLength = 0.0;
|
|
|
+ if(isArrived = 1)isArrived = 2;
|
|
|
+ }
|
|
|
+
|
|
|
if(std::atoi(gvehicleType.c_str()) == 0)
|
|
|
vehicleType = org::jeecg::defsDetails::grpc::VehicleClass::RUN_ERRANDS;
|
|
|
if(std::atoi(gvehicleType.c_str()) == 1)
|
|
|
vehicleType = org::jeecg::defsDetails::grpc::VehicleClass::GUIDE;
|
|
|
if(std::atoi(gvehicleType.c_str()) == 2)
|
|
|
vehicleType = org::jeecg::defsDetails::grpc::VehicleClass::CLEAN;
|
|
|
-
|
|
|
-// modeFeedback = CtrlMode::CMD_REMOTE; //mode Feedback
|
|
|
}
|
|
|
|
|
|
void DataExchangeClient::updatePath(std::string pathID, QVector<MapPoint> points)
|
|
@@ -735,7 +778,7 @@ void DataExchangeClient::run()
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- std::this_thread::sleep_for(std::chrono::microseconds(500));//sleep 0.5ms
|
|
|
+ std::this_thread::sleep_for(std::chrono::microseconds(500));///< sleep 0.5ms
|
|
|
}
|
|
|
|
|
|
if(abs(xTime.elapsed() - fileWriteTime) >= 2500)
|
|
@@ -751,7 +794,7 @@ void DataExchangeClient::run()
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- std::this_thread::sleep_for(std::chrono::microseconds(500));//sleep 0.5ms
|
|
|
+ std::this_thread::sleep_for(std::chrono::microseconds(500));///< sleep 0.5ms
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -801,6 +844,7 @@ void DataExchangeClient::destination_Recieved_Slot(void)
|
|
|
if(fabs(destinationPosition.latitude()) > 0.000001 \
|
|
|
&& fabs(destinationPosition.longitude()) > 0.000001)
|
|
|
{
|
|
|
+// std::cout<<"get destination"<<std::endl;
|
|
|
if(destinationRefreshed == true)
|
|
|
{
|
|
|
xodrobj xodrDest;
|
|
@@ -808,14 +852,16 @@ void DataExchangeClient::destination_Recieved_Slot(void)
|
|
|
xodrDest.flat = destinationPosition.latitude();
|
|
|
xodrDest.lane = 1;
|
|
|
|
|
|
- iv::modulecomm::ModuleSendMsg(shmXodrRequest.mpa,(char *)&xodrDest,sizeof(xodrobj)); // send request msg
|
|
|
- destinationRefreshed = false;
|
|
|
+ iv::modulecomm::ModuleSendMsg(shmXodrRequest.mpa,(char *)&xodrDest,sizeof(xodrobj)); ///< send request msg
|
|
|
+// std::cout<<"modulesend xodr request"<<std::endl;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void DataExchangeClient::path_Updated_Slot(void)
|
|
|
{
|
|
|
+ remainPathLength = totalPathLength;
|
|
|
+ isArrived = 1; ///< 0 no destination 1 not arrived 2 arrived
|
|
|
uploadPath();
|
|
|
if(destinationRefreshed == true)
|
|
|
destinationRefreshed = false;
|