MCPcopy Create free account
hub / github.com/TeleHuman/TextOp / get_crc

Function get_crc

TextOpDeploy/src/textop_ctrl/src/motor_crc_hg.cpp:3–24  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include "common/motor_crc_hg.h"
2
3void 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
26uint32_t crc32_core(uint32_t *ptr, uint32_t len) {
27 uint32_t xbit = 0;

Callers 3

CheckInitializeMethod · 0.70
send_motor_commandsMethod · 0.70

Calls 1

crc32_coreFunction · 0.70

Tested by

no test coverage detected