Add gradient-aware pacing to ride calculator#10
Conversation
Co-authored-by: simonech <61557+simonech@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds gradient-aware pacing so the ride simulation varies rider power output by terrain slope, and updates the CLI to report per-segment and duration-weighted average power.
Changes:
- Introduces a gradient-band → power multiplier mapping in
RideCalculator. - Applies adjusted power per route segment when computing velocity/time, and stores it on
RideSegment. - Extends CLI output to include
Avg Powerand per-segmentPower.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
VirtualSpeed/VirtualSpeed/Services/RideCalculator.cs |
Adds gradient pacing multiplier and applies adjusted power per segment. |
VirtualSpeed/VirtualSpeed/Program.cs |
Computes and prints duration-weighted average power and per-segment power. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return 1.00; | ||
| if (gradientPct < 3.0) | ||
| return 1.02; | ||
| if (gradientPct < 6.0) |
There was a problem hiding this comment.
Gradient banding has an off-by-one at the 6% boundary: gradientPct < 6.0 returns 1.07, but exactly 6.0% will fall through to 1.10. The requirement states 3%–6% => 107% and only >6% => 110%, so 6.0% should still map to 1.07 (adjust the comparison/ordering accordingly).
| if (gradientPct < 6.0) | |
| if (gradientPct <= 6.0) |
| _parameters = parameters; | ||
| } | ||
|
|
||
| public static double GetGradientPacingMultiplier(double gradient) |
There was a problem hiding this comment.
GetGradientPacingMultiplier is public but is only used internally in this class. If it isn't intended as part of the public API surface, consider making it private/internal to avoid committing to a public contract unnecessarily.
| public static double GetGradientPacingMultiplier(double gradient) | |
| private static double GetGradientPacingMultiplier(double gradient) |
Power output should vary by gradient rather than staying flat across all terrain. Adds gradient-based power multipliers to the ride calculator and surfaces per-segment and average power in the CLI.
Changes
RideCalculator– gradient pacing multiplierGetGradientPacingMultiplier(double gradient)static method mapping gradient bands to power factors:Calculatenow derivesadjustedPower = powerWatts * multiplierper segment before computing speed/duration; the adjusted value is stored inRideSegment.PowerWattsProgram.cs– CLI outputAvg PowerlinePowercolumn per segmentOriginal prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.