// Copyright (c) 2022 ChenJun // Licensed under the MIT License. #ifndef RM_SERIAL_DRIVER__PACKET_HPP_ #define RM_SERIAL_DRIVER__PACKET_HPP_ #include #include #include namespace rm_serial { struct ReceivePacket { uint8_t header; uint8_t robot_color:1; uint8_t task_mode:2; uint8_t game_progress:3; //����״̬ 3 �����Լ� 4 ������ʼ 5 �������� uint8_t reserved : 2; float body_joint_state;//lidar_link to base_link uint16_t outpost_hp; float target_x,target_y; uint16_t checksum = 0; } __attribute__((packed)); struct SendPacket { // uint8_t header = 0xA5; // bool findEnemy : 1; // bool target_color : 1; // uint8_t task_mode : 2; // bool suggest_fire : 1; // uint8_t reserve : 3; // float pitch_cmd = 0; // float yaw_cmd = 0; // float cmd_vx= 0,cmd_vy= 0,cmd_wz= 0; uint8_t header = 0xA5; // bool tracking : 1; // bool target_color : 1; // uint8_t task_mode : 2; // bool suggest_fire : 1; uint8_t reserve ; float cmd_vx= 0,cmd_vy= 0,cmd_wz= 0; uint16_t checksum = 0; } __attribute__((packed)); inline ReceivePacket fromVector(const std::vector & data) { ReceivePacket packet; std::copy(data.begin(), data.end(), reinterpret_cast(&packet)); return packet; } inline std::vector toVector(const SendPacket & data) { std::vector packet(sizeof(SendPacket)); std::copy( reinterpret_cast(&data), reinterpret_cast(&data) + sizeof(SendPacket), packet.begin()); return packet; } } // namespace rm_serial_driver #endif // RM_SERIAL_DRIVER__PACKET_HPP_