Skip to content

Stspin Motor driver integration#3734

Merged
GrayHoang merged 27 commits into
UBC-Thunderbots:masterfrom
GrayHoang:motor_driver_integration
May 29, 2026
Merged

Stspin Motor driver integration#3734
GrayHoang merged 27 commits into
UBC-Thunderbots:masterfrom
GrayHoang:motor_driver_integration

Conversation

@GrayHoang
Copy link
Copy Markdown
Contributor

Description

Isolates the motor driver related changes from #3715

resolves #3711

Please look mainly at motor.cpp and the new motor_controller directory in embedded

Testing Done

Resolved Issues

Length Justification and Key Files to Review

Review Checklist

It is the reviewers responsibility to also make sure every item here has been covered

  • Function & Class comments: All function definitions (usually in the .h file) should have a javadoc style comment at the start of them. For examples, see the functions defined in thunderbots/software/geom. Similarly, all classes should have an associated Javadoc comment explaining the purpose of the class.
  • Remove all commented out code
  • Remove extra print statements: for example, those just used for testing
  • Resolve all TODO's: All TODO (or similar) statements should either be completed or associated with a github issue

Copy link
Copy Markdown
Contributor

@StarrryNight StarrryNight left a comment

Choose a reason for hiding this comment

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

Reviewed a bit, will finish the rest later

Comment thread src/software/embedded/gpio/gpio.cpp Outdated
* motor fault
* @param motor_faults a set of faults associated with this motor
*/
MotorFaultIndicator(bool drive_enabled,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Passing in drive_enabled seems redundant as we can just initialize the boolean as false.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure about if this exact use case exists but I'm pretty sure there's an instance where we may want to be able to disable the motors immediately upon startup of motor service (e.g. the robot is reset after a motor fault, and wants to immediately disable previously faulted motors).

Copy link
Copy Markdown
Contributor

@Andrewyx Andrewyx left a comment

Choose a reason for hiding this comment

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

Almost there. I think there is a lot of work involved in cleaning up motor.cpp and motor.h after auditing them. Both of these files seem to include far to much state leakage and exposes too much of the SPI related implementation. Otherwise, for the scope of this PR, I left a few minor comments. Please create a subsequent issue detailing the work involved for a future motor refactor.

Comment thread src/software/embedded/services/BUILD
Comment thread src/software/embedded/services/motor.cpp
Comment thread src/software/embedded/services/motor.h
Comment thread src/software/embedded/thunderloop.h
@GrayHoang GrayHoang mentioned this pull request May 26, 2026
4 tasks
@GrayHoang
Copy link
Copy Markdown
Contributor Author

A lot of the stuff in motor.cpp looks like unified fault handling and command distribution that is common to both trinamics and stspin drivers. We could probably simplify that whole interface by abstracting the motor fault handling to its own separate class? But that's for another pr lol

@GrayHoang GrayHoang merged commit 4cfd194 into UBC-Thunderbots:master May 29, 2026
6 of 7 checks passed
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.

MDv6 Thunderloop Integration

5 participants