2026 remote: tabbed Nextion UI, robot telemetry, servo centre calibration
Protocol v4: CmdPacket grows to 26 bytes (cal_cmd, cal_servo, cal_value); new 30-byte Telemetry rides back on the nRF24 ack payload (robot state, IMU, battery, 18 joint angles, packets/s, servo-cal echo). Each end drops wrong-length packets, so version mismatches still fail closed. Robot (owner-approved): SERVO_CAL state while disarmed, per-servo centre trims (+-200 us) in EEPROM, telemetry, battery reading; the IMU estimate now always runs (leveling still gated by ROBOT GYRO). Remote: generated HMI (scripts/make_remote_hmi.py) with pages splash, drive, status, servos, cal, setup, upload; page-aware NextionUI that only writes the showing page and only what changed; servo calibration and UPDATE DISPLAY on the touchscreen and serial console; battery module. The display is on Serial2 (pins 7/8), found on the real remote; the old sketch's Serial1 was never connected to it. Sim: RF24 shim supports ack payloads, API version 8 (hxsim_get_ack_payload); sim_smoke checks telemetry and every CAL command. Unity CmdPacket mirror updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
481610c9fd
commit
0b836af8de
40 files changed
+1463
-281
No files matched your search
@@ -14,7 +14,10 @@ namespace HexapodSim
|
||||
public short rx, ry, rz;
|
||||
public short remote_roll, remote_pitch;
|
||||
public short body_height; // -1000 lowest .. 0 default .. 1000 highest
|
||||
public short cal_value; // servo centre calibration (remote only; 0 here)
|
||||
public byte speed_scale, flags, seq;
|
||||
public byte cal_cmd; // CAL_NONE (0): the sim's remote never calibrates servos
|
||||
public byte cal_servo;
|
||||
|
||||
public const byte FLAG_ARMED = 1 << 0;
|
||||
public const byte FLAG_STAND = 1 << 1;
|
||||
@@ -73,7 +76,7 @@ namespace HexapodSim
|
||||
// "Reload firmware" and the new code runs. Each load is a fresh power-on.
|
||||
public sealed class HexapodSimNative : IDisposable
|
||||
{
|
||||
public const int ExpectedApiVersion = 7; // HXSIM_API_VERSION
|
||||
public const int ExpectedApiVersion = 8; // HXSIM_API_VERSION
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate int IntFn();
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate void VoidFn();
|
||||
@@ -88,6 +91,7 @@ namespace HexapodSim
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate void ServosFn(int[] us, int[] attached, uint[] writes);
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate void FloatsFn(float[] values);
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate void TwoFloatsFn(float a, float b);
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate int AckFn(byte[] bytes, int cap);
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate void BodyFn(float[] pos3, float[] quatWxyz4, out float yawDeg, out int contactMask);
|
||||
|
||||
IntPtr handle_;
|
||||
@@ -107,6 +111,7 @@ namespace HexapodSim
|
||||
StatusFn getStatus_;
|
||||
TwoFloatsFn setGroundTilt_;
|
||||
BodyFn getBody_;
|
||||
AckFn getAckPayload_;
|
||||
|
||||
public string LoadedFrom { get; private set; }
|
||||
|
||||
@@ -146,6 +151,7 @@ namespace HexapodSim
|
||||
n.getStatus_ = n.Fn<StatusFn>("hxsim_get_status");
|
||||
n.setGroundTilt_ = n.Fn<TwoFloatsFn>("hxsim_set_ground_tilt");
|
||||
n.getBody_ = n.Fn<BodyFn>("hxsim_get_body");
|
||||
n.getAckPayload_ = n.Fn<AckFn>("hxsim_get_ack_payload");
|
||||
|
||||
int version = n.apiVersion_();
|
||||
if (version != ExpectedApiVersion)
|
||||
@@ -205,6 +211,10 @@ namespace HexapodSim
|
||||
readonly float[] bodyPos_ = new float[3], bodyQuat_ = new float[4];
|
||||
// Kinematic body from the DLL, robot-world frame. The rotation is a
|
||||
// robot-frame quaternion held in a Unity Quaternion for its math only.
|
||||
// The robot's telemetry (HexapodProtocol.h Telemetry, 30 bytes) from the
|
||||
// last ack payload; returns its length, 0 before the first packet.
|
||||
public int GetAckPayload(byte[] buf) => getAckPayload_(buf, buf.Length);
|
||||
|
||||
public void GetBody(out Vector3 posMm, out Quaternion rotRobot, out float yawDeg, out int contactMask)
|
||||
{
|
||||
getBody_(bodyPos_, bodyQuat_, out yawDeg, out contactMask);
|
||||
|
||||
Reference in new issue
Block a user