|
@@ -20,34 +20,40 @@
|
|
|
|
|
|
#include <thread>
|
|
|
|
|
|
-void * gpacansend;
|
|
|
-void * gpadecition;
|
|
|
-void * gpachassis;
|
|
|
+#ifdef Q_OS_LINUX
|
|
|
+#include <signal.h>
|
|
|
+#endif
|
|
|
+
|
|
|
+static void * gpacansend;
|
|
|
+static void * gpadecition;
|
|
|
+static void * gpachassis;
|
|
|
|
|
|
-std::string gstrmemdecition;
|
|
|
-std::string gstrmemcansend;
|
|
|
-std::string gstrmemchassis;
|
|
|
-bool gbSendRun = true;
|
|
|
+static std::string gstrmemdecition;
|
|
|
+static std::string gstrmemcansend;
|
|
|
+static std::string gstrmemchassis;
|
|
|
+static bool gbSendRun = true;
|
|
|
|
|
|
-bool gbChassisEPS = false;
|
|
|
+static bool gbChassisEPS = false;
|
|
|
|
|
|
-iv::brain::decition gdecition_def;
|
|
|
-iv::brain::decition gdecition;
|
|
|
+static iv::brain::decition gdecition_def;
|
|
|
+static iv::brain::decition gdecition;
|
|
|
|
|
|
-QTime gTime;
|
|
|
-int gnLastSendTime = 0;
|
|
|
-int gnLastRecvDecTime = -1000;
|
|
|
-int gnDecitionNum = 0; //when is zero,send default;
|
|
|
+static QTime gTime;
|
|
|
+static int gnLastSendTime = 0;
|
|
|
+static int gnLastRecvDecTime = -1000;
|
|
|
+static int gnDecitionNum = 0; //when is zero,send default;
|
|
|
const int gnDecitionNumMax = 100;
|
|
|
-int gnIndex = 0;
|
|
|
+static int gnIndex = 0;
|
|
|
|
|
|
static bool gbHaveVehSpd = false;
|
|
|
static double gfVehSpd = 0.0;
|
|
|
|
|
|
-boost::shared_ptr<iv::control::Controller> gcontroller; //实际车辆控制器
|
|
|
+static boost::shared_ptr<iv::control::Controller> gcontroller; //实际车辆控制器
|
|
|
|
|
|
static QMutex gMutex;
|
|
|
|
|
|
+static std::thread * gpsendthread = NULL;
|
|
|
+
|
|
|
|
|
|
// signal: @ACC_LatAngReq //更改CANid
|
|
|
#define ECU_1C4_ACC_LatAngReq_CovFactor (0.1)
|
|
@@ -325,7 +331,7 @@ void Activate()
|
|
|
// for(int j=0;j<100000;j++)
|
|
|
// {
|
|
|
std::cout<<" run "<<std::endl;
|
|
|
- for(int i = 0; i < 10; i++){
|
|
|
+ for(int i = 0; i < 3; i++){
|
|
|
xdecition.set_wheelangle(0.0);
|
|
|
xdecition.set_angle_mode(0);
|
|
|
xdecition.set_angle_active(0);
|
|
@@ -338,7 +344,7 @@ void Activate()
|
|
|
ExecSend();
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
|
|
}
|
|
|
- for(int i = 0; i < 10; i++){
|
|
|
+ for(int i = 0; i < 3; i++){
|
|
|
xdecition.set_wheelangle(0.0);
|
|
|
xdecition.set_angle_mode(1);
|
|
|
xdecition.set_angle_active(1);
|
|
@@ -357,7 +363,7 @@ void Activate()
|
|
|
void UnAcitvate()
|
|
|
{
|
|
|
iv::brain::decition xdecition;
|
|
|
- for(int i = 0; i < 10; i++){
|
|
|
+ for(int i = 0; i < 3; i++){
|
|
|
xdecition.set_wheelangle(0);
|
|
|
xdecition.set_angle_mode(1);
|
|
|
xdecition.set_angle_active(1);
|
|
@@ -370,7 +376,7 @@ void UnAcitvate()
|
|
|
ExecSend();
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
|
|
}
|
|
|
- for(int i = 0; i < 10; i++){
|
|
|
+ for(int i = 0; i < 3; i++){
|
|
|
xdecition.set_wheelangle(0);
|
|
|
xdecition.set_angle_mode(0);
|
|
|
xdecition.set_angle_active(0);
|
|
@@ -563,8 +569,24 @@ void sendthread()
|
|
|
if(gbChassisEPS == false) ExecSend();
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
|
|
}
|
|
|
+ UnAcitvate();
|
|
|
}
|
|
|
|
|
|
+#ifdef Q_OS_LINUX
|
|
|
+void sig_int(int signo)
|
|
|
+{
|
|
|
+ gbSendRun = false;
|
|
|
+ gpsendthread->join();
|
|
|
+
|
|
|
+ iv::modulecomm::Unregister(gpacansend);
|
|
|
+ iv::modulecomm::Unregister(gpachassis);
|
|
|
+ iv::modulecomm::Unregister(gpadecition);
|
|
|
+
|
|
|
+ std::cout<<" controller exit."<<std::endl;
|
|
|
+ exit(0);
|
|
|
+}
|
|
|
+#endif
|
|
|
+
|
|
|
int main(int argc, char *argv[])
|
|
|
{
|
|
|
RegisterIVBackTrace();
|
|
@@ -619,5 +641,12 @@ int main(int argc, char *argv[])
|
|
|
|
|
|
std::thread xthread(sendthread);
|
|
|
|
|
|
+ gpsendthread = &xthread;
|
|
|
+
|
|
|
+#ifdef Q_OS_LINUX
|
|
|
+ signal(SIGINT, sig_int);
|
|
|
+ signal(SIGTERM,sig_int);
|
|
|
+#endif
|
|
|
+
|
|
|
return a.exec();
|
|
|
}
|