Dashboard (web/hand_web.py) - Record/replay panel driving g1_record_replay.py as a pty child: take library (replay/download/duplicate/rename/delete/upload/delete-all), pause & resume, and in-take key buttons that grey out in the --fingers modes the recorder ignores (measured: in touch mode the keys change nothing at all). - /api/restart is container-aware: it kills inspire_g1 and lets the supervisor relaunch it. It used to run manage.sh, which started a SECOND inspire_g1 beside the supervised one - two writers on one RS-485 bus - and never returned. - Shape/combo libraries take a .bak on every write, with an undo button. Both files are rewritten in full, so deleting the last entry was unrecoverable. recorder/ - The recorder lives in this project now: one source of truth for the CLI and the dashboard, with pause/resume added to replay. - record.sh picks a runtime by itself (a python with the SDK, the vendored SDK, or the inspire-hand container). bundle.sh packs a ~340KB portable kit. tools/ - preflight.sh: read-only readiness report for a new robot (hardware, docker, build prerequisites, per-robot settings) ending in an install-path verdict. - fetch_deps.sh: stage build dependencies, verifying the libs are aarch64. - export_ui.py: regenerate an embedding app's vendored copy of the UI. docker/ - build_image.sh resolves its dependencies from several layouts: deps/ inside the project, /usr/local, a source install prefix, or a ROS2 colcon workspace (where the idl headers live when /usr/local has none). - web/ is copied in the last layer, so dashboard edits skip the C++ rebuild. - restart=always, and start.sh always builds so an edit cannot silently run a stale image. deps/unitree_sdk2 is vendored so a robot that has never seen the SDK can build. Docs: README quickstart + embedding notes, SETUP_G1 corrected (that udev rule stopped creating /dev/inspire_* symlinks a while ago), ROBOT_README describing a live install.
89 lines
2.3 KiB
C++
89 lines
2.3 KiB
C++
#pragma once
|
|
|
|
#include <array>
|
|
|
|
#include "comm.h"
|
|
#include "unitree/idl/go2/LowCmd_.hpp"
|
|
|
|
namespace unitree::common
|
|
{
|
|
|
|
void motorCmd2Dds(UNITREE_LEGGED_SDK::MotorCmd *raw, std::array<unitree_go::msg::dds_::MotorCmd_, 20> &dds)
|
|
{
|
|
for (int i = 0; i < 20; i++)
|
|
{
|
|
dds[i].mode(raw[i].mode);
|
|
dds[i].q(raw[i].q);
|
|
dds[i].dq(raw[i].dq);
|
|
dds[i].tau(raw[i].tau);
|
|
dds[i].kp(raw[i].Kp);
|
|
dds[i].kd(raw[i].Kd);
|
|
|
|
memcpy(&dds[i].reserve()[0], &raw[i].reserve[0], 12);
|
|
}
|
|
};
|
|
|
|
void bmsCmd2Dds(UNITREE_LEGGED_SDK::BmsCmd &raw, unitree_go::msg::dds_::BmsCmd_ &dds)
|
|
{
|
|
dds.off(raw.off);
|
|
|
|
memcpy(&dds.reserve()[0], &raw.reserve[0], 3);
|
|
};
|
|
|
|
uint32_t crc32_core(uint32_t *ptr, uint32_t len)
|
|
{
|
|
uint32_t xbit = 0;
|
|
uint32_t data = 0;
|
|
uint32_t CRC32 = 0xFFFFFFFF;
|
|
const uint32_t dwPolynomial = 0x04c11db7;
|
|
for (uint32_t i = 0; i < len; i++)
|
|
{
|
|
xbit = 1 << 31;
|
|
data = ptr[i];
|
|
for (uint32_t bits = 0; bits < 32; bits++)
|
|
{
|
|
if (CRC32 & 0x80000000)
|
|
{
|
|
CRC32 <<= 1;
|
|
CRC32 ^= dwPolynomial;
|
|
}
|
|
else
|
|
CRC32 <<= 1;
|
|
if (data & xbit)
|
|
CRC32 ^= dwPolynomial;
|
|
|
|
xbit >>= 1;
|
|
}
|
|
}
|
|
return CRC32;
|
|
};
|
|
|
|
void lowCmd2Dds(UNITREE_LEGGED_SDK::LowCmd &raw, unitree_go::msg::dds_::LowCmd_ &dds)
|
|
{
|
|
// with crc
|
|
memcpy(&dds.head()[0], &raw.head[0], 2);
|
|
|
|
dds.level_flag(raw.levelFlag);
|
|
dds.frame_reserve(raw.frameReserve);
|
|
|
|
memcpy(&dds.sn()[0], &raw.SN[0], 8);
|
|
memcpy(&dds.version()[0], &raw.version[0], 8);
|
|
|
|
dds.bandwidth(raw.bandWidth);
|
|
|
|
motorCmd2Dds(&raw.motorCmd[0], dds.motor_cmd());
|
|
bmsCmd2Dds(raw.bms, dds.bms_cmd());
|
|
|
|
memcpy(&dds.wireless_remote()[0], &raw.wirelessRemote[0], 40);
|
|
|
|
memcpy(&dds.led()[0], &raw.led[0], 12); // go2
|
|
memcpy(&dds.fan()[0], &raw.fan[0], 2);
|
|
dds.gpio(raw.gpio); // go2
|
|
|
|
dds.reserve(raw.reserve);
|
|
|
|
raw.crc = crc32_core((uint32_t *)&raw, (sizeof(raw) >> 2) - 1);
|
|
|
|
dds.crc(raw.crc);
|
|
};
|
|
} |