|
@@ -16,16 +16,19 @@
|
|
|
#include <thread>
|
|
|
|
|
|
#include "remotectrl.pb.h"
|
|
|
+#include "platform_feedback.pb.h"
|
|
|
|
|
|
QMutex gMutex;
|
|
|
|
|
|
void * gpacansend;
|
|
|
void * gpadecition;
|
|
|
void * gparemote;
|
|
|
+void * gpaPaltformFeedback;
|
|
|
|
|
|
std::string gstrmemdecition;
|
|
|
std::string gstrmemcansend;
|
|
|
std::string gstrmemremote; //Remote Ctrl
|
|
|
+std::string gstrmemPaltformFeedback;
|
|
|
|
|
|
bool gbSendRun = true;
|
|
|
|
|
@@ -39,6 +42,7 @@ bool gbAutoDriving = true; //if true, Auto Driving, false, remote controll
|
|
|
bool gbChassisEPS = true;
|
|
|
|
|
|
iv::brain::decition gdecition_remote;
|
|
|
+iv::platformFeedback gPlateformFeedback;
|
|
|
|
|
|
qint64 gLastRemoteTime = 0;
|
|
|
|
|
@@ -51,7 +55,6 @@ int gnIndex = 0;
|
|
|
|
|
|
boost::shared_ptr<iv::control::Controller> gcontroller; //实际车辆控制器
|
|
|
|
|
|
-
|
|
|
void executeDecition(const iv::brain::decition decition)
|
|
|
{
|
|
|
std::cout<<"acc is "<<decition.torque()<<" ang is "<<decition.wheelangle()<<std::endl;
|
|
@@ -66,7 +69,27 @@ void executeDecition(const iv::brain::decition decition)
|
|
|
gcontroller->control_drive_mode(decition.mode());
|
|
|
gcontroller->control_elec_brake(decition.handbrake());
|
|
|
gcontroller->control_brake_light(decition.brakelamp());
|
|
|
- gcontroller->control_dangwei(decition.gear());
|
|
|
+ gcontroller->control_dangwei(decition.gear()); //0P 1D 2R 3N
|
|
|
+
|
|
|
+ switch (decition.gear()) {
|
|
|
+ case 0:
|
|
|
+ gPlateformFeedback.set_shift(3); //0N 1D 2R 3P
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ gPlateformFeedback.set_shift(1); //0N 1D 2R 3P
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ gPlateformFeedback.set_shift(2); //0N 1D 2R 3P
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ gPlateformFeedback.set_shift(0); //0N 1D 2R 3P
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ gPlateformFeedback.set_throttle(decition.torque());
|
|
|
+ gPlateformFeedback.set_brake(decition.brake());
|
|
|
+ gPlateformFeedback.set_steeringwheelangle(decition.wheelangle());
|
|
|
}
|
|
|
|
|
|
|
|
@@ -87,10 +110,12 @@ void ListenRemotectrl(const char * strdata,const unsigned int nSize,const unsign
|
|
|
if(xrc.ntype() == iv::remotectrl_CtrlType_AUTO)
|
|
|
{
|
|
|
gbAutoDriving = true;
|
|
|
+ gPlateformFeedback.set_typefeedback(iv::platformFeedback::ctrlType::platformFeedback_ctrlType_AUTO);
|
|
|
}
|
|
|
else if(xrc.ntype() == iv::remotectrl_CtrlType_STOP)
|
|
|
{
|
|
|
gbAutoDriving = false;
|
|
|
+ gPlateformFeedback.set_typefeedback(iv::platformFeedback::ctrlType::platformFeedback_ctrlType_STOP);
|
|
|
xdecition.set_torque(0.0);
|
|
|
xdecition.set_brake(100.0);
|
|
|
xdecition.set_wheelangle(0.0);
|
|
@@ -111,6 +136,7 @@ void ListenRemotectrl(const char * strdata,const unsigned int nSize,const unsign
|
|
|
else
|
|
|
{
|
|
|
gbAutoDriving = false;
|
|
|
+ gPlateformFeedback.set_typefeedback(iv::platformFeedback::ctrlType::platformFeedback_ctrlType_REMOTE);
|
|
|
xdecition.set_torque(xrc.acc());
|
|
|
xdecition.set_brake(xrc.brake());
|
|
|
xdecition.set_wheelangle(xrc.wheel()*5.5f);
|
|
@@ -181,6 +207,16 @@ void ExecSend()
|
|
|
{
|
|
|
std::cout<<"MainWindow::onTimer serialize error."<<std::endl;
|
|
|
}
|
|
|
+
|
|
|
+ int ndatasize = gPlateformFeedback.ByteSize();
|
|
|
+ char * str = new char[ndatasize];
|
|
|
+ std::shared_ptr<char> pstr;pstr.reset(str);
|
|
|
+ if(!gPlateformFeedback.SerializeToArray(str,ndatasize))
|
|
|
+ {
|
|
|
+ std::cout<<"MainWindow::on_horizontalSlider_valueChanged serialize error."<<std::endl;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ iv::modulecomm::ModuleSendMsg(gpaPaltformFeedback,str,ndatasize);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -239,6 +275,13 @@ int main(int argc, char *argv[])
|
|
|
gdecition_def.set_brake(0);
|
|
|
gdecition_def.set_torque(0);
|
|
|
gdecition_def.set_speed(105);
|
|
|
+
|
|
|
+ gPlateformFeedback.set_typefeedback(iv::platformFeedback::ctrlType::platformFeedback_ctrlType_AUTO);
|
|
|
+ gPlateformFeedback.set_shift(3);
|
|
|
+ gPlateformFeedback.set_throttle(0.0);
|
|
|
+ gPlateformFeedback.set_brake(0.0);
|
|
|
+ gPlateformFeedback.set_steeringwheelangle(0.0);
|
|
|
+
|
|
|
gTime.start();
|
|
|
|
|
|
gcontroller = boost::shared_ptr<iv::control::Controller>(new iv::control::Controller());
|
|
@@ -248,6 +291,7 @@ int main(int argc, char *argv[])
|
|
|
gstrmemcansend = xp.GetParam("cansend","cansend0");
|
|
|
gstrmemdecition = xp.GetParam("dection","deciton");
|
|
|
gstrmemremote = xp.GetParam("remotectrl","remotectrl");
|
|
|
+ gstrmemPaltformFeedback = xp.GetParam("paltformFeedback","paltformFeedback");
|
|
|
|
|
|
std::string strremote = xp.GetParam("allowremote","true");
|
|
|
if(strremote == "true")
|
|
@@ -262,6 +306,7 @@ int main(int argc, char *argv[])
|
|
|
|
|
|
if(gbAllowRemote)
|
|
|
{
|
|
|
+ gpaPaltformFeedback = iv::modulecomm::RegisterSend(gstrmemPaltformFeedback.data(),10000,1);
|
|
|
gparemote = iv::modulecomm::RegisterRecv(gstrmemremote.data(),ListenRemotectrl);
|
|
|
}
|
|
|
|