|
@@ -18,12 +18,15 @@
|
|
|
|
|
|
#include "remotectrl.pb.h"
|
|
|
|
|
|
+#include "torquebrake.pb.h"
|
|
|
+
|
|
|
#include <thread>
|
|
|
|
|
|
void * gpacansend;
|
|
|
void * gpadecition;
|
|
|
void * gpachassis;
|
|
|
void * gparemote;
|
|
|
+void * gpatorquebrake;
|
|
|
|
|
|
std::string gstrmemdecition;
|
|
|
std::string gstrmemcansend;
|
|
@@ -55,6 +58,10 @@ QMutex gMutex;
|
|
|
|
|
|
boost::shared_ptr<iv::control::Controller> gcontroller; //实际车辆控制器
|
|
|
|
|
|
+iv::controller::torquebrake gtb;
|
|
|
+int gnothavetb = 10;
|
|
|
+QMutex gMutextb;
|
|
|
+
|
|
|
|
|
|
//void executeDecition(const iv::decition::Decition decition)
|
|
|
//{
|
|
@@ -86,6 +93,29 @@ void executeDecition(const iv::brain::decition decition)
|
|
|
|
|
|
gcontroller->control_torque(decition.torque());
|
|
|
gcontroller->control_brake(decition.brake());
|
|
|
+
|
|
|
+ if(gnothavetb < 10)
|
|
|
+ {
|
|
|
+ iv::controller::torquebrake xtb;
|
|
|
+ gMutextb.lock();
|
|
|
+ xtb.CopyFrom(gtb);
|
|
|
+ gMutextb.unlock();
|
|
|
+ if(xtb.enable())
|
|
|
+ {
|
|
|
+ gcontroller->control_torque(xtb.torque());
|
|
|
+ gcontroller->control_brake(xtb.brake());
|
|
|
+// qDebug("use tb value torque is %f brake is %f",xtb.torque(),xtb.brake());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+// qDebug("torquebrake not enable.");
|
|
|
+ }
|
|
|
+ gnothavetb++;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+// qDebug("no tb");
|
|
|
+ }
|
|
|
gcontroller->control_engine(decition.engine());
|
|
|
gcontroller->control_grade(decition.grade());
|
|
|
gcontroller->control_mode(decition.mode());
|
|
@@ -100,6 +130,20 @@ void executeDecition(const iv::brain::decition decition)
|
|
|
// qDebug("dangwei is %d mode is %d",decition.gear(),decition.mode());
|
|
|
}
|
|
|
|
|
|
+void UpdateTorqueBrake(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
|
|
|
+{
|
|
|
+ iv::controller::torquebrake xtb;
|
|
|
+ if(!xtb.ParseFromArray(strdata,nSize))
|
|
|
+ {
|
|
|
+ std::cout<<"UpdateTorqueBrake ParseFrom Array Error."<<std::endl;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ gMutextb.lock();
|
|
|
+ gtb.CopyFrom(xtb);
|
|
|
+ gMutextb.unlock();
|
|
|
+ gnothavetb= 0;
|
|
|
+}
|
|
|
+
|
|
|
void UpdateChassis(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
|
|
|
{
|
|
|
iv::chassis xchassis;
|
|
@@ -309,6 +353,7 @@ int main(int argc, char *argv[])
|
|
|
gpacansend = iv::modulecomm::RegisterSend(gstrmemcansend.data(),10000,1);
|
|
|
gpadecition = iv::modulecomm::RegisterRecv(gstrmemdecition.data(),ListenDeciton);
|
|
|
gpachassis = iv::modulecomm::RegisterRecv(gstrmemchassis.data(),UpdateChassis);
|
|
|
+ gpatorquebrake = iv::modulecomm::RegisterRecv("torquebrake",UpdateTorqueBrake);
|
|
|
|
|
|
|
|
|
if(gbAllowRemote)
|