|
@@ -12,6 +12,7 @@
|
|
|
#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;
|
|
@@ -472,6 +473,23 @@ void DataExchangeClient::ListenTraceMapMsg(const char * strdata,const unsigned i
|
|
|
// std::cout<<pathPoints.at(i).index()<<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();
|
|
|
}
|
|
|
|
|
@@ -528,8 +546,8 @@ std::string DataExchangeClient::uploadVehicleInfo(void)
|
|
|
request.set_sensorstatuscamright(sensorStatusCamRight);
|
|
|
request.set_isarrived(isArrived);
|
|
|
request.set_platenumber(plateNumber);
|
|
|
- request.set_usestatusfeedback(org::jeecg::defsDetails::grpc::UseStatus::ENABLING);
|
|
|
- request.set_remainpathlength(500.0);
|
|
|
+ request.set_usestatusfeedback(useStatus);
|
|
|
+ request.set_remainpathlength(remainPathLength);
|
|
|
request.set_classfeedback(vehicleType);
|
|
|
|
|
|
// Container for the data we expect from the server.
|
|
@@ -575,9 +593,9 @@ std::string DataExchangeClient::uploadPath(void)
|
|
|
request.add_pathpoints();
|
|
|
request.mutable_pathpoints(i)->operator =(pathPoints.at(i));
|
|
|
}
|
|
|
- request.set_arrivedtime(500.0/gspeedWantAvg);
|
|
|
- request.set_waittime(gwaitTime);
|
|
|
- request.set_totalpathlength(500.0);
|
|
|
+ request.set_arrivedtime(arrivedTime);
|
|
|
+ request.set_waittime(waitTime);
|
|
|
+ request.set_totalpathlength(totalPathLength);
|
|
|
|
|
|
// Container for the data we expect from the server.
|
|
|
Empty reply;
|
|
@@ -672,18 +690,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 = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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)
|
|
@@ -744,7 +776,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)
|
|
@@ -760,7 +792,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
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -817,7 +849,7 @@ 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
|
|
|
+ iv::modulecomm::ModuleSendMsg(shmXodrRequest.mpa,(char *)&xodrDest,sizeof(xodrobj)); ///< send request msg
|
|
|
destinationRefreshed = false;
|
|
|
}
|
|
|
}
|
|
@@ -825,6 +857,8 @@ void DataExchangeClient::destination_Recieved_Slot(void)
|
|
|
|
|
|
void DataExchangeClient::path_Updated_Slot(void)
|
|
|
{
|
|
|
+ remainPathLength = totalPathLength;
|
|
|
+ isArrived = 1; ///< 0 no destination 1 not arrived 2 arrived
|
|
|
uploadPath();
|
|
|
if(destinationRefreshed == true)
|
|
|
destinationRefreshed = false;
|