|
2 | 2 | #include <bitset> |
3 | 3 | #include <cstdint> |
4 | 4 | #include <vector> |
| 5 | +#include <iostream> |
5 | 6 |
|
6 | 7 | bool RobotState::is_wanted_pre(const std::vector<uint8_t> &prefix) |
7 | 8 | { |
8 | | - if (prefix[0] != 0xA5) return false; |
| 9 | + if (prefix[0] != 0xA5) |
| 10 | + return false; |
9 | 11 |
|
10 | 12 | uint16_t length = static_cast<uint16_t>(prefix[1]) | (static_cast<uint16_t>(prefix[2]) << 8); |
11 | 13 | uint16_t cmd_id = static_cast<uint16_t>(prefix[5]) | (static_cast<uint16_t>(prefix[6]) << 8); |
12 | 14 |
|
13 | | - if (cmd_id != 0x0201 || length != 27) return false; |
| 15 | + if (cmd_id != 0x0201 || length != 13) |
| 16 | + return false; |
14 | 17 | return true; |
15 | 18 | } |
16 | 19 |
|
17 | 20 | RobotState::RobotState(const std::vector<uint8_t> &frame) |
18 | 21 | { |
19 | 22 | // copy the uint8_t vector to the struct |
20 | | - std::copy(frame.begin(), frame.end(), reinterpret_cast<uint8_t*>(&interpreted)); |
| 23 | + std::copy(frame.begin(), frame.end(), reinterpret_cast<uint8_t *>(&interpreted)); |
21 | 24 | } |
22 | 25 |
|
23 | 26 | operation_interface::msg::RobotState RobotState::msg() |
24 | 27 | { |
25 | 28 | operation_interface::msg::RobotState msg; |
26 | 29 | msg.robot_id = interpreted.data.robot_id; |
27 | 30 | msg.robot_level = interpreted.data.robot_level; |
28 | | - msg.remain_hp = interpreted.data.remain_HP; |
29 | | - msg.max_hp = interpreted.data.max_HP; |
30 | | - msg.shooter_id1_17mm_cooling_rate = interpreted.data.shooter_id1_17mm_cooling_rate; |
31 | | - msg.shooter_id1_17mm_cooling_limit = interpreted.data.shooter_id1_17mm_cooling_limit; |
32 | | - msg.shooter_id1_17mm_speed_limit = interpreted.data.shooter_id1_17mm_speed_limit; |
33 | | - |
34 | | - msg.shooter_id2_17mm_cooling_rate = interpreted.data.shooter_id2_17mm_cooling_rate; |
35 | | - msg.shooter_id2_17mm_cooling_limit = interpreted.data.shooter_id2_17mm_cooling_limit; |
36 | | - msg.shooter_id2_17mm_speed_limit = interpreted.data.shooter_id2_17mm_speed_limit; |
37 | | - |
38 | | - msg.shooter_id1_42mm_cooling_rate = interpreted.data.shooter_id1_42mm_cooling_rate; |
39 | | - msg.shooter_id1_42mm_cooling_limit = interpreted.data.shooter_id1_42mm_cooling_limit; |
40 | | - msg.shooter_id1_42mm_speed_limit = interpreted.data.shooter_id1_42mm_speed_limit; |
41 | | - |
| 31 | + msg.current_hp = interpreted.data.current_HP; |
| 32 | + msg.maximum_hp = interpreted.data.maximum_HP; |
| 33 | + msg.shooter_barrel_cooling_value = interpreted.data.shooter_barrel_cooling_value; |
| 34 | + msg.shooter_barrel_heat_limit = interpreted.data.shooter_barrel_heat_limit; |
42 | 35 | msg.chassis_power_limit = interpreted.data.chassis_power_limit; |
43 | | - msg.mains_power_gimbal_output = interpreted.data.mains_power_gimbal_output; |
44 | | - msg.mains_power_chassis_output = interpreted.data.mains_power_chassis_output; |
45 | | - msg.mains_power_shooter_output = interpreted.data.mains_power_shooter_output; |
| 36 | + msg.power_management_gimbal_output = interpreted.data.power_management_gimbal_output; |
| 37 | + msg.power_management_chassis_output = interpreted.data.power_management_chassis_output; |
| 38 | + msg.power_management_shooter_output = interpreted.data.power_management_shooter_output; |
46 | 39 | return msg; |
47 | 40 | } |
0 commit comments