Skip to content

Created abstract base class PowerHAL - #3982

Open
Lo3wer wants to merge 2 commits into
UBC-Thunderbots:masterfrom
Lo3wer:abstract-class-of-powerhal
Open

Lo3wer wants to merge 2 commits into
UBC-Thunderbots:masterfrom
Lo3wer:abstract-class-of-powerhal

Conversation

@Lo3wer

@Lo3wer Lo3wer commented Oct 8, 2026 •

Copy link
Copy Markdown

Description

Created abstract class PowerHAL. Serves as an interface for tests and the ESP to talk through. See issue 3981 for full architecture and scope of future changes.

Testing Done

N/A

Resolved Issues

Resolves: #3980

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

This comment was marked as off-topic.

@Andrewyx

Andrewyx commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

is this ready for review? If not, mark as draft?

@Lo3wer

Lo3wer commented Oct 11, 2026 •

Copy link
Copy Markdown
Author

The pull request is ready for review and closes the specific issue mentioned, but is a part of an umbrella issue for the power firmware refactor rfc, see #3981. I have moved necessary documentation to the main issue #3981 and only mentioned changes in #3980, and removed unnecessary details.

@StarrryNight StarrryNight left a comment

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.

Left some comments. LGTM but can you make this a part of a stacked PR so we can get coherent code merges? There will probably be some changes to the abstract interface once we start implementing the concrete classes.

Once we resolve the comments we can start implementing the concrete classes.

Just to clarify. The plan rn for autokick-chip is to deprecate the breakbeam condition in chicker and make it a state machine trigger event?

Comment on lines +27 to +31
// Chicker break beam
/**
* @return true if the break beam is tripped, false otherwise
*/
virtual bool getBreakBeamTripped() = 0;

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.

Do we still need this if we are making breakbeam tripped an update event.

virtual float getBatteryVoltage() = 0;
/**
* @return the current draw in amps
*/

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.

There should probably be a micros() function to get time, implemented differently in EspHal and SimHal

Comment on lines +17 to +24
* @param pulse_width kicker pulse width in microseconds
*/
virtual void kick(uint32_t pulse_width) = 0;
/**
* Fires the chipper.
*
* @param pulse_width chipper pulse width in microseconds
*/

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.

We will probably clamp the upper limit of pulse_width somewhere, or is it clamped upstream? If we want to clamp it in the firmware add docs.

virtual void setDribblerSpeed(uint32_t speed_rpm) = 0;
/**
* Advances the dribbler ramp and applies the resulting PWM output.
*/

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.

Could this be combined such that update_dribbler passes in a speed value and also run the ramp towards it?

* @return the battery voltage in volts
*/
virtual float getBatteryVoltage() = 0;
/**

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.

Missing unit since the getCurrentDrawAmp() below comes with units

virtual void setCapacitorPin(bool pin_state) = 0;
/**
* Updates the capacitor charger and recharges if necessary.
*/

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.

Whats the difference? Could we just keep one of them?

@GrantYu9
GrantYu9 requested review from GrantYu9 and removed request for GrantYu9 October 14, 2026 03:01
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.

Design and implement abstract class of PowerHal

4 participants