Skip to content

Refactor strava.py: Advanced Post-Ride Analytics and Model Calibration Loop #68

@hifly81

Description

@hifly81

Description

The current strava.py module serves as a basic bridge to fetch past activities. However, it only utilizes the summary_polyline (low resolution) and pulls environmental data for the starting coordinate only. This ignores the spatial and temporal evolution of a ride (e.g., a 4-hour ride where mud conditions or wind changed significantly between the start and the 60km mark).

The goal is to transform this into a Post-Mission Debriefing Tool that compares "Predicted vs. Actual" performance to refine our core algorithms.

Current Limitations

  1. Low-Resolution Geometry: summary_polyline is too coarse for detailed terrain analysis.
  2. Point-Source Intelligence: Weather and Mud reports are only generated for the start point $(lat, lon)$, which is insufficient for long-distance missions.
  3. No Temporal Correlation: The analysis doesn't sync the time of the Strava stream with the historical weather at that specific hour and location.
  4. Static Logic: It lacks a feedback mechanism to "learn" from the user's actual speed on specific surfaces.

Proposed Technical Roadmap

1. High-Fidelity Stream Integration

  • Action: Move from activity summaries to Strava Streams API (latlng, time, altitude, velocity_smooth).
  • Benefit: Allows for a meter-by-meter analysis of the route.

2. Spatio-Temporal Environmental Fusion

  • Action: Implement a "Timeline Sync" feature.
  • Logic: For every major segment of the ride, fetch the historical weather/mud state for that specific location and specific time.
  • Result: A "True Condition" map showing exactly where the rider encountered the worst mud or headwinds.

3. "The Performance Gap" Analysis

  • Action: Compare the actual speed on a segment against the Time-in-Motion prediction from scouting.py.
  • Correlations:
    • "You were 20% slower than predicted on Sector 4 (Mud Risk: High)." → Validates Mud Model.
    • "Battery drain was 15% higher than expected in crosswinds." → Refines Aero/Battery Model.

4. Automated Surface Tagging

  • Action: Cross-reference Strava segments with OpenStreetMap (via Overpass) to identify precisely when the rider moved from asphalt to gravel/dirt.
  • Benefit: Refines the soil_sensitivity coefficients based on actual speed degradation.

5. "Mechanical Efficiency" Scoring

  • Provide a score based on how well the bike_setup (tire pressure/type) performed for the encountered conditions.

Success Criteria

  • Post-ride report identifies specific sectors where environmental factors (wind/mud) impacted performance.
  • Integration of a "Calibration" payload that suggests updates to the RiderProfile (e.g., "Your actual climbing VAM is 150m/h higher than predicted").
  • Successful mapping of weather conditions at the finish of a long ride, not just the start.
  • High-res polyline processing without hitting Strava API rate limits (implementing caching).

Additional Context

This refactor moves BikeScout from a "Planning Tool" to a "Cycling Intelligence Platform." By analyzing why a mission deviated from the plan, the system becomes smarter with every uploaded ride, eventually providing personalized "GO/NO-GO" thresholds tailored to the individual rider's actual technical skills and speed.


Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions