|
@@ -11,15 +11,37 @@ ctrlcmd2decition::ctrlcmd2decition()
|
|
|
mpactrlcmd = iv::modulecomm::RegisterRecvPlus("ctrlcmd",xFunctrlcmd);
|
|
|
mpadecision = iv::modulecomm::RegisterSend("deciton",1000,1);
|
|
|
|
|
|
+ ModuleFun xFunGPSIMU = std::bind(&ctrlcmd2decition::ListenGPSIMU,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
|
|
|
+
|
|
|
+ mpagpsimu = iv::modulecomm::RegisterRecvPlus("hcp2_gpsimu",xFunGPSIMU);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
ctrlcmd2decition::~ctrlcmd2decition()
|
|
|
{
|
|
|
+ iv::modulecomm::Unregister(mpagpsimu);
|
|
|
iv::modulecomm::Unregister(mpadecision);
|
|
|
iv::modulecomm::Unregister(mpactrlcmd);
|
|
|
delete mpLT;
|
|
|
}
|
|
|
|
|
|
+void ctrlcmd2decition::ListenGPSIMU(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
|
|
|
+{
|
|
|
+ (void)index;
|
|
|
+ (void)dt;
|
|
|
+ (void)strmemname;
|
|
|
+
|
|
|
+ iv::gps::gpsimu xgpsimu;
|
|
|
+ if(xgpsimu.ParseFromArray(strdata,nSize))
|
|
|
+ {
|
|
|
+ mfVelNow = sqrt(pow(xgpsimu.ve(),2) + pow(xgpsimu.vn(),2));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ std::cout<<" ctrlcmd2decition::ListenGPSIMU Parse Fail ." <<std::endl;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void ctrlcmd2decition::ListenCtrlCmd(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
|
|
|
{
|
|
|
(void)index;
|
|
@@ -38,11 +60,52 @@ void ctrlcmd2decition::ListenCtrlCmd(const char *strdata, const unsigned int nSi
|
|
|
double ftorque = 0;
|
|
|
double fbrake = 0;
|
|
|
double fwheelangle = 0;
|
|
|
+ if(xctrlcmd.linear_velocity() > 1.0)
|
|
|
+ {
|
|
|
+ if(xctrlcmd.linear_velocity()>mfVelNow)
|
|
|
+ {
|
|
|
+ if(xctrlcmd.linear_velocity()>(mfVelNow + 0.1))
|
|
|
+ {
|
|
|
+ if(xctrlcmd.linear_velocity()>(mfVelNow + 0.3))
|
|
|
+ {
|
|
|
+ facc =0.3+ 1.0* (xctrlcmd.linear_velocity() -mfVelNow)/xctrlcmd.linear_velocity() ;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ facc =1.6 * (xctrlcmd.linear_velocity() -mfVelNow)/xctrlcmd.linear_velocity() ;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ facc = 0.0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(xctrlcmd.linear_velocity()>(mfVelNow-0.3))
|
|
|
+ {
|
|
|
+ facc = 0.0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ facc = -1.5;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(xctrlcmd.linear_velocity()>mfVelNow)
|
|
|
+ {
|
|
|
+ facc = 1.0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ facc = -1.0;
|
|
|
+ }
|
|
|
+ }
|
|
|
if(mpLT->IsINterpolationOK())
|
|
|
{
|
|
|
- mpLT->GetTorqueBrake(xctrlcmd.linear_velocity()*3.6,xctrlcmd.linear_acceleration(),ftorque,fbrake);
|
|
|
+ mpLT->GetTorqueBrake(xctrlcmd.linear_velocity()*3.6,facc,ftorque,fbrake);
|
|
|
}
|
|
|
- facc = xctrlcmd.linear_acceleration();
|
|
|
+// facc = xctrlcmd.linear_acceleration();
|
|
|
fwheelangle = xctrlcmd.steering_angle() * (180.0/M_PI) * 15.0;
|
|
|
xdecition.set_accelerator(facc);
|
|
|
xdecition.set_brake(fbrake);
|
|
@@ -52,10 +115,10 @@ void ctrlcmd2decition::ListenCtrlCmd(const char *strdata, const unsigned int nSi
|
|
|
xdecition.set_wheelangle(fwheelangle);
|
|
|
xdecition.set_wheelspeed(300);
|
|
|
xdecition.set_torque(ftorque);
|
|
|
- xdecition.set_mode(0);
|
|
|
- xdecition.set_gear(0);
|
|
|
+ xdecition.set_mode(1);
|
|
|
+ xdecition.set_gear(1);
|
|
|
xdecition.set_handbrake(0);
|
|
|
- xdecition.set_grade(0);
|
|
|
+ xdecition.set_grade(1);
|
|
|
xdecition.set_engine(0);
|
|
|
xdecition.set_brakelamp(false);
|
|
|
xdecition.set_ttc(15);
|