Bläddra i källkod

添加智能大会 云平台模块

lijinliang 4 år sedan
förälder
incheckning
e07d59ed2c

+ 25 - 0
src/v2x/v2xTcpClientWL/Readme.md

@@ -0,0 +1,25 @@
+# 简介
+网连云平台,针对智能大会期间开发的客户端。使用TCP/IP 协议传输。
+具体协议参考doc/智能网连数据采集规范.pdf
+协议范例:
+```
+2323 03fe 4c5a595441474257354b31303439323831 31363136353733333731323533 000000000000000000 01 00 00d6
+01020020目标物数据
+010104e204e200780078007800780078010104e204e200780078007800780078
+02020010位置数据
+06c68be302130d2606d8e9b4026dcd96
+03020058决策数据
+0410100010021010002001001000100010001000100002201000100210100020010010001000100010001000
+04020020整车性能数据
+0010000800020000001000100010001000200008000200000010001000100010
+05010018整车状态数据
+010101010101010101010001010101000101001000100101
+0701000c道路信息数据
+005a00100101780101010100
+08010004自然环境数
+0101001c
+09010003
+010101
+0a01000b
+0101010101010101010101
+```

+ 51 - 0
src/v2x/v2xTcpClientWL/boost.h

@@ -0,0 +1,51 @@
+#pragma once
+
+#ifndef _IV_BOOST_H_
+#define _IV_BOOST_H_
+
+#if defined __GNUC__
+#  pragma GCC system_header 
+#endif
+#ifndef __CUDACC__
+//https://bugreports.qt-project.org/browse/QTBUG-22829
+#ifndef Q_MOC_RUN
+#include <boost/version.hpp>
+#include <boost/numeric/conversion/cast.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/condition.hpp>
+#include <boost/thread.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/filesystem.hpp>
+#include <boost/bind.hpp>
+#include <boost/cstdint.hpp>
+#include <boost/function.hpp>
+#include <boost/tuple/tuple.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+#include <boost/mpl/fold.hpp>
+#include <boost/mpl/inherit.hpp>
+#include <boost/mpl/inherit_linearly.hpp>
+#include <boost/mpl/joint_view.hpp>
+#include <boost/mpl/transform.hpp>
+#include <boost/mpl/vector.hpp>
+#include <boost/algorithm/string.hpp>
+#ifndef Q_MOC_RUN
+#include <boost/date_time/posix_time/posix_time.hpp>
+#endif
+#if BOOST_VERSION >= 104700
+#include <boost/chrono.hpp>
+#endif
+#include <boost/tokenizer.hpp>
+#include <boost/foreach.hpp>
+#include <boost/shared_array.hpp>
+#include <boost/interprocess/sync/file_lock.hpp>
+#if BOOST_VERSION >= 104900
+#include <boost/interprocess/permissions.hpp>
+#endif
+#include <boost/iostreams/device/mapped_file.hpp>
+#define BOOST_PARAMETER_MAX_ARITY 7
+#include <boost/signals2.hpp>
+#include <boost/signals2/slot.hpp>
+#endif
+#endif
+#endif    // _IV_BOOST_H_

+ 203 - 0
src/v2x/v2xTcpClientWL/data_type.h

@@ -0,0 +1,203 @@
+#ifndef DATA_TYPE_H
+#define DATA_TYPE_H
+/// cameral status, 2019-10-18
+#include <vector>
+#include <stdint.h>
+#include <iostream>
+
+typedef uint8_t u8;
+typedef uint16_t u16;
+typedef uint32_t u32;
+
+enum DownID { StopCommand = 1, AutoPilotControl, StationCommand };
+//1目标物数据
+struct ObsTypeData
+{
+    u8 msgSig = 1;
+    u8 msgRate = 1;
+    u8 msgSize = 16; //0x20
+    u8 obsType = 0xFF;
+    u8 obsSt = 0xFF;
+    u8 hDisH = 0xFF;
+    u8 hDisL = 0;
+    u8 vDisH = 0xFF;
+    u8 vDisL = 0;
+    u8 hSpeedH = 0xFF;
+    u8 hSpeedL = 0;
+    u8 vSpeedH = 0xFF;
+    u8 vSpeedL = 0;
+    u8 obsLengthH = 0xFF;
+    u8 obsLengthL = 0xFF;
+    u8 obsHightH = 0xFF;
+    u8 obsHightL = 0;
+    u8 obsWigthH = 0xFF;
+    u8 obsWigthL = 0xFF;
+};
+//2位置数据 @
+struct LocationData
+{
+    u8 msgSig = 2;
+    u8 msgRate = 1;
+
+    u8 msgSize = 8; //0x8
+    u8 lonH1 = 0;
+    u8 lonH0 = 0;
+    u8 lonL1 = 0;
+    u8 lonL0 = 0;
+    u8 latH1 = 0;
+    u8 latH0 = 0;
+    u8 latL1 = 0;
+    u8 latL0 = 0;
+};
+//3决策数据 @
+struct DecisionData
+{
+    u8 msgSig = 3;
+    u8 msgRate = 1;
+    u8 msgSize = 22;
+    u8 gear = 0;
+    u8 accPad = 0xFF;
+    u8 brakePad = 0xFF;
+    u8 epsAngleH = 0xFF; //@
+    u8 epsAngleL = 0; //@
+    u8 gearReq = 0;
+    u8 hAccAdReqH = 0;
+    u8 hAccAdReqL = 0;
+    u8 vAccAdReqH = 0;
+    u8 vAccAdReqL = 0;
+    u8 epsAngleAdReqH1 = 0;
+    u8 epsAngleAdReqH0 = 0;
+    u8 epsAngleAdReqL1 = 0;
+    u8 epsAngleAdReqL0 = 0;
+    u8 epsPowerAdReqH = 0;
+    u8 epsPowerAdReqL = 0;
+    u8 vPowerAdReqH = 0;
+    u8 vPowerAdReqL = 0;
+    u8 lightAdReqH = 0;
+    u8 lightAdReqL = 0;
+    u8 wiperAdReqH = 0;
+    u8 wiperAdReqL = 0;
+    u8 controllOver = 0;
+};
+//4整车性能数据
+struct VehiclePerfData
+{
+    u8 msgSig = 4;
+    u8 msgRate = 1;
+    u8 msgSize = 16;
+    u8 speedH = 0xFF; //@
+    u8 speedL = 0xFF; //@
+    u8 hAccH = 0; //@
+    u8 hAccL = 0; //@
+    u8 vAccH = 0; //@
+    u8 vAccL = 20; //@
+    u8 headingH1 = 0;//@
+    u8 headingH0 = 0;//@
+    u8 headingL1 = 0;//@
+    u8 headingL0 = 0;//@
+    u8 yawSpeedH = 0;
+    u8 yawSpeedL = 0;
+    u8 rollSpeedH = 0;
+    u8 rollSpeedL = 0;
+    u8 pitchSpeedH = 0;
+    u8 pitchSpeedL = 0;
+};
+
+//5整车状态数据
+struct VehicleStData
+{
+    u8 msgSig = 5;
+    u8 msgRate = 1;
+    u8 msgSize = 24;
+    u8 powerSt = 0xFF;
+    u8 ctrlMode = 0xFF; //@
+    u8 driMode = 0xFF;
+    u8 chargeMode = 0xFF;
+    u8 gearSt = 0;
+    u8 brakeSt = 0xFF;
+    u8 lightSt = 0xFF;
+    u8 batterySt = 0xFF;
+    u8 oilMassSt = 0xFF;
+    u8 batteryLvSt = 0xFF;
+    u8 meilageH1 = 0xE3;//@
+    u8 meilageH0 = 0xFF;//@
+    u8 meilageL1 = 0;//@
+    u8 meilageL0 = 0;//@
+    u8 wiperSt = 0xFF;
+    u8 netSt = 0xFF;
+    u8 signalSt = 0xFF;
+    u8 upSpeedH = 0xF0;
+    u8 upSpeedL = 0;
+    u8 downSpeedH = 0xE0;
+    u8 downSpeedL = 0;
+    u8 AFS = 0x02;
+    u8 ESC = 0x3;
+};
+
+////6路测设施数据
+//struct1
+//{
+//    u8 msgSig = 6;
+//    u8 msgRate = 1;
+//    u8 msgSize = ;
+//};
+////7道路信息数据
+//struct
+//{
+//    u8 msgSig = 7;
+//    u8 msgRate = 1;
+//    u8 msgSize = ;
+//};
+////8自然环境数据
+//struct
+//{
+//    u8 msgSig = 8;
+//    u8 msgRate = 1;
+//    u8 msgSize = ;
+//};
+////9人员数据
+//struct
+//{
+//    u8 msgSig = 9;
+//    u8 msgRate = 1;
+//    u8 msgSize = ;
+//};
+//10部件数据
+struct ComponsData
+{
+    u8 msgSig = 0x0A;
+    u8 msgRate = 1;
+    u8 msgSize = 11;
+    u8 SRSSt = 0xFF;
+    u8 GNSSST = 0xFF;
+    u8 IMUSt = 0xFF;
+    u8 ADSysSt = 0x01;//@
+    u8 mapSt = 0xFF;
+    u8 OBUSt = 0xFF;
+    u8 cameraSt = 0xFF;
+    u8 lidarSt = 0xFF;
+    u8 ultraSt = 0xFF;
+    u8 radarSt = 0xFF;
+    u8 nightVision = 0xFF;
+};
+
+//数据包
+struct UpdatePack
+{
+    u8 head1 = 0x23;
+    u8 head2 = 0x23;
+    u8 cmdSig = 0x03;
+    u8 askSig = 0xfe;
+//    std::string carVIN= "A1S2D3F4G5H6J7126;
+    u8 carVIN[17] ;
+//    std::string timeStamp;
+    u8 timeStamp[13] = {0};
+//    std::string msgId = "000000000";
+    u8 msgID[9] = {0};
+    u8 encryType = 0x01;
+    u8 dataRate = 0;
+    u8 dataSizeL = 0;
+    u8 dataSizeH = 0;
+};
+
+#endif // DATA_TYPE_H

+ 61 - 0
src/v2x/v2xTcpClientWL/decition_type.h

@@ -0,0 +1,61 @@
+#pragma once
+#ifndef _IV_DECITION_DECITION_TYPE_
+#define _IV_DECITION_DECITION_TYPE_
+#include "boost.h"
+namespace iv {
+namespace decition {
+struct DecitionBasic {
+    float speed;				//车速
+    float wheel_angle;			//转向角度
+    float brake;				//刹车
+    float accelerator;			//油门
+    float torque;               //力矩
+    bool leftlamp;				//左转向灯
+    bool rightlamp;				//右转向灯
+
+    int  engine;
+    int  grade;
+    int  mode;
+    int handBrake;
+    bool speak;
+    bool door;
+    bool bright;
+    int dangWei;
+
+    float angSpeed;
+    int brakeType :1;
+    char brakeEnable;  //add by fjk
+    bool left;         //add by fjk
+    bool right;        //add by fjk
+
+    bool angleEnable;
+    bool speedEnable;
+    bool dangweiEnable;
+    int  driveMode;
+
+    int directLight;
+    int brakeLight;
+    int backLight;
+    int topLight;
+
+    int farLight;
+    int nearLight;
+
+
+
+    bool   air_enable ;                  //空调使能
+    bool   air_on;
+    float   air_temp ;                  //空调温度
+    float   air_mode ;                  //空调模式
+    float   wind_level ;                  //空调风力
+    float   roof_light ;                  //顶灯
+    float   home_light ;                  //日光灯
+    float   air_worktime ;                  //空调工作时间
+    float   air_offtime ;                  //空调关闭时间
+
+};
+typedef boost::shared_ptr<DecitionBasic> Decition;	//决策
+}
+}
+#endif // !_IV_DECITION_DECITION_TYPE_
+

+ 154 - 0
src/v2x/v2xTcpClientWL/gnss_coordinate_convert.cpp

@@ -0,0 +1,154 @@
+#include <gnss_coordinate_convert.h>
+
+void gps2xy(double J4, double K4, double *x, double *y)
+{
+    int L4 = (int)((K4 - 1.5) / 3) + 1;
+    double M4 = K4 - (L4 * 3);
+    double N4 = sin(J4 * 3.1415926536 / 180);
+    double O4 = cos(J4 * 3.1415926536 / 180);
+    double P4 = tan(J4 * 3.1415926536 / 180);
+    double Q4 = 111134.8611 * J4 - N4 * O4 * (32005.7799 + 133.9238 * N4 * N4 + 0.6973 * N4 * N4 * N4 * N4 + 0.0039 * N4 * N4 * N4 * N4 * N4 * N4);
+    double R4 = sqrt(0.006738525414683) * O4;
+    double S4 = sqrt(1 + R4 * R4);
+    double T4 = 6399698.901783 / S4;
+    double U4 = (T4 / S4) / S4;
+    double V4 = O4 * M4 * 3.1415926536 / 180;
+    double W4 = 0.5 + (5 - P4 * P4 + 9 * R4 * R4 + 4 * R4 * R4 * R4 * R4) * V4 * V4 / 24;
+    double X4 = V4 * V4 * V4 * V4 / 720 * (61 + (P4 * P4 - 58) * P4 * P4);
+    double Y4 = 1 + V4 * V4 * (1 - P4 * P4 + R4 * R4) / 6;
+    double Z4 = V4 * V4 * V4 * V4 * (5 - 18 * P4 * P4 * P4 * P4 * P4 * P4 + 14 * R4 * R4 - 58 * R4 * R4 * P4 * P4) / 120;
+
+    *y = Q4 + T4 * P4 * V4 * V4 * (W4 + X4);
+    *x = 500000 + T4 * V4 * (Y4 + Z4);
+}
+
+
+
+//高斯投影由经纬度(Unit:DD)反算大地坐标(含带号,Unit:Metres)
+void GaussProjCal(double longitude, double latitude, double *X, double *Y)
+{
+    int ProjNo = 0; int ZoneWide; ////带宽
+    double longitude1, latitude1, longitude0, latitude0, X0, Y0, xval, yval;
+    double a, f, e2, ee, NN, T, C, A, M, iPI;
+    iPI = 0.0174532925199433; ////3.1415926535898/180.0;
+    ZoneWide = 6; ////6度带宽
+    a = 6378245.0; f = 1.0 / 298.3; //54年北京坐标系参数
+                                    ////a=6378140.0; f=1/298.257; //80年西安坐标系参数
+    ProjNo = (int)(longitude / ZoneWide);
+    longitude0 = ProjNo * ZoneWide + ZoneWide / 2;
+    longitude0 = longitude0 * iPI;
+    latitude0 = 0;
+    longitude1 = longitude * iPI; //经度转换为弧度
+    latitude1 = latitude * iPI; //纬度转换为弧度
+    e2 = 2 * f - f * f;
+    ee = e2 * (1.0 - e2);
+    NN = a / sqrt(1.0 - e2 * sin(latitude1)*sin(latitude1));
+    T = tan(latitude1)*tan(latitude1);
+    C = ee * cos(latitude1)*cos(latitude1);
+    A = (longitude1 - longitude0)*cos(latitude1);
+    M = a * ((1 - e2 / 4 - 3 * e2*e2 / 64 - 5 * e2*e2*e2 / 256)*latitude1 - (3 * e2 / 8 + 3 * e2*e2 / 32 + 45 * e2*e2
+        *e2 / 1024)*sin(2 * latitude1)
+        + (15 * e2*e2 / 256 + 45 * e2*e2*e2 / 1024)*sin(4 * latitude1) - (35 * e2*e2*e2 / 3072)*sin(6 * latitude1));
+    xval = NN * (A + (1 - T + C)*A*A*A / 6 + (5 - 18 * T + T * T + 72 * C - 58 * ee)*A*A*A*A*A / 120);
+    yval = M + NN * tan(latitude1)*(A*A / 2 + (5 - T + 9 * C + 4 * C*C)*A*A*A*A / 24
+        + (61 - 58 * T + T * T + 600 * C - 330 * ee)*A*A*A*A*A*A / 720);
+    X0 = 1000000L * (ProjNo + 1) + 500000L;
+    Y0 = 0;
+    xval = xval + X0; yval = yval + Y0;
+    *X = xval;
+    *Y = yval;
+}
+
+
+/*
+//=======================zhaobo0904
+#define PI  3.14159265358979
+void GaussProjCal(double lon, double lat, double *X, double *Y)
+{
+    // 1975 年国际椭球体长半轴 a, 第一离心率 e2, 第二离心率 ep2
+    double a = 6378140.0;
+    double e2 = 0.006694384999588;
+    double ep2 = e2/(1-e2);
+
+    // 原点所在经度
+    double lon_origin = 6.0*int(lon/6) + 3.0;
+    lon_origin *= PI / 180.0;
+
+    double k0 = 0.9996;
+
+    // 角度转弧度
+    double lat1 = lat * PI / 180.0;
+    double lon1 = lon * PI / 180.0;
+
+
+    // 经线在该点处的曲率半径,
+    double N = a / sqrt(1 - e2*sin(lat1)*sin(lat1));
+
+
+    // 赤道到该点的经线长度近似值 M, 使用泰勒展开逐项积分然后取前四项.
+    // 这个近似值是将 N 作为纬度 \phi 的函数展开为泰勒计数, 然后在区间 [0, lat1] 上积分得到的.
+    // 首先计算前四项的系数 a1~a4.
+    double a1 = 1 - e2/4 - (3*e2*e2)/64 - (5*e2*e2*e2)/256;
+    double a2 = (3*e2)/8 + (3*e2*e2)/32 + (45*e2*e2*e2)/1024;
+    double a3 = (15*e2*e2)/256 + (45*e2*e2*e2)/1024;
+    double a4 = (35*e2*e2*e2)/3072;
+    double M = a * (a1*lat1 - a2*sin(2*lat1) + a3*sin(4*lat1) - a4*sin(6*lat1));
+
+    // 辅助量
+    double T = tan(lat1)*tan(lat1);
+    double C = ep2*cos(lat1)*cos(lat1);
+    double A = (lon1 - lon_origin)*cos(lat1);
+
+    *X = 500000.0 + k0 * N * (A + (1 - T + C)*(A*A*A)/6 + (5 - 18*T + T*T + 72*C - 58*ep2)*(A*A*A*A*A)/120);
+    *Y = M + N * tan(lat1) * ((A*A)/2 +
+                              (5 - T + 9*C + 4*C*C)*(A*A*A*A)/24 +
+                              (61 - 58*T + T*T + 600*C - 330*ep2)*(A*A*A*A*A*A)/720);
+
+
+    *Y *= k0;
+    return;
+}
+//==========================================================
+
+*/
+
+
+//高斯投影由大地坐标(Unit:Metres)反算经纬度(Unit:DD)
+void GaussProjInvCal(double X, double Y, double *longitude, double *latitude)
+{
+    int ProjNo; int ZoneWide; ////带宽
+    double longitude1, latitude1, longitude0, latitude0, X0, Y0, xval, yval;
+    double e1, e2, f, a, ee, NN, T, C, M, D, R, u, fai, iPI;
+    iPI = 0.0174532925199433; ////3.1415926535898/180.0;
+    a = 6378245.0; f = 1.0 / 298.3; //54年北京坐标系参数
+    ////a=6378140.0; f=1/298.257; //80年西安坐标系参数
+    ZoneWide = 6; ////6度带宽
+    ProjNo = (int)(X / 1000000L); //查找带号
+    longitude0 = (ProjNo - 1) * ZoneWide + ZoneWide / 2;
+    longitude0 = longitude0 * iPI; //中央经线
+    X0 = ProjNo * 1000000L + 500000L;
+    Y0 = 0;
+    xval = X - X0; yval = Y - Y0; //带内大地坐标
+    e2 = 2 * f - f * f;
+    e1 = (1.0 - sqrt(1 - e2)) / (1.0 + sqrt(1 - e2));
+    ee = e2 / (1 - e2);
+    M = yval;
+    u = M / (a*(1 - e2 / 4 - 3 * e2*e2 / 64 - 5 * e2*e2*e2 / 256));
+    fai = u + (3 * e1 / 2 - 27 * e1*e1*e1 / 32)*sin(2 * u) + (21 * e1*e1 / 16 - 55 * e1*e1*e1*e1 / 32)*sin(
+                4 * u)
+            + (151 * e1*e1*e1 / 96)*sin(6 * u) + (1097 * e1*e1*e1*e1 / 512)*sin(8 * u);
+    C = ee * cos(fai)*cos(fai);
+    T = tan(fai)*tan(fai);
+    NN = a / sqrt(1.0 - e2 * sin(fai)*sin(fai));
+    R = a * (1 - e2) / sqrt((1 - e2 * sin(fai)*sin(fai))*(1 - e2 * sin(fai)*sin(fai))*(1 - e2 * sin
+                                                                                       (fai)*sin(fai)));
+    D = xval / NN;
+    //计算经度(Longitude) 纬度(Latitude)
+    longitude1 = longitude0 + (D - (1 + 2 * T + C)*D*D*D / 6 + (5 - 2 * C + 28 * T - 3 * C*C + 8 * ee + 24 * T*T)*D
+                               *D*D*D*D / 120) / cos(fai);
+    latitude1 = fai - (NN*tan(fai) / R)*(D*D / 2 - (5 + 3 * T + 10 * C - 4 * C*C - 9 * ee)*D*D*D*D / 24
+                                         + (61 + 90 * T + 298 * C + 45 * T*T - 256 * ee - 3 * C*C)*D*D*D*D*D*D / 720);
+    //转换为度 DD
+    *longitude = longitude1 / iPI;
+    *latitude = latitude1 / iPI;
+}

+ 26 - 0
src/v2x/v2xTcpClientWL/gnss_coordinate_convert.h

@@ -0,0 +1,26 @@
+#pragma once
+#ifndef _IV_PERCEPTION_GNSS_CONVERT_
+#define _IV_PERCEPTION_GNSS_CONVERT_
+
+#include <math.h>
+//double nmeaConvert2Lat(string lat)
+//{
+//	Console.WriteLine(lat);
+//	double nmea_d = double.Parse(lat.Substring(0, 2));
+//	double nmea_m = double.Parse(lat.Substring(2, 6));
+//	return nmea_d + nmea_m / 60;
+//}
+//
+//double nmeaConvert2Lon(string lon)
+//{
+//	Console.WriteLine(lon);
+//	double nmea_d = double.Parse(lon.Substring(0, 3));
+//	double nmea_m = double.Parse(lon.Substring(3, 7));
+//	return nmea_d + nmea_m / 60;
+//}
+
+void gps2xy(double , double , double *, double *);
+void GaussProjCal(double longitude, double latitude, double *X, double *Y);
+void GaussProjInvCal(double X, double Y, double *longitude, double *latitude);
+
+#endif // !_IV_PERCEPTION_GNSS_CONVERT_

+ 141 - 0
src/v2x/v2xTcpClientWL/gps_type.h

@@ -0,0 +1,141 @@
+#pragma once
+/*
+*GPS 惯导数据
+*/
+#ifndef _IV_COMMON_GPS_TYPE_
+#define _IV_COMMON_GPS_TYPE_
+
+#include <boost.h>
+namespace iv {
+    struct GPS_INS
+    {
+        int valid = 0xff;
+        int index = 0;	//gps点序号
+
+        double gps_lat = 0;//纬度
+        double gps_lng = 0;//经度
+
+        double gps_x = 0;
+        double gps_y = 0;
+        double gps_z = 0;
+
+        double ins_roll_angle = 0;	//横滚角 一般定义载体的右、前、上三个方向构成右手系,绕向前的轴旋转就是横滚角,绕向右的轴旋转就是俯仰角,绕向上的轴旋转就是航向角
+        double ins_pitch_angle = 0;	//俯仰角
+        double ins_heading_angle = 0;	//航向角
+
+        int ins_status = 0;	//惯导状态 4
+        int rtk_status = 0;	//rtk状态 6 -5 -3
+        int gps_satelites_num = 0;
+
+        //-----加速度--------------
+        double accel_x = 0;
+        double accel_y = 0;
+        double accel_z = 0;
+
+        //-------角速度------------
+        double ang_rate_x = 0;
+        double ang_rate_y = 0;
+        double ang_rate_z = 0;
+
+        //-----------方向速度--------------
+        double vel_N = 0;
+        double vel_E = 0;
+        double vel_D = 0;
+
+        int speed_mode = 0;
+        int mode2 = 0;
+        double speed = 0;			//速度  若导航点则为导航预设速度  若为当前点则为当前车速
+
+        int roadMode;
+        int runMode;
+        int roadSum;
+        int roadOri;
+
+    double mfLaneWidth = 3.5; // Current Lane Width
+
+    double mfDisToLaneLeft = 1.8; //Distance to Lane Left
+    int mnLaneChangeMark = 0; //1 to Left 0 not change   -1 to right
+    double mfDisToRoadLeft = 1.8; //Distance to Road Left
+    double mfRoadWidth = 3.5; // Road Width
+
+        bool mbInLaneAvoid = false; //if true suport In Lane Avoid
+        double gps_lat_avoidleft;
+        double gps_lng_avoidleft;
+        double gps_lat_avoidright;
+        double gps_lng_avoidright;
+        double gps_x_avoidleft = 0;
+        double gps_y_avoidleft = 0;
+        double gps_x_avoidright = 0;
+        double gps_y_avoidright = 0;
+
+
+
+    };
+
+//    typedef std::shared_ptr<iv::GPS_INS> GPSData;
+    typedef boost::shared_ptr<iv::GPS_INS> GPSData;
+     class Point2D
+    {
+      public:
+          double x = 0, y = 0, speed=0,obs_speed_x=0,obs_speed_y=0;
+         int v1 = 0, v2 = 0;
+         int roadMode = 0;
+         int obs_type=0;
+
+         Point2D()
+        {
+            x = y = v1 = 0;
+        }
+
+         Point2D(double _x, double _y)
+        {
+            x = _x; y = _y;
+        }
+
+
+     };
+
+
+     class TrafficLight
+    {
+      public:
+         int leftColor = 0, rightColor = 0, straightColor=0, uturnColor=0;
+         int leftTime=0, rightTime=0 ,straightTime=0, uturnTime=0;
+
+         TrafficLight()
+        {
+            leftColor = 0, rightColor = 0, straightColor=0, uturnColor=0;
+            leftTime=0, rightTime=0 ,straightTime=0, uturnTime=0;
+        }
+
+     };
+     class StationCmd
+     {
+     public:
+         bool received;
+         uint32_t carID,carMode,emergencyStop,stationStop;
+         bool has_carID,has_carMode,has_emergencyStop,has_stationStop,mode_manual_drive;
+         uint32_t stationID[20];
+         GPS_INS  stationGps[20];
+         uint32_t stationTotalNum;
+         StationCmd()
+         {
+             received=false;
+             has_carID=false;
+             has_carMode=false;
+             has_emergencyStop=false;
+             has_stationStop=false;
+             mode_manual_drive=false;
+             carID=0;
+             carMode=0;
+             emergencyStop=0;
+             stationStop=0;
+             stationTotalNum=0;
+         }
+     };
+
+
+
+
+}
+#endif // !_IV_COMMON_GPS_TYPE_

+ 11 - 0
src/v2x/v2xTcpClientWL/main.cpp

@@ -0,0 +1,11 @@
+#include "mainwindow.h"
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+    QApplication a(argc, argv);
+    MainWindow w;
+    w.show();
+
+    return a.exec();
+}

+ 358 - 0
src/v2x/v2xTcpClientWL/mainwindow.cpp

@@ -0,0 +1,358 @@
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+
+iv::Ivlog *givlog;
+unsigned int gv2xEn = true;
+int starSig = 0x2323;
+int cmdSig = 0x03;
+int askSig = 0xfe;
+std::string msgID = "000000000000000000";
+int encrytion = 0x01;
+int dataRate = 0;
+int dataSizeL = 0x00;
+int dataSizeH = 0xd6;
+
+MainWindow::MainWindow(QWidget *parent) :
+    QMainWindow(parent),
+    ui(new Ui::MainWindow)
+{
+    ui->setupUi(this);
+    //Start Get init param
+    QString strpath = QCoreApplication::applicationDirPath();
+    qDebug()<<strpath;
+        strpath = strpath + "/v2xTcpClientWL.xml";
+
+    iv::xmlparam::Xmlparam xp(strpath.toStdString());
+
+    std::string carVIN = xp.GetParam("carVIN","A1S2D3F4G5H6J7126");
+    const char* id = carVIN.data();
+    qDebug()<<id;
+    int len = sizeof(upPack.carVIN);
+    memcpy(upPack.carVIN, id, len);
+//    mscarID = QString::fromStdString(strCarVIN);
+
+//    std::string strHostIP = xp.GetParam("hostIP","127.0.0.1");
+//    std::string strHostPort = xp.GetParam("hostPort","1200");
+    std::string strHostIP = xp.GetParam("hostIP","123.127.164.24");
+    std::string strHostPort = xp.GetParam("hostPort","5600");
+
+    socket=new QTcpSocket();
+    ui->lineEdit_ip->setText(QString::fromStdString(strHostIP));
+    ui->lineEdit_port->setText(QString::fromStdString(strHostPort));
+    ui->pushButton_connect->setEnabled(false);
+
+    givlog = new iv::Ivlog("v2x");
+    connect(socket, &QTcpSocket::readyRead, this, &MainWindow::socket_Read_Data);
+    connect(socket, &QTcpSocket::disconnected, this, &MainWindow::socket_Disconnected);
+
+    /* ShareMemory Register BEGIN */
+    //ShareMem: 车辆地盘状态
+    ModuleFun funchassis =std::bind(&MainWindow::UpdateChassis,this,std::placeholders::_1,\
+                                    std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,\
+                                    std::placeholders::_5);
+    mpMemchassis = iv::modulecomm::RegisterRecvPlus("chassis",funchassis);
+    //ShareMem: gps
+    ModuleFun fungpsimu =std::bind(&MainWindow::UpdateGPSIMU,this,std::placeholders::_1, \
+                                   std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
+    mpMemGps = iv::modulecomm::RegisterRecvPlus("hcp2_gpsimu",fungpsimu);
+
+    /* ShareMemory Register END */
+
+    //heart beat,jiaolili,20210207
+    m_bEnablePlatform=false;
+    m_bIsConnect=false;
+    m_iHeartbeatCount=0;
+    QTimer *timer = new QTimer(this);
+    connect(timer,SIGNAL(timeout()),SLOT(heartBeat()));
+    timer->start(100);
+    ///////////////////////////////////////////
+
+}
+
+MainWindow::~MainWindow()
+{
+    delete this->socket;
+    delete ui;
+}
+void MainWindow::heartBeat()
+{
+    if(gv2xEn) {
+        if(!m_bEnablePlatform) {
+            connectPlatform();
+        }
+        if(m_bIsConnect) {
+            upDataStream();
+        } else {
+            connectPlatform();
+        }
+
+    } else {
+        if(m_bEnablePlatform) {
+            disconnectPlatform();
+        }
+    }
+    m_bEnablePlatform = gv2xEn;
+}
+
+void MainWindow::upDataStream()
+{
+    upVehicleStatus();
+    return;
+}
+
+void MainWindow::socket_Disconnected()
+{
+
+    //修改按键文字
+    m_bIsConnect=false;
+    ui->pushButton_connect->setText("connect");
+    ui->textEdit_messages->insertPlainText("服务器消息:Disconnected");
+}
+void MainWindow::connectPlatform()
+{
+    QString IP;
+    int port;
+    //获取IP地址
+    IP = ui->lineEdit_ip->text();
+    //获取端口号
+    port = ui->lineEdit_port->text().toInt();
+    ui->textEdit_messages->setText("");
+    ui->textEdit_messages->insertPlainText("正在连接"+ui->lineEdit_ip->text()+":"+ui->lineEdit_port->text()+"\n");
+    //取消已有的连接
+    socket->abort();
+    //连接服务器
+    socket->connectToHost(IP, port);
+    //等待连接成功
+    if(!socket->waitForConnected(30000)) {
+        ui->textEdit_messages->insertPlainText("连接失败\n");
+        return;
+    }
+    m_bIsConnect = true;
+    ui->textEdit_messages->insertPlainText("连接成功\n");
+    //修改按键文字
+    ui->pushButton_connect->setText("disconnect");
+}
+
+void MainWindow::disconnectPlatform()
+{
+    //断开连接
+    ui->textEdit_messages->setText("断开连接\n");
+    socket->disconnectFromHost();
+    //修改按键文字
+    ui->pushButton_connect->setText("connect");
+    m_bIsConnect=false;
+}
+void MainWindow::on_pushButton_connect_clicked()
+{
+    if(ui->pushButton_connect->text() == tr("connect"))
+    {
+        QString IP;
+        int port;
+
+        //获取IP地址
+        IP = ui->lineEdit_ip->text();
+        //获取端口号
+        port = ui->lineEdit_port->text().toInt();
+        ui->textEdit_messages->setText("");
+        ui->textEdit_messages->insertPlainText("正在连接"+ui->lineEdit_ip->text()+":"+ui->lineEdit_port->text()+"\n");
+        //取消已有的连接
+        socket->abort();
+        //连接服务器
+        socket->connectToHost(IP, port);
+        //等待连接成功
+        if(!socket->waitForConnected(30000))
+        {
+            QMessageBox::warning(this,tr("消息"),tr("连接失败!请重新连接"),QMessageBox::Yes);
+            ui->textEdit_messages->insertPlainText("连接失败\n");
+            return;
+        }
+        ui->textEdit_messages->insertPlainText("连接成功\n");
+        QMessageBox::information(this,tr("消息"),tr("连接成功"),QMessageBox::Yes);
+
+
+        //修改按键文字
+        ui->pushButton_connect->setText("disconnect");
+    }
+    else
+    {
+        //断开连接
+        ui->textEdit_messages->setText("断开连接\n");
+        socket->disconnectFromHost();
+        //修改按键文字
+        ui->pushButton_connect->setText("connect");
+    }
+}
+
+
+void MainWindow::on_textEdit_messages_textChanged()
+{
+    ui->textEdit_messages->moveCursor(QTextCursor::End);
+}
+
+#include <QDateTime>
+QString MainWindow::getTimeStamp()
+{
+    qint64 time = QDateTime::currentMSecsSinceEpoch();
+    QString str=QString::number(time);
+    return  str;
+}
+
+void MainWindow::socket_Read_Data()
+{
+    return;
+}
+void MainWindow::upVehicleStatus()
+{
+    QByteArray time_stamp=getTimeStamp().toLatin1();
+    memcpy(upPack.timeStamp, time_stamp.data(), sizeof(upPack.timeStamp));
+    int tmp = mflon * 10000000;
+    mlocation.lonL0 = tmp & 0xFF;
+    mlocation.lonL1 = tmp>>8 & 0xFF;
+    mlocation.lonH0 = tmp>>16 & 0xFF;
+    mlocation.lonH1 = tmp>>24 & 0xFF;
+    tmp = mflat * 10000000;
+    mlocation.latL0 = tmp & 0xFF;
+    mlocation.latL1 = tmp>>8 & 0xFF;
+    mlocation.latH0 = tmp>>16 & 0xFF;
+    mlocation.latH1 = tmp>>24 & 0xFF;
+    tmp = (int)(mfEpsAngle/500.0 + 250);
+    mdecision.epsAngleL = tmp & 0xFF;
+    mdecision.epsAngleH = tmp>>8 & 0xFF;
+    tmp = (int)mfspeed * 100;
+    mvehPerfData.speedL = tmp & 0xFF;
+    mvehPerfData.speedH = tmp>>8 & 0xFF;
+    tmp = (int)(mfAcc * 100 / 980);
+    mvehPerfData.hAccL = tmp & 0xFF;
+    mvehPerfData.hAccH = tmp>>8 & 0xFF;
+    tmp = -1 * mvehPerfData.vAccL;
+    mvehPerfData.vAccL = tmp & 0xFF; //临时
+    mvehPerfData.vAccH = tmp>>8 & 0xFF; //临时
+    tmp = (int)mfheading*80;
+    mvehPerfData.headingL0 = tmp & 0xFF;
+    mvehPerfData.headingL1 = tmp>>8 & 0xFF;
+    mvehPerfData.headingH0 = tmp>>16 & 0xFF;
+    mvehPerfData.headingH1 = tmp>>24 & 0xFF;
+    mvehStData.ctrlMode = 1;
+    mvehStData.meilageL0 = 0xE3;
+    mvehStData.meilageL1 = 0xFF;
+    mvehStData.meilageH0 = 0;
+    mvehStData.meilageH1 = 0;
+    mcomponsData.ADSysSt = 1;
+//    char str[10000];
+//    memcpy(str,mlocation,sizeof(LocationData));
+    char *sendBuf = new char[1000];
+    int length = 0;
+    int lenHead = sizeof(UpdatePack)/sizeof(unsigned char);
+    int lenLocation = sizeof(mlocation)/sizeof(unsigned char);
+    int lenDecision = sizeof(mdecision)/sizeof(unsigned char);
+    int lenVehPerfData = sizeof(mvehPerfData)/sizeof(unsigned char);
+    int lenVehStData = sizeof(mvehStData)/sizeof(unsigned char);
+    int lenComponsData = sizeof(mcomponsData)/sizeof(unsigned char);
+    length = lenLocation + lenDecision + lenVehPerfData + lenVehStData +lenComponsData;
+    upPack.dataSizeH = length>>8 & 0xFF;
+    upPack.dataSizeL = length & 0xFF;
+    memcpy(sendBuf,&upPack,lenHead);
+    length = lenHead;
+    memcpy(sendBuf+length,&mlocation,lenLocation);
+    length = length + lenLocation;
+    memcpy(sendBuf+length,&mdecision,lenDecision);
+    length = length + lenDecision;
+    memcpy(sendBuf+length,&mvehPerfData,lenVehPerfData);
+    length = length + lenVehPerfData;
+    memcpy(sendBuf+length,&mvehStData,lenVehStData);
+    length = length + lenVehStData;
+    memcpy(sendBuf+length,&mcomponsData,lenComponsData);
+    length = length + lenComponsData;
+
+    socket->write(sendBuf,length);
+    if(!socket->waitForBytesWritten(3000))
+    {
+        qDebug()<<"realtimeinfo send error";
+    }
+    //debug
+
+    qDebug()<<QDateTime::currentDateTimeUtc() <<"lon"<<mflon<<"lat"<<mflat<<"eps"<<mfEpsAngle \
+           <<"speed"<<mfspeed<<"acc"<<mfAcc<<"heading"<<mfheading;
+}
+
+
+void MainWindow::UpdateChassis(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
+{
+    mistCanCar = 0;
+    iv::chassis xchassis;
+    static int ncount = 0;
+    if(!xchassis.ParseFromArray(strdata,nSize))
+    {
+        std::cout<<"v2xTcpClient::UpdateChassis ParseFrom Array Error."<<std::endl;
+        return;
+    }
+
+    if(xchassis.has_drivemode())
+    {
+        micarMode = xchassis.drivemode();
+    }
+    if(xchassis.has_vel())
+        mfspeed = xchassis.vel();
+    if(xchassis.has_angle_feedback())
+        mfEpsAngle = xchassis.angle_feedback();
+    if((xchassis.has_soc()))
+    {
+        miSOC = xchassis.soc();
+    }
+    if(xchassis.has_accstep())
+        mfAcc = xchassis.accstep();
+}
+
+//接收GPS数据
+void MainWindow::UpdateGPSIMU(const char * strdata,const unsigned int nSize,const unsigned int index,\
+                              const QDateTime * dt,const char * strmemname)
+{
+
+    iv::gps::gpsimu  xgpsimu;
+    if(!xgpsimu.ParseFromArray(strdata,nSize))
+    {
+        givlog->warn("ADCIntelligentVehicle::UpdateGPSIMU parse error. nSize is %d",nSize);
+        return;
+    }
+
+    mflat = xgpsimu.lat();
+    mflon = xgpsimu.lon();
+    mfheading = xgpsimu.heading();
+    mpdata.gps_lat = xgpsimu.lat();
+    mpdata.gps_lng = xgpsimu.lon();
+    mpdata.ins_heading_angle = xgpsimu.heading();
+    mpdata.rtk_status = xgpsimu.rtk_state();
+    mpdata.ins_status = xgpsimu.ins_state();
+    mpdata.vel_D = xgpsimu.vd();    //地向速度,单位(米/秒)
+    mpdata.vel_E = xgpsimu.ve();    //东向速度,单位(米/秒)
+    mpdata.vel_N = xgpsimu.vn();    //北向速度,单位(米/秒)
+
+ //   mfspeed = sqrt(pow(data->vel_E,2)+pow(data->vel_N,2)) * 3.6;  //double pow(double x, double y) 返回 x 的 y 次幂,即 xy。
+    mistGPS = 0;
+}
+
+int toUnicode(const char* str)
+{
+    return str[0] + (str[1] ? toUnicode(str + 1) : 0);
+}
+
+constexpr inline int U(const char* str)
+{
+    return str[0] + (str[1] ? U(str + 1) : 0);
+}
+int GetTypeString(const char* obsType)
+{
+  switch (toUnicode(obsType))
+  {
+    case U("unknown"):
+      return 0;
+    case U("car"):
+      return 1;
+    case U("bike"):
+      return 5;
+    case U("pedestrian"):
+      return 3;
+    default:
+      return 0;
+  }
+}

+ 149 - 0
src/v2x/v2xTcpClientWL/mainwindow.h

@@ -0,0 +1,149 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+#include <QTcpSocket>
+#include <QFile>
+#include <QDir>
+#include <QList>
+#include <QTextStream>
+#include<QDateTime>
+#include "data_type.h"
+#include "QMessageBox"
+#include "v2x.pb.h"
+#include "chassis.pb.h"
+#include "gpsimu.pb.h"
+#include "object.pb.h"
+#include "objectarray.pb.h"
+#include "radarobject.pb.h"
+#include "radarobjectarray.pb.h"
+#include "gps_type.h"
+#include "modulecomm.h"
+#include "xmlparam.h"
+#include "ivlog.h"
+#include "transfer.h"
+#include "gnss_coordinate_convert.h"
+#include <QTimer>
+#include <iostream>
+#include <QMutex>
+namespace Ui {
+class MainWindow;
+}
+
+struct StationGps
+{
+    double lon;
+    double lat;
+};
+struct ObsInfo
+{
+    int    type;
+    double lon;
+    double lat;
+};
+
+class MainWindow : public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    explicit MainWindow(QWidget *parent = nullptr);
+    ~MainWindow();
+    void readMp3Messages(QString path);
+    QString getTimeStamp();
+    void ProStopCommand(QString str);
+    void ProAutoPilotControl(QStringList list);
+    void ProStationCommand(QString str);
+    bool checkVehicle(QString str);
+    int getDownStreamId(QString str);
+//    int toUnicode(const char* str);
+//    constexpr inline int U(const char* str);
+//    int GetTypeString(const char*  obsType) const;
+    void upVehicleStatus();
+    void upHardwareStatus();
+    QString getHardwareType(int state);
+    QString getObstacleData(int type);
+    void upObstacleDataStatus();
+    void upSoftwareStatus();
+    void upDataStream();
+    void shareV2xStReqMsg();
+    void shareV2xProtoMsg(iv::v2x::v2x msgV2xProto);
+    void UpdateChassis(const char *strdata, const unsigned int nSize, const unsigned int index, \
+                       const QDateTime *dt, const char *strmemname);
+    void UpdateGPSIMU(const char * strdata,const unsigned int nSize,const unsigned int index,\
+                                  const QDateTime * dt,const char * strmemname);
+    void UpdateLidarObs(const char * strdata,const unsigned int nSize,const unsigned int index, \
+                               const QDateTime * dt,const char * strmemname);
+    void UpdateRadarObs(const char * strdata,const unsigned int nSize,const unsigned int index, \
+                               const QDateTime * dt,const char * strmemname);
+private slots:
+
+    void socket_Read_Data();
+    void socket_Disconnected();
+    void on_pushButton_connect_clicked();
+    void on_textEdit_messages_textChanged();
+    void heartBeat();
+    void connectPlatform();
+    void disconnectPlatform();
+private:
+    Ui::MainWindow *ui;
+    QTcpSocket *socket;
+    void * mpMemV2xSend;
+    void * mpMemV2xStSend;
+    void * mpMemchassis;
+    void * mpMemGps;
+    void * mpMemLadarESRObs;//前毫米波
+    void * mpMemLadarSRRLObs;//角毫米波
+    void * mpMemRadarObs;
+    void * mpMemLidarObs;
+    void * mpMemMobleyeObs;//Mobiley
+    void * mpMemLidar_pc;
+    bool m_bEnablePlatform;
+    bool m_bIsConnect;  
+    QMutex mMutexMap;
+    QVector<StationGps> mstationGps;
+    iv::GPS_INS mpdata;
+    int m_iHeartbeatCount;
+
+    /* 车辆状态数据 上行 BEGIN */
+    QString mscarID ;
+    int micarMode = 0;
+    float mfspeed = 0;
+    float mfEpsAngle = 0;
+    int miSOC = 0;
+    float mfAcc=0;
+    int micarError = 0;
+    int mierrorNum = 0;
+    double mflat = 0;//经度
+    double mflon = 0;//纬度
+    double mfheading = 0;//航向
+    UpdatePack upPack;
+    LocationData mlocation;
+    DecisionData mdecision;
+    VehiclePerfData mvehPerfData;
+    VehicleStData mvehStData;
+    ComponsData mcomponsData;
+    /* 车辆状态数据 END */
+
+    /* 硬件状态数据 上行 BEGIN */
+    int mistRadar = 1;
+    int mistLidar = 1;
+    int mistSonic = 0;//超声
+    int mistCamera = 0;
+    int mistmic = 0;
+    int mistGPS = 1;
+    int mistCanCar = 1;
+    int mistCanRadar = 1;
+    int mistlight = 0;//红绿灯
+    /* 硬件状态数据 上行 END */
+
+    /* 障碍物状态数据 上行 START */
+    QVector<ObsInfo> mqLidarObsInfo;
+    QVector<ObsInfo> mqRadarObsInfo;
+    int miLidarObsCount = 0;
+    int miRadarObsCount = 0;
+    /* 障碍物状态数据 上行 END */
+
+
+};
+#endif // MAINWINDOW_H

+ 97 - 0
src/v2x/v2xTcpClientWL/mainwindow.ui

@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>593</width>
+    <height>437</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>MainWindow</string>
+  </property>
+  <widget class="QWidget" name="centralWidget">
+   <widget class="QWidget" name="layoutWidget">
+    <property name="geometry">
+     <rect>
+      <x>30</x>
+      <y>40</y>
+      <width>451</width>
+      <height>283</height>
+     </rect>
+    </property>
+    <layout class="QVBoxLayout" name="verticalLayout">
+     <item>
+      <layout class="QHBoxLayout" name="horizontalLayout">
+       <item>
+        <widget class="QLabel" name="label">
+         <property name="text">
+          <string>IP:</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QLineEdit" name="lineEdit_ip"/>
+       </item>
+       <item>
+        <widget class="QLabel" name="label_2">
+         <property name="text">
+          <string>PORT:</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QLineEdit" name="lineEdit_port"/>
+       </item>
+       <item>
+        <widget class="QPushButton" name="pushButton_connect">
+         <property name="text">
+          <string>connect</string>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </item>
+     <item>
+      <widget class="QLabel" name="label_3">
+       <property name="text">
+        <string>MESSAGE BOX:</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QTextEdit" name="textEdit_messages"/>
+     </item>
+     <item>
+      <layout class="QHBoxLayout" name="horizontalLayout_2"/>
+     </item>
+    </layout>
+   </widget>
+  </widget>
+  <widget class="QMenuBar" name="menuBar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>593</width>
+     <height>28</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QToolBar" name="mainToolBar">
+   <attribute name="toolBarArea">
+    <enum>TopToolBarArea</enum>
+   </attribute>
+   <attribute name="toolBarBreak">
+    <bool>false</bool>
+   </attribute>
+  </widget>
+  <widget class="QStatusBar" name="statusBar"/>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>

+ 62 - 0
src/v2x/v2xTcpClientWL/obstacle_type.h

@@ -0,0 +1,62 @@
+#pragma once
+#ifndef _IV_COMMON_OBSTACLE_TYPE_
+#define _IV_COMMON_OBSTACLE_TYPE_
+#include <vector>
+#include <boost.h>
+/**
+*障碍物类型
+*/
+namespace iv {
+const int grx = 250, gry = 500, centerx = 125, centery = 250;
+const double gridwide = 0.2;
+struct ObstacleBasic
+{
+    bool valid;
+    float nomal_x;
+    float nomal_y;
+    float nomal_z;
+
+    float speed_relative;
+    float speed_x;
+    float speed_y;
+    float speed_z;
+
+    float high;
+    float low;
+
+    int esr_ID;
+};
+
+typedef boost::shared_ptr<std::vector<iv::ObstacleBasic>> ObsLiDAR;
+typedef boost::shared_ptr<std::vector<iv::ObstacleBasic>> ObsRadar;
+typedef boost::shared_ptr<std::vector<iv::ObstacleBasic>> ObsCamera;
+typedef boost::shared_ptr<std::vector<iv::ObstacleBasic>>ObsRadarPointer;
+struct Obs_grid
+{
+    double high;
+    double low;
+    double obshight;
+    int pointcount;
+    int ob;//障碍物属性,0地面 ,1路沿,2障碍物
+};
+
+typedef Obs_grid LidarGrid;
+typedef Obs_grid* LidarGridPtr;
+
+struct array_360
+{
+    float x;
+    float y;
+    float z;
+};
+
+struct detect_info
+{
+    int light;
+};
+
+typedef detect_info CameraInfo;
+typedef detect_info* CameraInfoPtr;
+}
+
+#endif // !_IV_COMMON_OBSTACLE_TYPE_

+ 138 - 0
src/v2x/v2xTcpClientWL/transfer.cpp

@@ -0,0 +1,138 @@
+#include <transfer.h>
+#include <decition_type.h>
+#include <math.h>
+#include <iostream>
+#include <fstream>
+using namespace std;
+#define PI (3.1415926535897932384626433832795)
+
+
+
+///大地转车体
+iv::Point2D iv::decition::Coordinate_Transfer(double x_path, double y_path, iv::GPS_INS pos)
+{
+    double x_vehicle, y_vehicle;
+    double theta = atan2(x_path - pos.gps_x, y_path - pos.gps_y);
+
+    double distance = sqrt((x_path - pos.gps_x) * (x_path - pos.gps_x) + (y_path - pos.gps_y) * (y_path - pos.gps_y));
+    double angle = theta - (-90 + pos.ins_heading_angle) / 180 * PI;
+
+    x_vehicle = -cos(angle) * distance;
+    y_vehicle = sin(angle) * distance;
+    return  iv::Point2D(x_vehicle, y_vehicle);
+}
+
+///车体转大地
+iv::GPS_INS iv::decition::Coordinate_UnTransfer(double x_path, double y_path, iv::GPS_INS pos)
+{
+    iv::GPS_INS gps_ins;
+    double x_vehicle, y_vehicle;
+    double theta = atan2(x_path, y_path);
+
+    double distance = sqrt(x_path * x_path + y_path * y_path);
+    double angle = (pos.ins_heading_angle / 180 * PI + theta);
+
+    x_vehicle = pos.gps_x + distance * sin(angle);
+    y_vehicle = pos.gps_y + distance * cos(angle);
+    gps_ins.gps_x = x_vehicle;
+    gps_ins.gps_y = y_vehicle;
+
+    return  gps_ins;
+}
+
+double iv::decition::GetDistance(iv::Point2D x1, iv::Point2D x2)
+{
+    return sqrt((x1.x - x2.x) * (x1.x - x2.x) + (x1.y - x2.y) * (x1.y - x2.y));
+}
+
+double iv::decition::GetDistance(iv::GPS_INS p1, iv::GPS_INS p2)
+{
+    return sqrt((p1.gps_x - p2.gps_x) * (p1.gps_x - p2.gps_x) + (p1.gps_y - p2.gps_y) * (p1.gps_y - p2.gps_y));
+}
+
+
+
+
+//GPS转大地坐标
+void iv::decition::BLH2XYZ(iv::GPS_INS gp)
+{
+    int nFlag = 2;
+
+    double B = gp.gps_lat;
+
+    double L = gp.gps_lng;
+
+
+
+    double N, E, h;
+    double L0 = GetL0InDegree(L);//根据经度求中央子午线经度
+
+    double a = 6378245.0;            //地球半径  北京6378245
+    double F = 298.257223563;        //地球扁率
+    double iPI = 0.0174532925199433; //2pi除以360,用于角度转换
+
+    double f = 1 / F;
+    double b = a * (1 - f);
+    double ee = (a * a - b * b) / (a * a);
+    double e2 = (a * a - b * b) / (b * b);
+    double n = (a - b) / (a + b), n2 = (n * n), n3 = (n2 * n), n4 = (n2 * n2), n5 = (n4 * n);
+    double al = (a + b) * (1 + n2 / 4 + n4 / 64) / 2;
+    double bt = -3 * n / 2 + 9 * n3 / 16 - 3 * n5 / 32;
+    double gm = 15 * n2 / 16 - 15 * n4 / 32;
+    double dt = -35 * n3 / 48 + 105 * n5 / 256;
+    double ep = 315 * n4 / 512;
+
+    B = B * iPI;
+    L = L * iPI;
+    L0 = L0 * iPI;
+
+    double l = L - L0, cl = (cos(B) * l), cl2 = (cl * cl), cl3 = (cl2 * cl), cl4 = (cl2 * cl2), cl5 = (cl4 * cl), cl6 = (cl5 * cl), cl7 = (cl6 * cl), cl8 = (cl4 * cl4);
+    double lB = al * (B + bt * sin(2 * B) + gm * sin(4 * B) + dt * sin(6 * B) + ep * sin(8 * B));
+    double t = tan(B), t2 = (t * t), t4 = (t2 * t2), t6 = (t4 * t2);
+    double Nn = a / sqrt(1 - ee * sin(B) * sin(B));
+    double yt = e2 * cos(B) * cos(B);
+    N = lB;
+    N += t * Nn * cl2 / 2;
+    N += t * Nn * cl4 * (5 - t2 + 9 * yt + 4 * yt * yt) / 24;
+    N += t * Nn * cl6 * (61 - 58 * t2 + t4 + 270 * yt - 330 * t2 * yt) / 720;
+    N += t * Nn * cl8 * (1385 - 3111 * t2 + 543 * t4 - t6) / 40320;
+
+    E = Nn * cl;
+    E += Nn * cl3 * (1 - t2 + yt) / 6;
+    E += Nn * cl5 * (5 - 18 * t2 + t4 + 14 * yt - 58 * t2 * yt) / 120;
+    E += Nn * cl7 * (61 - 479 * t2 + 179 * t4 - t6) / 5040;
+
+    E += 500000;
+    if (nFlag == 1)
+    {
+        //UTM投影
+        N = 0.9996 * N;
+        E = 0.9996 * (E - 500000.0) + 500000.0;//Get y
+    }
+    if (nFlag == 2)
+    {
+        //UTM投影
+        N = 0.9999 * N;
+        E = 0.9999 * (E - 500000.0) + 250000.0;//Get y
+    }
+
+    //原
+    //pt2d.x = N;
+    //pt2d.y = E;
+    //
+    gp.gps_x = E - 280000;
+    gp.gps_y = N - 4325000;
+
+}
+
+
+double iv::decition::GetL0InDegree(double dLIn)
+{
+    //3°带求带号及中央子午线经度(d的形式)
+    //具体公式请参阅《常用大地坐标系及其变换》朱华统,解放军出版社138页
+    double L = dLIn;//d.d
+    double L_ddd_Style = L;
+    double ZoneNumber = (int)((L_ddd_Style - 1.5) / 3.0) + 1;
+    double L0 = ZoneNumber * 3.0;//degree
+    return L0;
+}

+ 27 - 0
src/v2x/v2xTcpClientWL/transfer.h

@@ -0,0 +1,27 @@
+#pragma once
+#ifndef _IV_DECITION_TRANSFER_
+#define _IV_DECITION_TRANSFER_
+
+#include "gps_type.h"
+#include "decition_type.h"
+#include <vector>
+
+namespace iv {
+    namespace decition {
+        //根据传感器传输来的信息作出决策
+
+        double GetL0InDegree(double dLIn);
+
+        void BLH2XYZ(GPS_INS gps_ins);
+
+        ///大地转车体
+        Point2D Coordinate_Transfer(double x_path, double y_path, GPS_INS pos);
+
+        ///车体转大地
+        GPS_INS Coordinate_UnTransfer(double x_path, double y_path, GPS_INS pos);
+        double GetDistance(Point2D x1, Point2D x2);
+        double GetDistance(GPS_INS p1, GPS_INS p2);
+    }
+}
+
+#endif // ! _IV_DECITION_TRANSFER_

+ 74 - 0
src/v2x/v2xTcpClientWL/v2xTcpClientWL.pro

@@ -0,0 +1,74 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2020-12-25T08:41:28
+#
+#-------------------------------------------------
+
+QT       += core gui network
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+TARGET = v2xTcpClientWL
+TEMPLATE = app
+
+# The following define makes your compiler emit warnings if you use
+# any feature of Qt which has been marked as deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if you use deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
+
+INCLUDEPATH += $$PWD/../../../include/
+LIBS += -L$$PWD/../../../bin/ -lxmlparam -lmodulecomm -livlog -livfault -lprotobuf
+
+INCLUDEPATH += $$PWD/../../include/msgtype
+
+CONFIG += c++11
+
+SOURCES += \
+        main.cpp \
+        mainwindow.cpp \
+        ../../include/msgtype/v2x.pb.cc \
+        ../../include/msgtype/chassis.pb.cc \
+        ../../include/msgtype/gpsimu.pb.cc \
+        ../../include/msgtype/object.pb.cc \
+        ../../include/msgtype/objectarray.pb.cc \
+        ../../include/msgtype/radarobject.pb.cc \
+        ../../include/msgtype/radarobjectarray.pb.cc \
+        transfer.cpp \
+    gnss_coordinate_convert.cpp
+
+HEADERS += \
+        mainwindow.h \
+        data_type.h\
+        ../../include/msgtype/v2x.pb.h \
+        ../../include/msgtype/chassis.pb.h \
+        ../../include/msgtype/gpsimu.pb.h \
+        ../../include/msgtype/object.pb.h \
+        ../../include/msgtype/objectarray.pb.h \
+        ../../include/msgtype/radarobject.pb.h \
+        ../../include/msgtype/radarobjectarray.pb.h \
+        transfer.h \
+        decition_type.h \
+        gps_type.h \
+        boost.h \
+    gnss_coordinate_convert.h
+
+FORMS += \
+        mainwindow.ui
+
+win32: INCLUDEPATH += C:/File/boost/boost_1_67_0
+win32: LIBS += -LC:/File/boost/boost_1_67_0/vc2017/lib -lboost_system-vc141-mt-x64-1_67 -lboost_thread-vc141-mt-x64-1_67
+unix:!macx: LIBS += -L$$PWD/./  -lboost_thread -lboost_system
+unix:LIBS += -lboost_thread -lboost_system -lboost_serialization
+
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target
+
+

+ 48 - 0
src/v2x/v2xTcpClientWL/v2xTcpClientWL.xml

@@ -0,0 +1,48 @@
+<xml>	
+	<node name="v2xTcpClient">
+		<param name="carVIN" value="catarc001" />
+		<param name="hostIP" value="47.95.196.28" />
+		<param name="hostPort" value="12123" />
+		<param name="stationCount" value="20" />
+		<param name="lat0" value="0" />
+		<param name="lon0" value="0" />
+		<param name="lat1" value="0" />
+		<param name="lon1" value="0" />
+		<param name="lat2" value="39.1221963" />
+		<param name="lon2" value="117.0272492" />
+		<param name="lat3" value="39.1216422" />
+		<param name="lon3" value="117.0272508" />
+		<param name="lat4" value="39.1209112" />
+		<param name="lon4" value="117.0272539" />
+		<param name="lat5" value="0" />
+		<param name="lon5" value="0" />
+		<param name="lat6" value="0" />
+		<param name="lon6" value="0" />
+		<param name="lat7" value="0" />
+		<param name="lon7" value="0" />
+		<param name="lat8" value="0" />
+		<param name="lon8" value="0" />
+		<param name="lat9" value="0" />
+		<param name="lon9" value="0" />
+		<param name="lat10" value="0" />
+		<param name="lon10" value="0" />
+		<param name="lat11" value="0" />
+		<param name="lon11" value="0" />
+		<param name="lat12" value="0" />
+		<param name="lon12" value="0" />
+		<param name="lat13" value="0" />
+		<param name="lon13" value="0" />
+		<param name="lat14" value="0" />
+		<param name="lon14" value="0" />
+		<param name="lat15" value="0" />
+		<param name="lon15" value="0" />
+		<param name="lat16" value="0" />
+		<param name="lon16" value="0" />
+		<param name="lat17" value="0" />
+		<param name="lon17" value="0" />
+		<param name="lat18" value="0" />
+		<param name="lon18" value="0" />
+		<param name="lat19" value="0" />
+		<param name="lon19" value="0" />
+	</node>
+</xml>