Skip to content

Kb/feature/add tactile sensing and haptic feedback#7

Merged
Juliaj merged 9 commits intomainfrom
kb/feature/add_tactile_sensing_and_haptic_feedback
Apr 21, 2026
Merged

Kb/feature/add tactile sensing and haptic feedback#7
Juliaj merged 9 commits intomainfrom
kb/feature/add_tactile_sensing_and_haptic_feedback

Conversation

@kbhakt
Copy link
Copy Markdown

@kbhakt kbhakt commented Mar 23, 2026

Adds initial support for FSR-based tactile sensing and haptic coin motor feedback.

Changes:

Initial scripts for haptic coin motor and tactile FSR sensor
Haptic test script
Resolved PySide6 dependency
Bug fixes in tactile sensing
Updated README with setup instructions and BOM
Added sensor dependencies to pixi.lock and updated CI

Copy link
Copy Markdown

@Juliaj Juliaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall the code looks good to me. This is a good addition to the original upstream repo, let's add it to FORK.md. In terms of location, how do you feel about moving Sensors to under src ? Moving it there make it easier to release this as standalone Python package for other applications to reuse.

There are some Python styling issues which our pre-commit wasn't able to catch. We also missed this with previous check-in. I am planning to fix them after your PR, changes are parked at branch jj/refactor/enhance_ruff_check.

Comment thread docs/BOM.md
|---|---|
| Camera | https://www.amazon.com/dp/B0CLRJZG8D |
| AD/DA Expansion Hat | https://www.amazon.com/dp/B09Q8Y5F7Y |
| Haptic Motors | https://www.amazon.com/dp/B0FX9HW33Z |
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated with commit. Let me know what you think.

For the src move:
Keeping sensors as a sibling package (amazinghand_sensors/) rather than a subpackage lets users install the core SDK without hardware-specific deps like lgpio and spidev. Each package gets its own pyproject.toml, versions independently, and declares only the deps it actually needs.

Is this ok or do I need to account for something else I may have missed?

@kbhakt
Copy link
Copy Markdown
Author

kbhakt commented Apr 6, 2026

Also, have you been able to run this code successfully on your setup with all the hardware -- any challenges or questions on setting up your system?

Comment thread src/amazinghand_sensors/ads1256.py Outdated
raise ValueError(f"ADS1256 single-ended channel must be 0–7, got {channel}")
self._write_reg(REG["REG_MUX"], (channel << 4) | 0x08)

def _set_diff_channel(self, channel: int):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_set_channel and _set_diff_channel both use channel as input argument. It seems that the pattern is standard even though the semantic for channel is different, physical channel versus channel pair. A small clarify improvement is renaming the channel here to pair_index, diff_channel or something similar.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to diff_channel and added a comment clarifying it's a pair index (0–3), not a physical AIN pin number, with the pin mapping spelled out.

Comment thread src/amazinghand_sensors/haptic_coin.py Outdated
logger.debug("Ramping up")
for duty in range(0, 101, step):
self.motor.value = duty / 100.0
sleep(delay_s)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sleep(...) here is fine. If we tighten the timing precision, we could use a monotonic clock. For example,

       try:
            next_tick = monotonic()
            while True:
                logger.debug("Ramping up")
                for duty in range(0, 101, step):
                    self.motor.value = duty / 100.0
                    next_tick += delay_s
                    sleep(max(0.0, next_tick - monotonic()))
                logger.debug("Ramping down")
                for duty in range(100, -1, -step):
                    self.motor.value = duty / 100.0
                    next_tick += delay_s
                    sleep(max(0.0, next_tick - monotonic()))
                next_tick += pause_s
                sleep(max(0.0, next_tick - monotonic()))
...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added. and left a comment for time.perf_counter for future if we need sub 1 ms accuracy

kbhakt added 2 commits April 18, 2026 10:56
… cleanup issues, remove dead code and unused imports, and register the package as an editable pixi dependency
@kbhakt
Copy link
Copy Markdown
Author

kbhakt commented Apr 18, 2026

@Juliaj can you review again when you get a chance? thanks

@Juliaj
Copy link
Copy Markdown

Juliaj commented Apr 20, 2026

@kbhakt, I tested out the tactile sensor and haptic coin. The python scripts ran without any issue. Haptic coin behaves as expected.

For tactitle sensor, I used 10 kΩ resister (config.toml was updated with fsr_r_fixed = 10000). The sensor was wired to AIN3 (thumb). I noticed following

  • Single thumb on AIN3: Thumb sat near ~0.06 V with real variation when pressed;
  • index–pinky stayed near ~0.61 V with little structure → floating / unwired inputs.

Is this expected ? Attached image is my setup.
image

@kbhakt
Copy link
Copy Markdown
Author

kbhakt commented Apr 21, 2026

  1. Congrats on getting your hardware setup!!

  2. For your tactile sensor I think there is a couple things wrong with your wiring

  • first on this hat you should be using AGND (analog ground) not just regular GND (since this also does Digital to Analog conversion)

  • I think you're ground is not actually connected to your tactile sensor. on your breadboard you need to have another wire that connects the 2 green wires. this is not electrically connected on the breadboard (only the 5 holes on the left / right panels are connected not all 10)

When I press the sensor with the 5.1 kOhm resistor I get my voltage to go to around ~2.3V (note the magnitude and sensitivity of this will depend on your resistor value you choose).

For your floating wires, hard to know what the noise will be but should not worry about it if you're not using those channels.

One thing I have noticed is that if you use AIN1 sometimes that can be a noisier signal than using AIN7. not sure if this is a shielding issue but something I have observed in the past.

Reference of my setup:
IMG_9015

@Juliaj
Copy link
Copy Markdown

Juliaj commented Apr 21, 2026

  • I think you're ground is not actually connected to your tactile sensor.

You're totally right, a newbie problem. The UI is pretty awesome.
image

Copy link
Copy Markdown

@Juliaj Juliaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@Juliaj Juliaj merged commit a0a5607 into main Apr 21, 2026
2 checks passed
@Juliaj Juliaj deleted the kb/feature/add_tactile_sensing_and_haptic_feedback branch April 21, 2026 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants