set data, todo: send by lcm
| 275 | |
| 276 | // set data, todo: send by lcm |
| 277 | void LowStateHandler(const void *message) { |
| 278 | unitree_hg::msg::dds_::LowState_ low_state = |
| 279 | *(const unitree_hg::msg::dds_::LowState_ *)message; |
| 280 | |
| 281 | if (low_state.crc() != |
| 282 | Crc32Core((uint32_t *)&low_state, |
| 283 | (sizeof(unitree_hg::msg::dds_::LowState_) >> 2) - 1)) { |
| 284 | std::cout << "low_state CRC Error" << std::endl; |
| 285 | return; |
| 286 | } |
| 287 | |
| 288 | // get motor state |
| 289 | MotorState ms_tmp; |
| 290 | for (int i = 0; i < G1_NUM_MOTOR; ++i) { |
| 291 | ms_tmp.q.at(i) = low_state.motor_state()[i].q(); |
| 292 | ms_tmp.dq.at(i) = low_state.motor_state()[i].dq(); |
| 293 | } |
| 294 | motor_state_buffer_.SetData(ms_tmp); |
| 295 | |
| 296 | // get imu state |
| 297 | ImuState imu_tmp; |
| 298 | imu_tmp.omega = low_state.imu_state().gyroscope(); |
| 299 | imu_tmp.rpy = low_state.imu_state().rpy(); |
| 300 | imu_tmp.quat = low_state.imu_state().quaternion(); |
| 301 | imu_tmp.abody = low_state.imu_state().accelerometer(); |
| 302 | imu_state_buffer_.SetData(imu_tmp); |
| 303 | // update mode machine |
| 304 | if (mode_machine_ != low_state.mode_machine()) { |
| 305 | if (mode_machine_ == 0) |
| 306 | std::cout << "G1 type: " << unsigned(low_state.mode_machine()) |
| 307 | << std::endl; |
| 308 | mode_machine_ = low_state.mode_machine(); |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | void LowCommandWriter() { |
| 313 | unitree_hg::msg::dds_::LowCmd_ dds_low_command; |
nothing calls this directly
no test coverage detected