@Pigmon
2020-12-01T16:02:11.000000Z
字数 1617
阅读 770
遥控
目前采用的方法是,用一个只有1位是1,其他位都是0的16位无符号整数来代表一个异常状态。车端获取到所有异常状态后将它们按位或操作后发出。
接收端可以根据整体错误代码中为1的位有哪些得知目前都有什么异常状态。
目前的错误代码定义:
bin | dec | hex | 含义 |
---|---|---|---|
0000 0000 0000 0010 | 2 | 0x0002 | 预留代表未知错误 |
0000 0000 0000 0100 | 4 | 0x0004 | GPS 错误 |
0000 0000 0000 1000 | 8 | 0x0008 | IMU 错误 |
0000 0000 0001 0000 | 16 | 0x0010 | 激光雷达错误 |
0000 0000 0010 0000 | 32 | 0x0020 | 预留其他错误 |
... | ... | ... | ... |
0100 0000 0000 0000 | 16384 | 0x4000 | 预留其他错误 |
考虑出现有符号接收的可能性,符号位保持0。
rc_chassis.msg
# Description the state of chassis
Header header
int8 gear # 档位,1, 2, 3..., 0表示无档位
float64 speed # 秒速
float64 steering # 轮偏角,弧度
int16 rpm # 发动机转速
uint8 bucket_pos # 斗位置 0-底,1-中间,2-顶,3-故障
uint16 detect_error # 检测到故障,用于发出接管请求
uint8 state
uint8 Normal = 0
uint8 RequiredRC = 1
uint8 Emergency = 2
车端可以 source 工程 nox_comm 得到这个消息。
错误码定义:
const unsigned short ERRDET_UNKOWN_ERR = 0X0002;
const unsigned short ERRDET_GPS_LOSS = 0x0004;
const unsigned short ERRDET_IMU_LOSS = 0x0008;
const unsigned short ERRDET_LIDAR_LOSS = 0x0010;
const unsigned short ERRDET_PLACEHOLDER_0 = 0X0020;
const unsigned short ERRDET_PLACEHOLDER_1 = 0X0040;
const unsigned short ERRDET_PLACEHOLDER_2 = 0X0080;
const unsigned short ERRDET_PLACEHOLDER_3 = 0X0100;
const unsigned short ERRDET_PLACEHOLDER_4 = 0X0200;
const unsigned short ERRDET_PLACEHOLDER_5 = 0X0400;
const unsigned short ERRDET_PLACEHOLDER_6 = 0X0800;
const unsigned short ERRDET_PLACEHOLDER_7 = 0X1000;
const unsigned short ERRDET_PLACEHOLDER_8 = 0X2000;
const unsigned short ERRDET_PLACEHOLDER_9 = 0X4000;
使用示例:
unsigned short err_code = ERRDET_GPS_LOSS | ERRDET_LIDAR_LOSS;
bool gps_err = (err_code & ERRDET_GPS_LOSS) == ERRDET_GPS_LOSS;
bool imu_err = (err_code & ERRDET_IMU_LOSS) == ERRDET_IMU_LOSS;
bool lidar_err = (err_code & ERRDET_LIDAR_LOSS) == ERRDET_LIDAR_LOSS;
std::cout << std::boolalpha << gps_err << ", " << imu_err << ", " << lidar_err << std::endl;
// prints: true, false, true