123456789101112131415161718192021222324252627282930313233343536 |
- #ifndef VEHICLE_H
- #define VEHICLE_H
- #include <iostream>
- #include <string>
- using namespace std;
- unsigned char order_on[8] = {0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; //id:421 指令模式开
- unsigned char headlamp_on[8] = {0x01,0x01,0x50,0x00,0x00,0x00,0x00,0x00}; //id:121 前车灯常开
- unsigned char headlamp_off[8] = {0x01,0x00,0x50,0x00,0x00,0x00,0x00,0x00}; //id:121 前车灯常关
- unsigned char tailamp_on[8] = {0x01,0x00,0x00,0x10,0x50,0x00,0x00,0x00}; //id:121 后车灯常关
- unsigned char taillamp_off[8] = {0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; //id:121 后车灯常关
- unsigned char move_forward[8] = {0x00,0x96,0x00,0x00,0x00,0x00,0x00,0x00}; //id:111 以0.15m/s前进
- unsigned char move_backward[8] = {0x00,0xcc,0x00,0x00,0x00,0x00,0x00,0x00}; //id:111 以0.15m/s后退
- unsigned char move_rotation[8] = {0x00,0x00,0x00,0xc8,0x00,0x00,0x00,0x00}; //id:111 以0.2rad/s旋转
- unsigned char stop[8] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; //id:111 急停
- class Vehicle {
- private:
- bool order_flag;
- bool lamp_flag; // 车灯状态
- bool stop_flag; // 急停状态
- std::string direction_tag; // 车辆当前方向
-
- public:
- Vehicle() : order_flag(true), lamp_flag(false), stop_flag(false), direction_tag("forward") {}
-
- void order(bool order_flag);
- void toggleLamp(bool lamp_flag); // 车灯开关
- void moveForward(); // 车辆前进
- void turnLeft(); // 车辆左转
- void turnRight(); // 车辆右转
- void moveBackward(); // 车辆后退(简单实现,不改变方向)
- };
- #endif
|