|
@@ -27,6 +27,8 @@ static bool gbthreadrun = true;
|
|
|
static std::thread * gpthreadsend;
|
|
|
|
|
|
static Shenlanfd * gpShenlanfd;
|
|
|
+static double gfTotalPathLen = 100;
|
|
|
+static double gfNowVel = 1.0; //m/s
|
|
|
|
|
|
|
|
|
static std::shared_ptr<apollo::cyber::Writer<iv::can::canmsg>>
|
|
@@ -106,10 +108,12 @@ static void ExecSend()
|
|
|
void threadsend()
|
|
|
{
|
|
|
int i;
|
|
|
+ i=0;
|
|
|
|
|
|
|
|
|
while(gbthreadrun)
|
|
|
{
|
|
|
+ i++;
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
|
|
ExecSend();
|
|
|
}
|
|
@@ -119,17 +123,20 @@ void threadsend()
|
|
|
|
|
|
void RecvCANMsg(const std::shared_ptr<iv::can::canmsg> &xmsg)
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
void RecvPlanning(const std::shared_ptr<apollo::planning::ADCTrajectory> & xplanning)
|
|
|
{
|
|
|
-
|
|
|
+ gfTotalPathLen = xplanning->total_path_length();
|
|
|
+// std::cout<<"total path length: "<<xplanning->total_path_length()<<std::endl;
|
|
|
+// std::cout<<"total path time: "<<xplanning->total_path_time()<<std::endl;
|
|
|
}
|
|
|
|
|
|
void RecvChassis(const std::shared_ptr<iv::chassis> &xchassis)
|
|
|
{
|
|
|
|
|
|
+ gfNowVel = xchassis->vel()/3.6;
|
|
|
gpShenlanfd->SetSpeed(xchassis->vel());
|
|
|
|
|
|
std::shared_ptr<apollo::canbus::Chassis> apollochassis_ptr;
|
|
@@ -147,8 +154,22 @@ void RecvController(const std::shared_ptr<apollo::control::ControlCommand> &xcmd
|
|
|
double fbrake = xcmd->brake();
|
|
|
double fwheelangle = 0;
|
|
|
|
|
|
+ const double fEndBrakeCtrlLen = 1.0;
|
|
|
+
|
|
|
facc = xcmd->acceleration();
|
|
|
|
|
|
+ if((gfTotalPathLen<fEndBrakeCtrlLen) && (gfTotalPathLen>0.001))
|
|
|
+ {
|
|
|
+ double fcalcacc = 0.0;
|
|
|
+ fcalcacc = (-1.0) * gfNowVel * gfNowVel /(2.0*gfTotalPathLen);
|
|
|
+ if(fcalcacc < (-5.0))fcalcacc = -5.0;
|
|
|
+ if(facc<fcalcacc)
|
|
|
+ {
|
|
|
+ facc = fcalcacc;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
double fVehWeight = 1800;
|
|
|
double fg = 9.8;
|
|
|
double fRollForce = 50;
|
|
@@ -192,7 +213,7 @@ void RecvController(const std::shared_ptr<apollo::control::ControlCommand> &xcmd
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- gpShenlanfd->SetDecision(xdcs);
|
|
|
+// gpShenlanfd->SetDecision(xdcs);
|
|
|
}
|
|
|
|
|
|
void testthread()
|