Repository navigation
Conversation
Roll, pitch and yaw from the XF headtracker's receiver (expansion port in "Wireless PPM" mode) become mix sources htR/htP/htY, with Companion support. Build option XF_HEADTRACKER, off by default, as SPACEMOUSE.
|
@kilrah As you worked on a similar project for ExpressLRS (https://github.com/kilrah/allxf-headtracker-elrs), would you be able to look/review this PR? Especially from the XF protocol perspective? Thx! |
|
I guess I hadn't even noticed there were multiple UART modes, I just went with what mine was set to i.e. "C Series Gimbal". If it's to be a dedicated thing for a head tracker I'd think that's better to use since it's 4x faster, but it's worth discussing if there's interest in an 8-channel input that could be more generic. Guess I have to add a note about mode in my README now though :D |
The expansion port now takes either output CwHeadTracker offers for it, told apart by the header: "Wireless PPM" (E7 9B, 25 Hz) or "C Series Gimbal" (A5 5A, about 50 Hz on my unit). Both also give the mode and the sensitivity, as two more sources htM and htS, on the same scale: angles at +-180 deg full range, mode and sensitivity as PPM carries them on CH7 and CH8. After a bad CRC the parser steps one byte and looks again, since C Series frames come too close together for the pause to resync.
|
@kilrah thanks for looking at it. I've added the C Series Gimbal frame too (0eb13b9): the port now takes either output and tells them apart by the header, and both give mode and sensitivity as well, as On the rate: on the XF one I measured about 51 Hz in C Series mode (a capture of 1018 frames) and 25 Hz in Wireless PPM, so 2x here rather than 4x. Maybe the Caddx one is faster. I'd still keep PPM next to it, as it's the more generic of the two and works with a wider range of setups, custom ones included. I don't use the headtracker with an XF gimbal but with a cheap Chinese two-servo one, and it works very well: a gimbal without spending much, and a simple way to get the channels to the receiver and the FC, and from there to the gimbal. |
Summary of changes:
This adds the XF (Nanjing Xianfei) headtracker as an input on an AUX serial port. Its roll, pitch, yaw, mode and sensitivity become five mix sources,
htR,htP,htY,htMandhtS, so the headtracker no longer has to come in through the trainer port or a Lua script, and the trainer port stays free for a real trainer link.Protocol. The headtracker's receiver has a UART on its expansion port, 115200 8N1. CwHeadTracker offers two outputs for it, and the radio takes either, told apart by the header.
"Wireless PPM", 25 frames a second:
E7 9B"C Series Gimbal", about 50 frames a second on my unit. It is the frame the XF C-20T and the Walksnail/Caddx GM gimbals take, the one ArduPilot's CADDX mount driver and INAV's serial gimbal send:
A5 5ANeither is documented by XF. I worked them out from captures of my unit and checked them against what CwHeadTracker shows; the C Series layout matches ArduPilot's driver. In PPM, channels 4-8 are roll, pitch, yaw, mode and sensitivity in CwHeadTracker's default mapping, and 1000-2000 us maps to -1024..1024. C Series comes out on the same scale: ±180 deg is ±1024, which is what the PPM output gives with CwHeadTracker's default ratio, and mode and sensitivity are scaled as PPM carries them on CH7 and CH8 (mode 2 is 2000 us and sensitivity 15 is 1968.75 us, so (mode - 1) x 1024 and sensitivity x 64). Captures of the same unit in the two outputs give the same values.
Radio
crc16(CRC_1021, ...).E7 9Bis 1663 us, andA5 5Acan turn up in the angles) cannot keep it out of step, even with C Series frames arriving too close together for the pause between them to help. It also restarts after the pause between PPM frames.htr,htp,hty,htmandhts. The sources are also in theSRC_STICKfilter, next to tilt and SpaceMouse.Scope. I kept to the SpaceMouse pattern: build option
XF_HEADTRACKER, OFF by default, in the Horus target, with the sources underPCBHORUS. On a TX16S image, measured against main:As suggested on Discord, it's meant as an option that users pick in Buddy's CloudBuild rather than part of the default builds; once this is in, I'll open the matching
targets.jsonentry in EdgeTX/cloudbuild. I'm happy to turn it on by default, or to make it available to more targets, if you prefer.Source numbering. As with any new source, the five new ones shift the numbers of every later source by 5 on
PCBHORUSradios. Models are not affected, since the YAML stores sources by name. On H7 radios with 99 telemetry sensors, the 10-bitsrcRawfields could already not hold the last telemetry sources: on a TX16S MK3 they run up to 584 against a limit of 511. With this change, that limit is reached 5 source numbers (under two sensors) earlier.Companion. It knows the new AUX mode and the five sources, with YAML tags
XFHT_ROLL,XFHT_PITCH,XFHT_YAW,XFHT_MODEandXFHT_SENSmatching the firmware. The sources are offered when AUX1 or AUX2 is set to the headtracker.Generated files
tools/generate-yaml.sh(15 targets).sim_string_list.hregenerated with m4.tools/cfn_sorter.shleavescfn_sort.cppunchanged.Testing
tests/xf_headtracker.cpp:tests/sources.cpp.tools/commit-tests.shpasses:-DXF_HEADTRACKER=ON: 248 tests;tests/xf_headtracker_yaml_test.cppcovers the YAML round trip, the names and the availability;tests-companionpasses all 44 tests with Qt 6.9.3.