|
@@ -93,8 +93,61 @@ int ivdecision_brain::getdecision(brain::decition &xdecition,iv::brain::brainsta
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ double fAcc;
|
|
|
+ double fWheel;
|
|
|
+ int nshift;
|
|
|
+ double fdSpeed;
|
|
|
+ double fdSecSpeed;
|
|
|
+
|
|
|
+ bool bAvoidAvail = true;
|
|
|
+
|
|
|
+ switch (vehState) {
|
|
|
+ case normalRun:
|
|
|
+ break;
|
|
|
+ case preAvoid:
|
|
|
+ break;
|
|
|
+ case avoiding:
|
|
|
+ break;
|
|
|
+ case dRever0:
|
|
|
+ mivpark.GetBocheDecision(now_gps_ins->gps_lng,now_gps_ins->gps_lat,now_gps_ins->ins_heading_angle,
|
|
|
+ now_gps_ins->speed,fAcc,fWheel,nshift,fdSpeed,fdSecSpeed,vehState,true);
|
|
|
+ break;
|
|
|
+ case dRever2:
|
|
|
+ mivpark.GetBocheDecision(now_gps_ins->gps_lng,now_gps_ins->gps_lat,now_gps_ins->ins_heading_angle,
|
|
|
+ now_gps_ins->speed,fAcc,fWheel,nshift,fdSpeed,fdSecSpeed,vehState,true);
|
|
|
+ break;
|
|
|
+ case dRever3:
|
|
|
+ mivpark.GetBocheDecision(now_gps_ins->gps_lng,now_gps_ins->gps_lat,now_gps_ins->ins_heading_angle,
|
|
|
+ now_gps_ins->speed,fAcc,fWheel,nshift,fdSpeed,fdSecSpeed,vehState,true);
|
|
|
+ break;
|
|
|
+ case reversing:
|
|
|
+ mivpark.GetBocheDecision(now_gps_ins->gps_lng,now_gps_ins->gps_lat,now_gps_ins->ins_heading_angle,
|
|
|
+ now_gps_ins->speed,fAcc,fWheel,nshift,fdSpeed,fdSecSpeed,vehState,true);
|
|
|
+ break;
|
|
|
+ case reverseDirect:
|
|
|
+ mivpark.GetBocheDecision(now_gps_ins->gps_lng,now_gps_ins->gps_lat,now_gps_ins->ins_heading_angle,
|
|
|
+ now_gps_ins->speed,fAcc,fWheel,nshift,fdSpeed,fdSecSpeed,vehState,true);
|
|
|
+ break;
|
|
|
+ case reverseCircle:
|
|
|
+ mivpark.GetBocheDecision(now_gps_ins->gps_lng,now_gps_ins->gps_lat,now_gps_ins->ins_heading_angle,
|
|
|
+ now_gps_ins->speed,fAcc,fWheel,nshift,fdSpeed,fdSecSpeed,vehState,true);
|
|
|
+ break;
|
|
|
+ case reverseArr:
|
|
|
+ mivpark.GetBocheDecision(now_gps_ins->gps_lng,now_gps_ins->gps_lat,now_gps_ins->ins_heading_angle,
|
|
|
+ now_gps_ins->speed,fAcc,fWheel,nshift,fdSecSpeed,fdSecSpeed,vehState,true);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
iv::decition::Decition decition= getDecideFromGPS(*now_gps_ins,mgpsMapLine,lidarptr,xvectorper,xtrafficlight);
|
|
|
|
|
|
+ //Park
|
|
|
+ //Local Plan,Selec Path
|
|
|
+ //Controller
|
|
|
+
|
|
|
xdecition.set_accelerator(decition->accelerator);
|
|
|
xdecition.set_brake(decition->brake);
|
|
|
xdecition.set_leftlamp(decition->leftlamp);
|
|
@@ -1285,6 +1338,77 @@ void ivdecision_brain::decision_speedctrl(Decition &gps_decition,const std::vect
|
|
|
std::cout<<"juecesudu2="<<dSpeed<<std::endl;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+int ivdecision_brain::normalRunDecision(GPS_INS now_gps_ins,
|
|
|
+ const std::vector<GPSData> gpsMapLine,
|
|
|
+ iv::LidarGridPtr lidarGridPtr,
|
|
|
+ std::vector<iv::Perception::PerceptionOutput> lidar_per,
|
|
|
+ iv::TrafficLight trafficLight,
|
|
|
+ double & fAcc,double & fWheel,int & nshift,double & fdSpeed,double & fdSecSpeed,VehState & xvehstate)
|
|
|
+{
|
|
|
+
|
|
|
+ std::vector<double> xvectorObs;
|
|
|
+ if(isFirstRun)
|
|
|
+ {
|
|
|
+ xvectorObs.clear();
|
|
|
+ }
|
|
|
+
|
|
|
+ if(now_gps_ins.gps_lat<0||now_gps_ins.gps_lat>90){
|
|
|
+ // int a=0;
|
|
|
+ fAcc = -0.5;
|
|
|
+ fWheel = 0;
|
|
|
+ nshift = ShiftState::Drive;
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ PathPoint = mnearpointfunc.FindNearPoint(gpsMapLine,now_gps_ins.gps_lng,now_gps_ins.gps_lat,now_gps_ins.ins_heading_angle);
|
|
|
+
|
|
|
+ if(PathPoint <0)
|
|
|
+ {
|
|
|
+ std::cout<<" Can't Find Near Point."<<std::endl;
|
|
|
+ fAcc = -0.5;
|
|
|
+ fWheel = 0;
|
|
|
+ nshift = ShiftState::Drive;
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ double fPreviewDis = 100.0;
|
|
|
+
|
|
|
+ int nsize = static_cast<int>(gpsMapLine.size());
|
|
|
+
|
|
|
+ int i;
|
|
|
+ double fDisTotal = 0.0;
|
|
|
+ std::vector<iv::Point2D> xvectorplan;
|
|
|
+ xvectorplan.clear();
|
|
|
+ for(i=PathPoint;i<nsize;i++)
|
|
|
+ {
|
|
|
+ iv::Point2D pt = iv::decition::Coordinate_Transfer(gpsMapLine[i]->gps_x,gpsMapLine[i]->gps_y, now_gps_ins);
|
|
|
+ if(xvectorplan.size()>0)
|
|
|
+ {
|
|
|
+ double fdisadd = sqrt(pow(pt.x - xvectorplan[xvectorplan.size()-1].x,2) + pow(pt.y - xvectorplan[xvectorplan.size()-1].y,2));
|
|
|
+ fDisTotal = fDisTotal + fdisadd;
|
|
|
+ }
|
|
|
+ xvectorplan.push_back(pt);
|
|
|
+ if(fDisTotal >= fPreviewDis)break;
|
|
|
+ }
|
|
|
+
|
|
|
+ gpsTraceOri= getGpsTrace(now_gps_ins, gpsMapLine, lastGpsIndex,circleMode);
|
|
|
+
|
|
|
+ if(gpsTraceOri.empty())
|
|
|
+ {
|
|
|
+ std::cout<<" No Trace."<<std::endl;
|
|
|
+ fAcc = -0.5;
|
|
|
+ fWheel = 0;
|
|
|
+ nshift = ShiftState::Drive;
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ lastGpsIndex = PathPoint;
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+ iv::decition::Decition gps_decition(new iv::decition::DecitionBasic);
|
|
|
//std::vector<iv::Perception::PerceptionOutput> lidar_per,
|
|
|
iv::decition::Decition ivdecision_brain::getDecideFromGPS(GPS_INS now_gps_ins,
|
|
|
const std::vector<GPSData> gpsMapLine,
|