| 1 | #include "common/motor_crc_hg.h" |
| 2 | |
| 3 | void get_crc(unitree_hg::msg::LowCmd &msg) { |
| 4 | LowCmd raw{}; |
| 5 | |
| 6 | raw.modePr = msg.mode_pr; |
| 7 | raw.modeMachine = msg.mode_machine; |
| 8 | |
| 9 | for (int i = 0; i < 35; i++) { |
| 10 | raw.motorCmd[i].mode = msg.motor_cmd[i].mode; |
| 11 | raw.motorCmd[i].q = msg.motor_cmd[i].q; |
| 12 | raw.motorCmd[i].dq = msg.motor_cmd[i].dq; |
| 13 | raw.motorCmd[i].tau = msg.motor_cmd[i].tau; |
| 14 | raw.motorCmd[i].Kp = msg.motor_cmd[i].kp; |
| 15 | raw.motorCmd[i].Kd = msg.motor_cmd[i].kd; |
| 16 | |
| 17 | raw.motorCmd[i].reserve = msg.motor_cmd[i].reserve; |
| 18 | } |
| 19 | |
| 20 | memcpy(&raw.reserve[0], &msg.reserve[0], 4); |
| 21 | |
| 22 | raw.crc = crc32_core((uint32_t *)&raw, (sizeof(LowCmd) >> 2) - 1); |
| 23 | msg.crc = raw.crc; |
| 24 | } |
| 25 | |
| 26 | uint32_t crc32_core(uint32_t *ptr, uint32_t len) { |
| 27 | uint32_t xbit = 0; |
no test coverage detected