Skip to content

Improve drive power management and logging#2

Open
jgx0 wants to merge 8 commits into
millburnx:masterfrom
jgx0:master
Open

Improve drive power management and logging#2
jgx0 wants to merge 8 commits into
millburnx:masterfrom
jgx0:master

Conversation

@jgx0

@jgx0 jgx0 commented May 30, 2026

Copy link
Copy Markdown

This pull request introduces improvements to the Pedro drive subsystem and the OpMode base class, focusing on safer control scaling based on battery voltage and more robust loop timing. The main changes include adding voltage-aware power limiting to the drive logic, new configuration parameters for tuning, and a fix to prevent division by zero in the control loop timing.

Drive power scaling and voltage handling:

  • Added logic in Pedro to read the robot's voltage and automatically scale drive power if the voltage drops below a configurable threshold, enhancing safety and battery management. If voltage reading fails, the telemetry now reports it only once. (Pedro.kt)
  • Introduced new configuration parameters to control drive power limits, voltage-based scaling, and thresholds, making it easier to tune robot behavior for different battery conditions. (Pedro.kt)
  • Imported kotlin.math.min to support the new drive power scaling logic. (Pedro.kt)

Loop timing robustness:

  • In OpMode, added a minimum delta time constant and logic to ensure the control loop never divides by zero, preventing possible crashes or instability when measuring loop frequency. (OpMode.kt) [1] [2]

State tracking:

  • Added a voltageReadFailed flag to Pedro to avoid redundant telemetry messages if voltage reading fails repeatedly. (Pedro.kt)Before issuing a pull request, please see the contributing page.

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