Quellcode durchsuchen

change pilot_apollo_bridge_gui. remove modulecomm code and cyber code, for set for only system manager.

yuchuli vor 1 Monat
Ursprung
Commit
9209dbb9a9

+ 12 - 1
src/apollo/code/apollocontroller_shenlanfd/main.cpp

@@ -13,6 +13,14 @@
 #include "canmsg.pb.h"
 #include "modules/common_msgs/control_msgs/control_cmd.pb.h"
 
+#include "gflags/gflags.h"
+
+DECLARE_string(controller_msg_name);
+
+DEFINE_string(controller_msg_name, "/aplollo/controller",
+              "apllo controller name "
+              "set  for recve.");
+
 static bool gbthreadrun = true;
 static std::thread * gpthreadsend;
 
@@ -172,6 +180,9 @@ void RecvController(const std::shared_ptr<apollo::control::ControlCommand> &xcmd
 int main(int argc, char *argv[])
 {
 //    QCoreApplication a(argc, argv);
+    google::ParseCommandLineFlags(&argc, &argv, true);
+
+    std::cout<<" msg name: "<<FLAGS_controller_msg_name<<std::endl;
 
     apollo::cyber::Init("apollocontroller_shenlanfd");
     std::unique_ptr<apollo::cyber::Node> pilot_node  = apollo::cyber::CreateNode("apollocontroller_shenlanfd");
@@ -191,7 +202,7 @@ int main(int argc, char *argv[])
     );
 
     controller_reader_ = pilot_node->CreateReader<apollo::control::ControlCommand>(
-        "/aa",
+        FLAGS_controller_msg_name,
         [](const std::shared_ptr<apollo::control::ControlCommand> &xcmd){
             RecvController(xcmd);
         }

+ 2 - 0
src/apollo/code/conf/apollocontroller_shenlanfd.conf

@@ -0,0 +1,2 @@
+--controller_msg_name=/aplollo/controller
+

+ 11 - 0
src/apollo/code/launch/apollocontroller_shenlanfd.launch

@@ -0,0 +1,11 @@
+<cyber>
+    <module>
+        <name>apollocontroller_shenlanfd</name>
+        <dag_conf></dag_conf>
+        <type>binary</type>
+        <process_name>
+            apollocontroller_shenlanfd
+        </process_name>
+        <exception_handler>respawn</exception_handler>
+    </module>
+</cyber>

+ 0 - 11
src/apollo/code/pilot_apollo_bridge_gui/apolloctrlcmd.proto

@@ -1,11 +0,0 @@
-syntax = "proto2";
-
-package iv.apollo;
-
-message apolloctrlcmd
-{
-  required double steering_target = 1;
-  required double acceleration =2 ;//#m/s^2
-  required double brake = 3;
- 
-};

+ 0 - 82
src/apollo/code/pilot_apollo_bridge_gui/gpsimu.proto

@@ -1,82 +0,0 @@
-syntax = "proto2";
-
-package iv.gps;
-
-message pos_accuracy_def
-{
- optional double latstd = 1;
- optional double lonstd = 2;
- optional double hstd = 3;
-};
-
-message vel_accuracy_def
-{
- optional double vnstd = 1;
- optional double vestd = 2;
- optional double vdstd = 3;
-};
-
-message pose_accuracy_def
-{
- optional double rollstd = 1;
- optional double pitchstd = 2;
- optional double yawstd = 3;
-};
-
-message dev_temp_def
-{
- optional double temp = 1;
-};
-
-message gps_state_def
-{
- optional int32 pos_state = 1;
- optional int32 satnum = 2;
- optional int32 heading_state = 3;
-};
-
-message wheel_state_def
-{
- optional int32 wheeldata = 1;
-};
-
-
-
-message gpsimu
-{
- optional double pitch = 1;
- optional double roll = 2;
- optional double heading = 3;
- optional double gyro_x = 4; //惯导x轴角速度
- optional double gyro_y = 5; //惯导y轴角速度
- optional double gyro_z = 6; //惯导z轴角速度
- optional double acce_x = 7;
- optional double acce_y = 8;
- optional double acce_z = 9;
- optional double lat = 10;
- optional double lon = 11;
- optional double height = 12;
- optional double vn = 13;//北向速度
- optional double ve = 14;//东向速度
- optional double vd = 15;//地向速度
- optional int32 state = 16;
- optional int32 type = 17;
- optional pos_accuracy_def pos_accuracy = 18;
- optional vel_accuracy_def vel_accuracy = 19;
- optional dev_temp_def dev_temp = 20;
- optional gps_state_def gps_state = 21;
- optional wheel_state_def wheel_state = 22;
- optional double time = 23;
- optional bytes check = 24;
- optional pose_accuracy_def pose_accuracy = 25;
- optional int64 msgtime = 26;
- optional double rtk_state = 27;
- optional double ins_state = 28;
- optional double acc_calc = 29;
- optional int32 satnum1 = 30;
- optional int32 satnum2 = 31;
- optional int32 gpsweek = 32; //from 1980-1-6 weeks.
- optional int32 gpstime = 33; //from sunday 0:00:00 seconds.
- optional double speed = 34;
-
-};

+ 1 - 70
src/apollo/code/pilot_apollo_bridge_gui/mainwindow.cpp

@@ -12,21 +12,6 @@ MainWindow::MainWindow(QWidget *parent)
     apollo::cyber::Init("pilot_apollo_bridge_gui");
     pilot_node = apollo::cyber::CreateNode("pilot_apollo_bridge_gui");
 
-    mcmd_writer_ = pilot_node->CreateWriter<iv::apollo::apolloctrlcmd>("apcmd");
-    mgps_writer_ = pilot_node->CreateWriter<iv::gps::gpsimu>("/adc/gps");
-    mobj_writer_ = pilot_node->CreateWriter<iv::lidar::objectarray>("/adc/obj");
-    mcmd_reader_ = pilot_node->CreateReader<iv::apollo::apolloctrlcmd>("/adc/control",[this](const std::shared_ptr<iv::apollo::apolloctrlcmd>& cmd_ptr){
-        this->onControl(cmd_ptr);
-    });
-
-    ModuleFun fungpsimu =std::bind(&MainWindow::ListenGPSIMU,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
-    mpagps = iv::modulecomm::RegisterRecvPlus("hcp2_gpsimu",fungpsimu);
-
-    ModuleFun funlidartrack =std::bind(&MainWindow::ListenLiarTrack,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
-    mpaobj = iv::modulecomm::RegisterRecvPlus("lidar_track",funlidartrack);
-
-    mpactrl = iv::modulecomm::RegisterSend("apolloctrlcmd",10000,1);
-
     mpthreadtest = new std::thread(&MainWindow::threadtest,this);
 
     ui->pushButton_StartApollo->setEnabled(true);
@@ -67,9 +52,6 @@ MainWindow::~MainWindow()
     mbtestrun = false;
     mpthreadtest->join();
 
-    iv::modulecomm::Unregister(mpactrl);
-    iv::modulecomm::Unregister(mpaobj);
-    iv::modulecomm::Unregister(mpagps);
 
     std::this_thread::sleep_for(std::chrono::milliseconds(10));
 
@@ -78,18 +60,8 @@ MainWindow::~MainWindow()
 
 void MainWindow::threadtest()
 {
-    double wheel = -430.0;
-    while(mbtestrun && (apollo::cyber::OK())){
 
-        auto cmd_ptr = std::make_shared<iv::apollo::apolloctrlcmd>();
-        cmd_ptr->set_acceleration(0.0);
-        cmd_ptr->set_brake(0.0);
-
-        wheel = wheel+1.0;
-        cmd_ptr->set_steering_target(wheel);
-        if(wheel>=430.0)wheel = -430.0;
-
-        mcmd_writer_->Write(cmd_ptr);
+    while(mbtestrun && (apollo::cyber::OK())){
         std::this_thread::sleep_for(std::chrono::milliseconds(100));
     }
 }
@@ -195,46 +167,5 @@ void MainWindow::onProcessFinished(int nStatus)
     }
 }
 
-void MainWindow::ListenGPSIMU(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
-{
-//    std::cout<<" listen gpsimu."<<std::endl;
-    (void)index;
-    (void)dt;
-    (void)strmemname;
-//    iv::gps::gpsimu xgpsimu;
-    auto gpsimu_ptr = std::make_shared<iv::gps::gpsimu>();
-    if(!gpsimu_ptr->ParseFromArray(strdata,nSize))
-    {
-        std::cout<<"ListenRaw Parse error."<<std::endl;
-        return;
-    }
-    mgps_writer_->Write(gpsimu_ptr);
-}
 
-void MainWindow::ListenLiarTrack(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname){
-//  iv::lidar::objectarray xobjarray;
-    (void)index;
-    (void)dt;
-    (void)strmemname;
-
-//  std::cout<<" recv lidar track."<<std::endl;
-  auto obj_ptr = std::make_shared<iv::lidar::objectarray>();
-  if(!obj_ptr->ParseFromArray(strdata,nSize))
-  {
-    std::cout<<" Parse Object Array Fail."<<std::endl;
-    return;
-  }
-  mobj_writer_->Write(obj_ptr);
-}
 
-void MainWindow::onControl(const std::shared_ptr<iv::apollo::apolloctrlcmd> &xCmd)
-{
-    int nbytesize = (int)xCmd->ByteSize();
-    std::shared_ptr<char> pstr_ptr = std::shared_ptr<char>(new char[nbytesize]);
-    if(!xCmd->SerializeToArray(pstr_ptr.get(),nbytesize))
-    {
-        std::cout<<" send ctrlcmd Serialize Fail. "<<std::endl;
-        return;
-    }
-    iv::modulecomm::ModuleSendMsg(mpactrl,pstr_ptr.get(),nbytesize);
-}

+ 0 - 20
src/apollo/code/pilot_apollo_bridge_gui/mainwindow.h

@@ -7,16 +7,10 @@
 #include "cyber/time/rate.h"
 #include "cyber/time/time.h"
 
-#include "apolloctrlcmd.pb.h"
-#include  "gpsimu.pb.h"
-#include  "objectarray.pb.h"
-
 #include  <thread>
 
 #include <QProcess>
 
-#include "modulecomm.h"
-
 QT_BEGIN_NAMESPACE
 namespace Ui { class MainWindow; }
 QT_END_NAMESPACE
@@ -43,10 +37,6 @@ private:
 
 private:
     void threadtest();
-    void ListenGPSIMU(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname);
-    void ListenLiarTrack(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname);
-
-    void onControl(const std::shared_ptr<iv::apollo::apolloctrlcmd> &xCmd);
 
 private:
     std::unique_ptr<apollo::cyber::Node> pilot_node;
@@ -54,12 +44,6 @@ private:
     std::thread * mpthreadtest;
     bool mbtestrun = true;
 
-    std::shared_ptr<apollo::cyber::Writer<iv::apollo::apolloctrlcmd>> mcmd_writer_ = nullptr;
-    std::shared_ptr<apollo::cyber::Reader<iv::apollo::apolloctrlcmd>> mcmd_reader_ = nullptr;
-
-
-    std::shared_ptr<apollo::cyber::Writer<iv::gps::gpsimu>> mgps_writer_ = nullptr;
-    std::shared_ptr<apollo::cyber::Writer<iv::lidar::objectarray>> mobj_writer_ = nullptr;
 
     QProcess mProc;
     bool mbDreamviewRunning = false;
@@ -74,10 +58,6 @@ private:
     QProcess mProcStopMonitor;
     bool mbProcStopApolloRunning = false;
 
-    void * mpagps;
-    void * mpaobj;
-    void * mpactrl;
-
 
 
 };

+ 0 - 80
src/apollo/code/pilot_apollo_bridge_gui/modulecomm.h

@@ -1,80 +0,0 @@
-#ifndef MODULECOMM_H
-#define MODULECOMM_H
-
-
-//#include <QtCore/qglobal.h>
-#include <QDateTime>
-
-#include <functional>
-
-
-
-
-#if defined(MODULECOMM_LIBRARY)
-#  define MODULECOMMSHARED_EXPORT Q_DECL_EXPORT
-#else
-#  define MODULECOMMSHARED_EXPORT Q_DECL_IMPORT
-#endif
-
-
-
-
-
-
-//#include <iostream>
-//#include <thread>
-
-//using namespace std::placeholders;
-
-#ifndef IV_MODULE_FUN
-
-typedef std::function<void(const char * ,const unsigned int , const unsigned int , QDateTime * ,const char *)> ModuleFun;
-typedef void (* SMCallBack)(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname);
-#define IV_MODULE_FUN
-#endif
-
-namespace iv {
-namespace modulecomm {
-
-enum ModuleComm_TYPE
-{
-    ModuleComm_SHAREMEM = 0,
-    ModuleComm_INTERIOR = 1,
-    ModuleComm_FASTRTPS = 2,
-    ModuleComm_FASTRTPS_TCP = 3,
-    ModuleComm_UNDEFINE = 4
-};
-
-void *  RegisterSend(const char * strcommname);
-
-
-void *  RegisterSend(const char * strcommname,const unsigned int nBufSize,const unsigned int nMsgBufCount
-                                            ,ModuleComm_TYPE xmctype,const unsigned short nport);
-void *  RegisterRecv(const char * strcommname,SMCallBack pCall,
-                                            ModuleComm_TYPE xmctype ,const char * strip,const unsigned short );
-void *  RegisterRecvPlus(const char * strcommname,ModuleFun xFun,
-                                                ModuleComm_TYPE xmctype,const char * strip,const unsigned short );
-
-
-//void * MODULECOMMSHARED_EXPORT RegisterSend(const char * strcommname,const unsigned int nBufSize,const unsigned int nMsgBufCount
-//                                            ,ModuleComm_TYPE xmctype = ModuleComm_UNDEFINE,const unsigned short nport = 5100);
-//void * MODULECOMMSHARED_EXPORT RegisterRecv(const char * strcommname,SMCallBack pCall,
-//                                            ModuleComm_TYPE xmctype = ModuleComm_UNDEFINE,const char * strip = 0,const unsigned short = 5100);
-//void * MODULECOMMSHARED_EXPORT RegisterRecvPlus(const char * strcommname,ModuleFun xFun,
-//                                                ModuleComm_TYPE xmctype = ModuleComm_UNDEFINE,const char * strip = 0,const unsigned short = 5100);
-
-void MODULECOMMSHARED_EXPORT ModuleSendMsg(void * pHandle,const char * strdata,const unsigned int nDataLen);
-void MODULECOMMSHARED_EXPORT Unregister(void * pHandle);
-void MODULECOMMSHARED_EXPORT PauseComm(void * pHandle);
-void MODULECOMMSHARED_EXPORT ContintuComm(void * pHandle);
-
-void *  RegisterSend(const char * strcommname,const unsigned int nBufSize,const unsigned int nMsgBufCount);
-void *  RegisterRecv(const char * strcommname,SMCallBack pCall);
-void *  RegisterRecvPlus(const char * strcommname,ModuleFun xFun);
-
-
-}
-
-}
-
-#endif // MODULECOMM_H

+ 0 - 59
src/apollo/code/pilot_apollo_bridge_gui/objectarray.proto

@@ -1,59 +0,0 @@
-syntax = "proto2";
-
-package iv.lidar;
-
-
-message PointXYZI {
-  optional float x = 1 [default = nan];
-  optional float y = 2 [default = nan];
-  optional float z = 3 [default = nan];
-  optional float i = 4 [default = 0];
-};
-
-message PointXYZ {
-  optional float x = 1 [default = nan];
-  optional float y = 2 [default = nan];
-  optional float z = 3 [default = nan];
-};
-
-message Dimension {
-  optional float x = 1 [default = 0];
-  optional float y = 2 [default = 0];
-  optional float z = 3 [default = 0];
-};
-
-message VelXY {
-  optional float x =1 [default = 0];
-  optional float y =2 [default = 0];
-};
-
-message lidarobject
-{
-  optional PointXYZ min_point = 1;
-  optional PointXYZ max_point = 2;
-  optional PointXYZ centroid = 3;
-  optional Dimension dimensions = 4;
-  optional PointXYZ position = 5;
-  optional double angle =6;
-  optional double velocity_linear_x = 7;
-  optional double acceleration_linear_y = 8;
-  optional double timestamp = 9;
-  optional double tyaw = 10;
-  required int32 mnType = 11;
-  optional int32 id = 12;
-  optional int32 behavior_state = 13;
-  optional float score = 14;
-  optional bool velocity_reliable = 15;
-  optional bool pose_reliable = 16;
-  repeated float type_probs = 17;
-  repeated PointXYZI cloud = 18;
-  optional string type_name = 19;
-  optional VelXY vel_relative = 20; //相对速度
-};
-
-
-message objectarray
-{
-  repeated lidarobject obj = 1;
-  optional double timestamp = 2;
-};

+ 2 - 10
src/apollo/code/pilot_apollo_bridge_gui/pilot_apollo_bridge_gui.pro

@@ -16,18 +16,11 @@ DEFINES += QT_DEPRECATED_WARNINGS
 #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
 
 SOURCES += \
-    apolloctrlcmd.pb.cc \
-    gpsimu.pb.cc \
     main.cpp \
-    mainwindow.cpp \
-    objectarray.pb.cc
+    mainwindow.cpp
 
 HEADERS += \
-    apolloctrlcmd.pb.h \
-    gpsimu.pb.h \
-    mainwindow.h \
-    modulecomm.h \
-    objectarray.pb.h
+    mainwindow.h
 
 FORMS += \
     mainwindow.ui
@@ -73,4 +66,3 @@ LIBS += -L/usr/local/lib/ -lbvar
 
 LIBS += -L/opt/apollo/neo/lib/3rd-protobuf -lprotobuf
 
-LIBS += -L/usr/local/lib -lmodulecomm