@Pigmon
2018-06-20T14:01:02.000000Z
字数 1832
阅读 929
慧拓
const char* UI_IP = "127.0.0.1";
const int UI_PORT = 10010; // 对应 UplinkDGram
const char* PANOSIM_IP = "10.130.210.63";
const int PANOSIM_PORT = 10012; // 对应 UplinkDGram
const int STATE_PORT = 10013; // 按键事件触发报文的端口,对应 HomeDgram_Trigger
const int LOCAL_PORT = 10015; // 模拟器输入实时状态的发送端口 HomeDgram_Ctrl
#pragma once
// 车辆上行信息,接收到就发给UI和PanoSim
struct UplinkDGram
{
short m_gram_header; // 报文头 0xAAA
short m_gram_id; // 报文标识 0xAF1
short m_vehicle_id; // 车辆ID 0x00A ~ 0x00C
short m_vehicle_state; // 0:正常; 1:故障
unsigned int m_longitude; // 经度
unsigned int m_latitude; // 纬度
unsigned short m_heading; // 航向
short m_speed; // 速度
int m_steering; // 方向盘转角
short m_ctrl_sign; // 0:自动; 1:遥控
short m_ctrl_info; // 控制信息 1:车辆主动请求接管; 2:车辆故障 ...
short m_rpm; // RPM
short m_unused0; //
void Print()
{
printf("DGram CarID: %d\n", m_vehicle_id);
printf("DGram m_speed: %d\n", m_speed);
printf("DGram m_steering: %d\n", m_steering);
}
};
struct DownlinkDGram
{
short m_gram_header; // 报文头 0xAAA
short m_gram_id; // 报文标识 0xAF1
short m_vehicle_id; // 车辆ID 0x00A ~ 0x00C
short m_rc_speed; // 遥控速度
short m_rc_acc_pedal;
short m_rc_brake_pedal;
short m_ctrl_sign; // 遥控状态, 1: 遥控; 0: 自动
short m_unused;
int m_rc_steer; // 遥控方向盘转角
void Print()
{
printf("DGram CarID: %d\n", m_vehicle_id);
printf("DGram Steering: %d\n", m_rc_steer);
printf("DGram Acc: %d\n", m_rc_acc_pedal);
printf("DGram Brk: %d\n", m_rc_brake_pedal);
}
};
#pragma pack(push)
#pragma pack(1)
// 模拟器状态报文,一直发送
typedef struct HomeDgram_Ctrl
{
short m_gram_header; // 报文头 0xA00
short m_gram_id; // 报文标识 0xA01
short m_vehicle_id; // 0 - 当前没有观察任何车辆;或 车辆ID
int m_rc_steering; // 模拟方向盘转角
short m_rc_speed; // 模拟器速度
short m_rc_acc_pedal; // 模拟器油门踏板开度 (0-100)
short m_rc_brk_pedal; // 模拟器刹车踏板开度 (0-100)
short m_ping_time; // RTT
HomeDgram_Ctrl()
{
m_gram_header = 0xA00;
m_gram_id = 0xA01;
m_ping_time = 5;
}
};
// 控制更改报文,有按键消息再发送
typedef struct HomeDgram_Trigger
{
short m_gram_header; // 报文头 0x010
short m_gram_id; // 报文标识 0x011
short m_ctrl_state; // 控制状态 0 - 啥也不做;1 - 遥控; 2 - 同步
HomeDgram_Trigger()
{
m_gram_header = 0x010;
m_gram_id = 0x011;
}
};
#pragma pack(pop)