|
@@ -2,12 +2,13 @@
|
|
|
|
|
|
#include "ivstdcolorout.h"
|
|
|
|
|
|
-brain_localplan_gpstype::brain_localplan_gpstype()
|
|
|
+brain_localplan_gpstype::brain_localplan_gpstype(localplan_base * pplan)
|
|
|
{
|
|
|
|
|
|
+ mpplan = pplan;
|
|
|
|
|
|
ModuleFun funmap =std::bind(&brain_localplan_gpstype::UpadateMap,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
|
|
|
- mpa_map = iv::modulecomm::RegisterRecvPlus("tracemap",funmap);
|
|
|
+ mpa_map = iv::modulecomm::RegisterRecvPlus("mapglobal",funmap);
|
|
|
|
|
|
ModuleFun funfusion =std::bind(&brain_localplan_gpstype::UpadateFusion,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
|
|
|
mpa_fusion = iv::modulecomm::RegisterRecvPlus("li_ra_fusion",funfusion);
|
|
@@ -16,7 +17,7 @@ brain_localplan_gpstype::brain_localplan_gpstype()
|
|
|
mpa_gps = iv::modulecomm::RegisterRecvPlus("hcp2_gpsimu",fungps);
|
|
|
|
|
|
ModuleFun funhmi =std::bind(&brain_localplan_gpstype::UpadateHMI,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
|
|
|
- mpa_hmi = iv::modulecomm::RegisterRecvPlus("tracemap",funhmi);
|
|
|
+ mpa_hmi = iv::modulecomm::RegisterRecvPlus("hmi",funhmi);
|
|
|
|
|
|
|
|
|
mbRun = true;
|
|
@@ -27,21 +28,32 @@ brain_localplan_gpstype::brain_localplan_gpstype()
|
|
|
brain_localplan_gpstype::~brain_localplan_gpstype()
|
|
|
{
|
|
|
|
|
|
+
|
|
|
+ mbRun = false;
|
|
|
+ mpthreadplan->join();
|
|
|
iv::modulecomm::Unregister(mpa_hmi);
|
|
|
iv::modulecomm::Unregister(mpa_gps);
|
|
|
iv::modulecomm::Unregister(mpa_fusion);
|
|
|
iv::modulecomm::Unregister(mpa_map);
|
|
|
|
|
|
- mbRun = false;
|
|
|
- mpthreadplan->join();
|
|
|
}
|
|
|
|
|
|
|
|
|
void brain_localplan_gpstype::threadplan()
|
|
|
{
|
|
|
+ std::shared_ptr<iv::map::mapglobal> pmapglobal_ptr = nullptr;
|
|
|
+ std::shared_ptr<iv::gps::gpsimu> pgpsimu_ptr = nullptr;
|
|
|
+ std::shared_ptr<iv::fusion::fusionobjectarray> pfusion_ptr = nullptr;
|
|
|
+
|
|
|
int nnogps = 0;
|
|
|
while(mbRun)
|
|
|
{
|
|
|
+ int64_t nms_now = std::chrono::system_clock::now().time_since_epoch().count()/1000000;
|
|
|
+ if(mbDecisionPause)
|
|
|
+ {
|
|
|
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
if(mbHaveMap == false)
|
|
|
{
|
|
|
static int nnotice = 0;
|
|
@@ -54,6 +66,19 @@ void brain_localplan_gpstype::threadplan()
|
|
|
}
|
|
|
continue;
|
|
|
}
|
|
|
+
|
|
|
+ bool bNewMap = false;
|
|
|
+
|
|
|
+ if(mbMapUpdate)
|
|
|
+ {
|
|
|
+ pmapglobal_ptr = std::shared_ptr<iv::map::mapglobal>(new iv::map::mapglobal);
|
|
|
+ mmutexmapglobal.lock();
|
|
|
+ pmapglobal_ptr->CopyFrom(mmapglobal);
|
|
|
+ mmutexmapglobal.unlock();
|
|
|
+ mbMapUpdate = false;
|
|
|
+ bNewMap = true;
|
|
|
+ }
|
|
|
+
|
|
|
static int nnogpsprint = 0;
|
|
|
if(mbGPSUpdate == false)
|
|
|
{
|
|
@@ -74,10 +99,39 @@ void brain_localplan_gpstype::threadplan()
|
|
|
}
|
|
|
continue;
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ pgpsimu_ptr = std::shared_ptr<iv::gps::gpsimu>(new iv::gps::gpsimu);
|
|
|
+ mmutexgpsimu.lock();
|
|
|
+ pgpsimu_ptr->CopyFrom(mgpsimu);
|
|
|
+ mmutexgpsimu.unlock();
|
|
|
+ mbGPSUpdate = false;
|
|
|
+ nnogpsprint = 0;
|
|
|
+ nnogps = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(abs(nms_now - mLastms_fusionupdate) > 1000)
|
|
|
+ {
|
|
|
+ pfusion_ptr = nullptr;
|
|
|
+ ivstdcolorout("No Obstacle Information.",iv::STDCOLOR_BOLDYELLOW);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(mbFusionUpdate)
|
|
|
+ {
|
|
|
+ mmutexfusionarray.lock();
|
|
|
+ pfusion_ptr->CopyFrom(mfusionarray);
|
|
|
+ mmutexfusionarray.unlock();
|
|
|
+ mbFusionUpdate = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ std::shared_ptr<iv::decision::localplan> plocalplan_ptr = mpplan->GetPlan(pmapglobal_ptr,pgpsimu_ptr,pfusion_ptr,bNewMap);
|
|
|
+
|
|
|
+ //Share local plan
|
|
|
+
|
|
|
|
|
|
|
|
|
- nnogpsprint = 0;
|
|
|
- nnogps = 0;
|
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
|
|
}
|
|
@@ -89,6 +143,21 @@ void brain_localplan_gpstype::UpadateMap(const char *strdata, const unsigned int
|
|
|
(void)index;
|
|
|
(void)dt;
|
|
|
(void)strmemname;
|
|
|
+ iv::map::mapglobal xmapglobal;
|
|
|
+ if(xmapglobal.ParseFromArray(strdata,static_cast<int>(nSize) ))
|
|
|
+ {
|
|
|
+ mmutexmapglobal.lock();
|
|
|
+ mmapglobal.CopyFrom(xmapglobal);
|
|
|
+ mmutexmapglobal.unlock();
|
|
|
+ mbHaveMap = true;
|
|
|
+ mbMapUpdate = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ char strout[256];
|
|
|
+ snprintf(strout,256,"brain_localplan_gpstype::UpadateMap Parse mapglobal fail.");
|
|
|
+ ivstdcolorout(strout,iv::STDCOLOR_BOLDYELLOW);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void brain_localplan_gpstype::UpadateFusion(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
|
|
@@ -97,6 +166,21 @@ void brain_localplan_gpstype::UpadateFusion(const char *strdata, const unsigned
|
|
|
(void)index;
|
|
|
(void)dt;
|
|
|
(void)strmemname;
|
|
|
+ iv::fusion::fusionobjectarray xfusionarray;
|
|
|
+ if(xfusionarray.ParseFromArray(strdata,static_cast<int>(nSize) ))
|
|
|
+ {
|
|
|
+ mmutexfusionarray.lock();
|
|
|
+ mfusionarray.CopyFrom(xfusionarray);
|
|
|
+ mmutexfusionarray.unlock();
|
|
|
+ mbFusionUpdate = true;
|
|
|
+ mLastms_fusionupdate = std::chrono::system_clock::now().time_since_epoch().count()/1000000;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ char strout[256];
|
|
|
+ snprintf(strout,256,"brain_localplan_gpstype::UpadateFusion Parse fusionarray fail.");
|
|
|
+ ivstdcolorout(strout,iv::STDCOLOR_BOLDYELLOW);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void brain_localplan_gpstype::UpadateGPS(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
|
|
@@ -105,6 +189,21 @@ void brain_localplan_gpstype::UpadateGPS(const char *strdata, const unsigned int
|
|
|
(void)index;
|
|
|
(void)dt;
|
|
|
(void)strmemname;
|
|
|
+ iv::gps::gpsimu xgpsimu;
|
|
|
+ if(xgpsimu.ParseFromArray(strdata,static_cast<int>(nSize) ))
|
|
|
+ {
|
|
|
+ mmutexgpsimu.lock();
|
|
|
+ mgpsimu.CopyFrom(xgpsimu);
|
|
|
+ mmutexgpsimu.unlock();
|
|
|
+ mbGPSUpdate = true;
|
|
|
+ mLastms_gpsupdate = std::chrono::system_clock::now().time_since_epoch().count()/1000000;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ char strout[256];
|
|
|
+ snprintf(strout,256,"brain_localplan_gpstype::UpadateGPS Parse gpsimu fail.");
|
|
|
+ ivstdcolorout(strout,iv::STDCOLOR_BOLDYELLOW);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void brain_localplan_gpstype::UpadateHMI(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
|
|
@@ -113,5 +212,18 @@ void brain_localplan_gpstype::UpadateHMI(const char *strdata, const unsigned int
|
|
|
(void)index;
|
|
|
(void)dt;
|
|
|
(void)strmemname;
|
|
|
+
|
|
|
+ iv::hmi::hmimsg xhmimsg;
|
|
|
+ if(xhmimsg.ParseFromArray(strdata,static_cast<int>(nSize)))
|
|
|
+ {
|
|
|
+ if(xhmimsg.mbpause())
|
|
|
+ {
|
|
|
+ mbDecisionPause = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ mbDecisionPause = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|