vehicle.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #ifndef VEHICLE_H
  2. #define VEHICLE_H
  3. #include <iostream>
  4. #include <string>
  5. using namespace std;
  6. unsigned char order_on[8] = {0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; //id:421 指令模式开
  7. unsigned char headlamp_on[8] = {0x01,0x01,0x50,0x00,0x00,0x00,0x00,0x00}; //id:121 前车灯常开
  8. unsigned char headlamp_off[8] = {0x01,0x00,0x50,0x00,0x00,0x00,0x00,0x00}; //id:121 前车灯常关
  9. unsigned char tailamp_on[8] = {0x01,0x00,0x00,0x10,0x50,0x00,0x00,0x00}; //id:121 后车灯常关
  10. unsigned char taillamp_off[8] = {0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; //id:121 后车灯常关
  11. unsigned char move_forward[8] = {0x00,0x96,0x00,0x00,0x00,0x00,0x00,0x00}; //id:111 以0.15m/s前进
  12. unsigned char move_backward[8] = {0x00,0xcc,0x00,0x00,0x00,0x00,0x00,0x00}; //id:111 以0.15m/s后退
  13. unsigned char move_rotation[8] = {0x00,0x00,0x00,0xc8,0x00,0x00,0x00,0x00}; //id:111 以0.2rad/s旋转
  14. unsigned char stop[8] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; //id:111 急停
  15. class Vehicle {
  16. private:
  17. bool order_flag;
  18. bool lamp_flag; // 车灯状态
  19. bool stop_flag; // 急停状态
  20. std::string direction_tag; // 车辆当前方向
  21. public:
  22. Vehicle() : order_flag(true), lamp_flag(false), stop_flag(false), direction_tag("forward") {}
  23. void order(bool order_flag);
  24. void toggleLamp(bool lamp_flag); // 车灯开关
  25. void moveForward(); // 车辆前进
  26. void turnLeft(); // 车辆左转
  27. void turnRight(); // 车辆右转
  28. void moveBackward(); // 车辆后退(简单实现,不改变方向)
  29. };
  30. #endif