Add pyserial workaround for Revo2Touch sensor API on older SDK#1
Open
brownwa wants to merge 1 commit into
Open
Add pyserial workaround for Revo2Touch sensor API on older SDK#1brownwa wants to merge 1 commit into
brownwa wants to merge 1 commit into
Conversation
The libbc_stark_sdk.so currently shipped via download-lib.sh is version
0.4.3, which hard-codes every touch-sensor API as "deprecated for current
firmware" and returns empty, even on Revo2Touch hardware where
modbus_get_device_info reports hardware_type=4. Version 0.8.1 of the SDK
(shipped with unitreerobotics/brainco_hand_service) does support the
touch APIs and talks to the same hands correctly.
This PR adds a standalone workaround that sidesteps the SDK version
mismatch entirely: scripts/touch_sensor_pyserial.py talks the same
Modbus RTU commands the newer SDK sends, using only pyserial, and works
on any installed SDK version. Verified on a Revo2Touch hand running
firmware 1.0.14.U — all 10 fingertip channels (thumb/index/middle/ring/
pinky × left+right) return a crisp 0-to-2500 normal_force reading when
pressed.
Also adds an FAQ entry (FAQ_en.md section 7) explaining the SDK-version
gotcha and both the "upgrade the .so" and "use the workaround" paths.
Register layout at address 4200 (30 x uint16, reverse-engineered by
time-aligning single-finger presses and cross-checked against what
libbc_stark_sdk 0.8.1 logs under TRACE):
regs[0..14] = 3 per finger, interleaved (normal_force,
tangential_force, tangential_direction)
regs[15..24] = 2 per finger, interleaved (self_proximity
as u32 lo/hi halves)
regs[25..29] = per-finger counter / status (not useful)
The firmware writes 0xFFFF as a "no data" sentinel on idle tangential
fields; the script masks those to 0.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
libbc_stark_sdk.socurrently shipped viadownload-lib.shis version 0.4.3, which hard-codes every touch-sensor API as "deprecated for current firmware" and returns empty — even on Revo2Touch hardware wheremodbus_get_device_inforeportshardware_type = 4and the physical sensors are installed and alive:Version 0.8.1 of the SDK (shipped with
unitreerobotics/brainco_hand_service) addsSTARK_HARDWARE_TYPE_REVO2_TOUCH = 4and accepts the touch-API calls on the same hands — but users of this repo can't easily pick it up without swapping out the.so, which risks breaking the ROS 2 wrapper.This PR adds a standalone workaround that bypasses the SDK version mismatch entirely.
What's added
ros2_stark_ws/src/ros2_stark_controller/scripts/touch_sensor_pyserial.pyTalks the same Modbus RTU commands the 0.8.1 SDK's
modbus_get_touch_statussends internally, using onlypyserial. Works on any installed SDK version.Press a fingertip and see per-finger
normal_forcego from 0 to ~2500.FAQ_en.mdsection 7 — explains the SDK-version gotcha with both the "upgrade the.so" and "use the workaround" paths.Register layout (reverse-engineered)
Reverse-engineered by time-aligning single-finger presses against the live register dump, cross-checked against what
libbc_stark_sdk0.8.1 logs atTRACElevel.Finger order:
f0=thumb, f1=index, f2=middle, f3=ring, f4=pinky.The firmware writes
0xFFFFas a "no data" sentinel on idle tangential fields; the script masks those to 0.Verification
Tested on a Revo2Touch hand (serial
BCXTL2334J..., firmware1.0.14.U). All 10 fingertip channels (thumb/index/middle/ring/pinky × left + right) return a crisp 0-to-2500normal_forcewhen pressed. Idle readings sit at 0. Palm has no sensor — only fingertips.Why ship this rather than just upgrade the SDK?
Three reasons:
libbc_stark_sdk.soto 0.8.1 requires a matching header-file update and afirmware_typebump in the config YAML, which is a larger and more disruptive change than a standalone script.Happy to follow up with a full SDK upgrade PR if that path is preferred, but the workaround gets touch data flowing today with zero risk to existing installs.
Test plan
pip install pyserial && python3 scripts/touch_sensor_pyserial.py --dualsucceeds and logstouch enable + calibrate: okfor both hands.normal_forcereading ≥ 500 on the corresponding finger.🤖 Generated with Claude Code