Firmware simulation, Unity project, and sim-verified robot fixes
Simulation - sim/: the unchanged robot firmware compiled into hexapod_sim.dll against PC stand-ins (Arduino, Servo, Wire + register-level MPU6050, RF24 with matching-config radio), a kinematic body model (support plane + planted-foot odometry) that also drives the simulated IMU, and a headless smoke test (sim_smoke). build.ps1 builds and tests. - Hexapod_Simulation_Unity/ folded in (history kept in a bundle outside the repo). Assets/HexapodSim loads the DLL, drives the existing leg rig, and offers joystick / keyboard / robot-serial input plus a test panel. Robot (all found or confirmed in the simulation) - Config.h geometry taken from the Unity model. - IK femur elevation sign, gait stance direction, body pose rotation direction, yaw lever arm. - Stance feet integrated from the current command; gait restarts at mid-stance; heading integrates the applied turn rate, only while walking. - Leg clearance and reach checks (Limits::feetFeasible); walk command and body pose scaled as a whole, pose scale rate-limited, planted feet guarded so the body never snaps or legs collide. - Robot-gyro self-leveling as an integrator. - Heading mode: steering relative to the body; S walks backward. - Standing height from the remote (STANCE_HEIGHT_RANGE_MM). Protocol v3 (reflash both boards) - CmdPacket gains body_height (22 bytes). Remote - Height slider (Nextion hHeight/nHeight, serial [ ]). - Fixed unspecified I2C read order in RemoteIMU. LEGACY/: owner's old Nextion HMI and remote hardware assets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
91dac16fca
commit
935526eab5
145 files changed
+431258
-114
No files matched your search
@@ -28,21 +28,26 @@ struct CmdPacket {
|
||||
int16_t rx = 0, ry = 0, rz = 0; // right stick: roll/pitch/yaw, or X/Y/Z offset if FLAG_RSTICK_XLATE
|
||||
int16_t remote_roll = 0; // remote handset tilt (feedforward), only honored with FLAG_REMOTE_GYRO
|
||||
int16_t remote_pitch = 0;
|
||||
int16_t body_height = 0; // standing height setting: -1000 lowest, 0 = default, +1000 highest
|
||||
uint8_t speed_scale = 128; // 0-255, multiplies vx/vy
|
||||
uint8_t flags = 0; // bit-packed, see FLAG_* below
|
||||
uint8_t seq = 0; // increments every transmitted packet
|
||||
};
|
||||
|
||||
// Both ends are Teensy (Cortex-M7, little-endian, 2-byte int16 alignment):
|
||||
// 8 x int16 + 3 x uint8 = 19 bytes, padded to 20. If a different MCU family
|
||||
// 9 x int16 + 3 x uint8 = 21 bytes, padded to 22. If a different MCU family
|
||||
// ever joins, pack the struct explicitly rather than trusting this.
|
||||
static_assert(sizeof(CmdPacket) == 20, "CmdPacket layout changed - reflash both boards");
|
||||
static_assert(sizeof(CmdPacket) == 22, "CmdPacket layout changed - reflash both boards");
|
||||
static_assert(sizeof(CmdPacket) <= 32, "nRF24L01 payloads are limited to 32 bytes");
|
||||
|
||||
constexpr uint8_t FLAG_ARMED = 1 << 0;
|
||||
constexpr uint8_t FLAG_STAND = 1 << 1; // 0 = sit requested, 1 = stand requested
|
||||
constexpr uint8_t FLAG_WALK = 1 << 2; // left stick past deadzone -> walking
|
||||
constexpr uint8_t FLAG_MODE_B = 1 << 3; // 0 = mode A direct, 1 = mode B heading-hold
|
||||
// Mode B (steering), relative to where the body faces right now: the left
|
||||
// stick's forward/back component walks forward/back, its sideways component
|
||||
// steers - forward+left or back+left walk while turning left, left alone
|
||||
// turns on the spot while held. Released, the robot holds its heading.
|
||||
constexpr uint8_t FLAG_MODE_B = 1 << 3; // 0 = mode A direct, 1 = mode B heading
|
||||
constexpr uint8_t FLAG_RSTICK_XLATE = 1 << 4; // 0 = right stick = rotation, 1 = translation
|
||||
constexpr uint8_t FLAG_GAIT_WAVE = 1 << 5; // 0 = tripod requested, 1 = wave requested
|
||||
constexpr uint8_t FLAG_REMOTE_GYRO = 1 << 6; // remote tilt feedforward enabled
|
||||
|
||||
Reference in new issue
Block a user