Skip to content
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

Feature/bldc haptics #60

Merged
merged 31 commits into from
Jun 3, 2023
Merged

Feature/bldc haptics #60

merged 31 commits into from
Jun 3, 2023

Conversation

finger563
Copy link
Contributor

@finger563 finger563 commented May 25, 2023

Description

  • Added bldc_haptics component which templates on a motor concept (works with bldc_motor right now) - copied with modifications from smartknob as initial implementation.
  • Added bldc_haptics_example to showcase new component.
  • Added set_config api to mirror get_config in Pid class
  • Updated Pid::set_config api to allow user to specify whether they want to clear the state or not (default true)
  • Added optional gpio_fault and fault detection to BldcDriver class (and use it in examples)
  • add maybe_unused to suppress compiler warning in fast_math
  • Added missing example usage doc to bldc_motor class
  • Moved non-templated bldc motor types into their own header files (now inside espp::detail namespace) and updated example accordingly
  • Allow configuring the pid gain factors for detents of BldcHaptics
  • Update to use new espp::detail namespace for types in BldcMotor
  • Update configuration of BldcMotor KV value
  • Add (currently untested) configuration parameter for phase_inductance in BldcMotor
  • Set motor to Torque control in BldcHaptics
  • Add motion control config api to concept requirement in BldcHaptics
  • Added missing parameter documentation to rtsp method
  • Added missing parameter documentation for ftp method
  • Send multiline response as multiline response (multiline=true) for FEAT in ftp client session
  • Updated docs and rebuilt them
  • Updated CI

Motivation and Context

Closes #7
We have support for haptics driven by specific haptic motor drivers (such as the DRV2605), but there are some use cases where directly integrating haptics into the user input device itself can provide a more configurable and interactive experience. One such example is shown by the smartknob project which uses a small BLDC gimbal motor as an input device (rotary encoder) with configurable detents, min/max ranges, haptic buzzes/clicks, and return to center functionality. Given that this is all controlled with a BLDC motor, the behavior of the input / haptics can change dynamically depending on the state of the program for more interesting user interfaces.

How has this been tested?

  • Building and running the updated bldc_motor/example with the new bldc motor test stand
  • Building and running the new bldc_haptics/example with the new bldc motor test stand (design forthcoming in new repo).

Screenshots (if appropriate, e.g. schematic, board, console logs, lab pictures):

image
image

bldc_motor/example

updated-bldc-motor-example-compressed.mp4

bldc_haptics/example

coarse values strong detents (best with sound)

coarse_values_strong_detents.mp4

magnetic detents (best with sound)

magnetic_detents.mp4

On / Off Strong Detents (best with sound)

on_off_strong.mp4

Multi-rev no detents

multi_rev_no_detents.mp4

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update
  • Hardware (schematic, board, system design) change
  • Software change

Checklist:

  • My change requires a change to the documentation.
  • I have added / updated the documentation related to this change via either README or WIKI

Software

  • I have added tests to cover my changes.
  • I have updated the .github/workflows/build.yml file to add my new test to the automated cloud build github action.
  • All new and existing tests passed.
  • My code follows the code style of this project.

* Added bldc_haptics component which templates on a motor concept (works with bldc_motor right now) - copied with modifications from smartknob as initial implementation.
* Added bldc_haptics_example to showcase new component.
@finger563 finger563 marked this pull request as draft May 25, 2023 21:55
@finger563 finger563 linked an issue May 25, 2023 that may be closed by this pull request
@finger563 finger563 added haptics bldc Related to Brushless DC Motors enhancement New feature or request labels May 26, 2023
@finger563 finger563 self-assigned this May 26, 2023
* Updated PID config api to allow user to specify whether they want to clear the state or not (default true)
* Added `set_config` api to mirror `get_config`
* Updated docs to include bldc haptics info
* Updated bldc_haptics comments for more complete docs and remove unused code
* Updated bldc_motor to point to example usage (was missing)
* Added fault pin (optional) to bldc_driver as an input with associated API
* Added mutex to protect en / fault pins (and check values before setting enable)
* Update bldc_motor example to use config for tinyS3 test stand (works!)
* Update bldc_motor example to quit if the driver reports a fault
* Update bldc_driver to configure the fault pin as pull-down (since fault is high) to prevent always triggering fault condition
* Update bldc_haptics example to use fault pin on motor driver and exit if the driver goes into fault condition
* Allow the kp/kd factors to be configured in the BldcHaptics::Config struct
* Fix potential bug from smartknob project where min/max (lower/upper) kd factors were inverted
* Moved non-templated types into their own header files (now inside espp::detail namespace) and updated example accordingly
* Allow configuring the pid gain factors for detents of BldcHaptics
* Update to use new espp::detail namespace for types in BldcMotor
* Set motor to Torque control in BldcHaptics
* Add motion control config api to concept requirement in BldcHaptics
* Tuning the gain factors for the detent pid
* Added another detent config (on/off)
* Updated return to center detent config to have position width properly set
* Added missing parameter documentation to rtsp method
* Added missing parameter documentation
* Send multiline response as multiline response (multiline=true) for FEAT
* Updated example to better indicate what config it is running (print it out completely)
* Updated detent config to support libfmt printing
* Added equality operator for detentconfig
* Removed integrator for detent pid and increased output min/max
* Updated gains for feeling of detents
* Remove integrator from detent PID
* Add example for playing haptics to doc
* Add API for getting current position from the haptics (for input)
* Update pid config for haptics
* Shorten example
* Run the haptic click / buzz test and add it to docs
* Run the loop_foc after calling the move command, instead of after the sleep like a dumbass.
* Update logger to print higher precision
* Add phase inductance parameter to bldc_motor (not tested)
* Update bldc_motor example to use motor for printing sensor data
* Update bldc_motor example to have proper zero electrical angle for motor on new test stand.
* Update bldc_motor example for less clamping
* updated haptics example to have correct zero electrical offset for this motor on this test stand
* updated haptics example to have higher current limit
* Updated to show more of the possible preconfigured detent configs and print them more cleanly
* Updated bldc_haptics output min/max to be same as velocity pid was since they both operate on current
* Updated logging for bldc_haptics
* Updated how position is updated when changing detent configuration
* Updated use of kd_factor_min/max to match how smartknob did it
* Properly send the torque to the motor (not the negative torque)
* Updated libfmt printing of DetentConfig structs
* Update gains in example
* Update default gains
@finger563 finger563 marked this pull request as ready for review June 3, 2023 20:08
@finger563 finger563 merged commit 72a7a43 into main Jun 3, 2023
@finger563 finger563 deleted the feature/bldc_haptics branch June 3, 2023 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bldc Related to Brushless DC Motors enhancement New feature or request haptics motor control
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for haptics, driven by BLDC
1 participant