forked from pollen-robotics/AmazingHand
-
Notifications
You must be signed in to change notification settings - Fork 0
Kb/feature/add tactile sensing and haptic feedback #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kbhakt
wants to merge
7
commits into
main
Choose a base branch
from
kb/feature/add_tactile_sensing_and_haptic_feedback
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
134935f
add initial scripts for haptic coin and tactile fsr sensor
kbhakt 85a48f2
Resolve the pyside6 dependency
Juliaj 64b65c6
add haptic test script
kbhakt c0ece58
Update pixi.lock after adding sensor dependencies
kbhakt 3464ca2
update ci.yml
kbhakt 6e295b4
fix bugs in tactile sensing; update instructions in README and add BOM
kbhakt 67fe42e
update to src folder & update documentation
kbhakt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,3 +13,8 @@ target/ | |
| Demo/out/ | ||
| out/ | ||
| *.code-workspace | ||
|
|
||
| # Log, CSV, and HTML plot files | ||
| *.log | ||
| *.csv | ||
| *.html | ||
Empty file.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # Bill of Materials (BOM) | ||
|
|
||
| ## Required Components | ||
|
|
||
| | Component | Link | | ||
| |---|---| | ||
| | 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 | | ||
| | Pressure Sensors (FSR) | https://www.amazon.com/dp/B0FGD267GK | | ||
| | Resistor Kit | https://www.amazon.com/dp/B016NXK6QK | | ||
|
|
||
| > **Note:** FSR voltage divider uses a **5.1 kΩ** resistor in series with each pressure sensor. | ||
|
|
||
| --- | ||
|
|
||
| ## Nice to Have | ||
|
|
||
| | Component | Link | | ||
| |---|---| | ||
| | Silicone Flexible Jumper Wires (Nice Quality) | https://www.amazon.com/dp/B0DNPS4RVQ | | ||
| | Dual Male Jumper Wires | https://www.amazon.com/dp/B09P52PLK4 | | ||
| | Breadboard | https://www.amazon.com/dp/B07DL13RZH | | ||
| | Generic Jumper Wires | https://www.amazon.com/dp/B01EV70C78 | | ||
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| # AmazingHand — Sensors | ||
|
|
||
| ## Files | ||
|
|
||
| | File | Description | | ||
| |---|---| | ||
| | `config.toml` | Shared config — GPIO pins, SPI settings, sensor channels, logging and visualisation defaults | | ||
| | `ads1256.py` | ADS1256 driver — 24-bit, 8-channel | | ||
| | `tactile_sensing.py` | `TactileSensor` wrapper — reads config.toml and drives the ADS1256 | | ||
| | `tactile_sensing_post_visualize.py` | Offline Bokeh visualisation of logged CSV data | | ||
| | `haptic_coin.py` | `HapticCoin` PWM class for the QYF-740 coin motor | | ||
|
|
||
| --- | ||
|
|
||
| ## FSR Tactile Sensing (ADS1256) | ||
|
|
||
| ### Hardware | ||
|
|
||
| - **ADC HAT**: [Waveshare High-Precision AD HAT](https://www.waveshare.com/wiki/High-Precision_AD_HAT) | ||
| - ADS1256: 24-bit, 8 single-ended channels, SPI | ||
| - **Sensors**: FSR (Force Sensitive Resistors) wired in a voltage-divider circuit with a **5.1 kΩ resistor** in series with each FSR to each ADC input channel. | ||
|
|
||
| ### FSR Wiring Diagram | ||
|
|
||
|  | ||
|
|
||
| ### SPI Wiring (BCM pin numbers, set in `config.toml`) | ||
|
|
||
| | Signal | BCM | Pi header pin | | ||
| |---|---|---| | ||
| | MOSI (DIN) | GPIO 10 | Pin 19 | | ||
| | MISO (DOUT) | GPIO 9 | Pin 21 | | ||
| | SCLK | GPIO 11 | Pin 23 | | ||
| | CS | GPIO 22 | Pin 15 | | ||
| | RST | GPIO 18 | Pin 12 | | ||
| | DRDY | GPIO 17 | Pin 11 | | ||
|
|
||
| Enable SPI on the Pi: | ||
| ```bash | ||
| sudo raspi-config # Interface Options → SPI → Enable | ||
| ``` | ||
|
|
||
| ### Install dependencies | ||
|
|
||
| ```bash | ||
| pixi install | ||
| ``` | ||
|
|
||
| To add a single package interactively: | ||
|
|
||
| ```bash | ||
| pixi add --pypi lgpio | ||
| ``` | ||
|
|
||
| ### Run | ||
|
|
||
| **GUI (default):** | ||
| ```bash | ||
| pixi run python -m amazinghand_sensors.tactile_sensing | ||
| ``` | ||
|
|
||
| **Terminal only (no GUI window):** | ||
| ```bash | ||
| pixi run python -m amazinghand_sensors.tactile_sensing --terminal | ||
| ``` | ||
|
|
||
| See all flags: | ||
| ```bash | ||
| pixi run python -m amazinghand_sensors.tactile_sensing --help | ||
| ``` | ||
|
|
||
| ### Offline Visualization | ||
|
|
||
| Run without arguments to automatically load the **latest** `tactile_*.csv` from the log directory configured in `config.toml` (`[logging] log_dir`): | ||
|
|
||
| ```bash | ||
| pixi run python -m amazinghand_sensors.tactile_sensing_post_visualize | ||
| ``` | ||
|
|
||
| To visualize a **specific file**, pass it with `--file`: | ||
|
|
||
| ```bash | ||
| pixi run python -m amazinghand_sensors.tactile_sensing_post_visualize --file LOGS/tactile_20260101_120000.csv | ||
| ``` | ||
|
|
||
| See all flags: | ||
|
|
||
| ```bash | ||
| pixi run python -m amazinghand_sensors.tactile_sensing_post_visualize --help | ||
| ``` | ||
|
|
||
| CSV schema (long format — one row per channel per sample): | ||
|
|
||
| ``` | ||
| sensor_time, channel, raw, volts, force_norm | ||
| ``` | ||
|
|
||
| ### Tuning `fsr_r_fixed` | ||
|
|
||
| The `fsr_r_fixed` parameter must match the resistor you place in series with each FSR to form the voltage divider. The build uses **5 100 Ω (5.1 kΩ)**. Larger values increase sensitivity at low force; smaller values increase the measurable force range. | ||
|
|
||
| --- | ||
|
|
||
| ## Haptic Coin (QYF-740) | ||
|
|
||
| ### Pin conflict warning | ||
|
|
||
| The ADS1256 tactile sensing stack claims the following BCM GPIO pins. **Do not assign the HapticCoin to any of these:** | ||
|
|
||
| | BCM | Use | | ||
| |---|---| | ||
| | GPIO 8 | SPI0 CE0 (kernel) | | ||
| | GPIO 9 | SPI0 MISO | | ||
| | GPIO 10 | SPI0 MOSI | | ||
| | GPIO 11 | SPI0 SCLK | | ||
| | GPIO 17 | ADS1256 DRDY | | ||
| | GPIO 18 | ADS1256 RST | | ||
| | GPIO 22 | ADS1256 CS | | ||
| | GPIO 23 | ADS1256 CS_DAC | | ||
|
|
||
| Safe choices for the PWM output include GPIO 12, 13 (hardware PWM), 24, 25, 26, 27, or 35. | ||
|
|
||
| ### Wiring — [RPi 5 pinout](https://vilros.com/pages/raspberry-pi-5-pinout) | ||
|
|
||
|  | ||
|
|
||
| | Motor wire | Pi pin | | ||
| |---|---| | ||
| | GND | Pin 6 | | ||
| | VCC | Pin 2 (5 V) | | ||
| | PWM | Pin 35 (GPIO 19) | | ||
|
|
||
| ### Usage | ||
|
|
||
| ```python | ||
| from amazinghand_sensors.haptic_coin import HapticCoin | ||
|
|
||
| motor = HapticCoin(gpio_pin=19) | ||
| motor.vibrate_once(intensity=0.8, duration_s=0.5) | ||
| motor.cleanup() | ||
| ``` | ||
|
|
||
| Run the example test script as a module so relative imports resolve: | ||
|
|
||
| ```bash | ||
| pixi run python -m amazinghand_sensors.haptic_test | ||
| ``` |
Empty file.
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This motor is out of stock. Is this a good replacement https://www.amazon.com/Vibration-9000RPM-Replacement-Arduino-Projects/dp/B08GPMCP7J/140-3617096-9051911?psc=1 ?
There was a problem hiding this comment.
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?