feat: Add battery-aware speed limiter ROS2 node (Issue #321) #327

Merged
sl-jetson merged 1 commits from sl-controls/issue-321-battery-speed into main 2026-03-03 06:45:19 -05:00
Owner

Summary

Implements battery-aware speed limiter that adjusts robot speed based on battery state to preserve charge and prevent deep discharge.

Features

  • Subscribes to /saltybot/battery_state (sensor_msgs/BatteryState)
  • Publishes speed limit factor on /saltybot/speed_limit_factor (Float32, 0.0-1.0)
  • Battery percentage thresholds:
    • 100-50%: 1.0 (full speed)
    • 50-25%: 0.7 (70% speed)
    • 25-15%: 0.4 (40% speed)
    • <15%: 0.0 (stop, preserve battery)
  • Automatically prevents deep discharge by stopping movement below 15%
  • Reduces speed to maximize operational duration as battery drains
  • Configurable thresholds and speed factors
  • Graceful voltage-based fallback when percentage unavailable

Testing

30+ comprehensive unit tests covering:

  • All threshold transitions (high to low and low to high)
  • Boundary conditions at each threshold
  • Parameter customization (thresholds and speed factors)
  • Limiting enable/disable functionality
  • Edge cases (0%, 100%, rapid transitions)
  • Realistic scenarios (full charge cycle, continuous updates)

Configuration

Parameters configurable via YAML:

  • Threshold percentages (full, reduced, critical, stop levels)
  • Speed factors (1.0, 0.7, 0.4, 0.0)
  • Publishing frequency (default 10 Hz)
  • Enable/disable limiting

🤖 Generated with Claude Code

## Summary Implements battery-aware speed limiter that adjusts robot speed based on battery state to preserve charge and prevent deep discharge. ## Features - Subscribes to /saltybot/battery_state (sensor_msgs/BatteryState) - Publishes speed limit factor on /saltybot/speed_limit_factor (Float32, 0.0-1.0) - Battery percentage thresholds: - 100-50%: 1.0 (full speed) - 50-25%: 0.7 (70% speed) - 25-15%: 0.4 (40% speed) - <15%: 0.0 (stop, preserve battery) - Automatically prevents deep discharge by stopping movement below 15% - Reduces speed to maximize operational duration as battery drains - Configurable thresholds and speed factors - Graceful voltage-based fallback when percentage unavailable ## Testing 30+ comprehensive unit tests covering: - All threshold transitions (high to low and low to high) - Boundary conditions at each threshold - Parameter customization (thresholds and speed factors) - Limiting enable/disable functionality - Edge cases (0%, 100%, rapid transitions) - Realistic scenarios (full charge cycle, continuous updates) ## Configuration Parameters configurable via YAML: - Threshold percentages (full, reduced, critical, stop levels) - Speed factors (1.0, 0.7, 0.4, 0.0) - Publishing frequency (default 10 Hz) - Enable/disable limiting 🤖 Generated with Claude Code
seb added 1 commit 2026-03-03 00:46:24 -05:00
Implements saltybot_battery_speed_limiter package:
- Subscribes to /saltybot/battery_state, publishes speed limit factor
- Battery percentage thresholds: 100-50%=1.0, 50-25%=0.7, 25-15%=0.4, <15%=0.0
- Reduces speed to preserve battery when running low
- Automatically stops movement below 15% to prevent deep discharge
- Configurable thresholds and speed factors
- Comprehensive test suite: 30+ tests covering all threshold transitions
- Handles both direct percentage and voltage-based fallback calculation

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
sl-jetson merged commit 00c94cfe0d into main 2026-03-03 06:45:19 -05:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: seb/saltylab-firmware#327
No description provided.