Skip to content

feat(apis): add line and odom APIs to get called by UI#41

Merged
ShayManor merged 9 commits intomainfrom
smanor/better-apis
Apr 27, 2026
Merged

feat(apis): add line and odom APIs to get called by UI#41
ShayManor merged 9 commits intomainfrom
smanor/better-apis

Conversation

@ShayManor
Copy link
Copy Markdown
Contributor

@ShayManor ShayManor commented Apr 26, 2026

This pull request introduces several enhancements and new features to the autonomous kart system, focusing on improved racing line management, dynamic line publishing, and richer odometry and metrics logging. Key changes include the addition of endpoints for accessing static and dynamic racing lines, expanded odometry data, and the integration of dynamic line publishing from the pathfinder node. There are also supporting changes to configuration and device handling.

API and Feature Additions:

  • Added /map and /lines endpoints to the master_api.py Flask app to expose static and dynamic racing line data, using a new _load_static_line function for efficient file access. ([[1]](https://github.com/EVC-Purdue/AutonomousKart/pull/41/files#diff-34a2533245ff40828e6ed8e17ebf077111d929a8dc1cc09df7fcc6f6df66f890L23-R52), [[2]](https://github.com/EVC-Purdue/AutonomousKart/pull/41/files#diff-34a2533245ff40828e6ed8e17ebf077111d929a8dc1cc09df7fcc6f6df66f890R123-R144))
  • The racing_line endpoint now uses a configurable path from the master node, allowing flexibility in line file location. ([src/autonomous_kart/autonomous_kart/nodes/master/master_api.pyL75-R104](https://github.com/EVC-Purdue/AutonomousKart/pull/41/files#diff-34a2533245ff40828e6ed8e17ebf077111d929a8dc1cc09df7fcc6f6df66f890L75-R104))
  • master_node.py now exposes the current dynamic line via get_dynamic_line, and subscribes to the new pathfinder/dynamic_line topic. ([src/autonomous_kart/autonomous_kart/nodes/master/master_node.pyR75-R94](https://github.com/EVC-Purdue/AutonomousKart/pull/41/files#diff-989fcf844bf787f311bfce0ff46b76e959d105f2d6caa5789026657acc170076R75-R94))

Odometry and Metrics Improvements:

  • Expanded the odometry data structure in master_node.py to include full position, orientation (quaternion), linear and angular velocities, and timestamp, with corresponding updates in the odometry callback. ([[1]](https://github.com/EVC-Purdue/AutonomousKart/pull/41/files#diff-989fcf844bf787f311bfce0ff46b76e959d105f2d6caa5789026657acc170076L52-R62), [[2]](https://github.com/EVC-Purdue/AutonomousKart/pull/41/files#diff-989fcf844bf787f311bfce0ff46b76e959d105f2d6caa5789026657acc170076R127-R143))
  • The metrics node now records odometry messages with full pose and twist data, improving logging and analysis capabilities. ([[1]](https://github.com/EVC-Purdue/AutonomousKart/pull/41/files#diff-04a607577393bd7fc6c3ef71e2facdddcdc132ed82595ad73d8ada69609aeda8R48), [[2]](https://github.com/EVC-Purdue/AutonomousKart/pull/41/files#diff-04a607577393bd7fc6c3ef71e2facdddcdc132ed82595ad73d8ada69609aeda8R99-R109))

Dynamic Line Publishing:

  • The pathfinder node now publishes dynamic racing line data (active status, strategy, merge index, and points) at 2 Hz on the pathfinder/dynamic_line topic, enabling real-time visualization and monitoring. ([[1]](https://github.com/EVC-Purdue/AutonomousKart/pull/41/files#diff-2e4443c2a5a6c41c70b412efbe8db892cbf492bc27ab9f35830815800a7ee255R73-R77), [[2]](https://github.com/EVC-Purdue/AutonomousKart/pull/41/files#diff-2e4443c2a5a6c41c70b412efbe8db892cbf492bc27ab9f35830815800a7ee255R514-R529))

Configuration and Setup:

  • Added a line_path parameter to the system configuration (system.yaml) and updated the master node to read the racing line path from this parameter. (Ff0f3754L26R27, Ff0f3754L49R51, Ff0f3754L49R51, [src/autonomous_kart/autonomous_kart/params/system.yamlR6](https://github.com/EVC-Purdue/AutonomousKart/pull/41/files#diff-9da709da86795c654d2d5c42d8059fd5b3bb375beb49530473b81f199ed4d543R6))
  • Updated the Python package setup to include the pathfinder strategies module. ([src/autonomous_kart/setup.pyR23](https://github.com/EVC-Purdue/AutonomousKart/pull/41/files#diff-a057cd6dae0c14b25a829ca0ec6003249bbc0f44acb2c5853fb549ef7698dd9eR23))
  • Commented out device mappings in docker-compose.yml for easier development without hardware. ([compose/docker-compose.ymlL16-R17](https://github.com/EVC-Purdue/AutonomousKart/pull/41/files#diff-6279b4379956d40a7c808ee22b5f1005cb7d1f6bfa77d45adc2e004f7ef3e6f9L16-R17))

Control and Logic Fixes:

  • Minor corrections to control logic in pathfinder.py for more precise throttle and steering outputs. ([[1]](https://github.com/EVC-Purdue/AutonomousKart/pull/41/files#diff-abd5995da60b22ec655932ac2cc61576a817336ca8b29c47de5d7b4d036b4e95L85-R85), [[2]](https://github.com/EVC-Purdue/AutonomousKart/pull/41/files#diff-abd5995da60b22ec655932ac2cc61576a817336ca8b29c47de5d7b4d036b4e95L141-R141))
  • Ensured the pathfinder node sets speed to zero on state changes for safer transitions. ([src/autonomous_kart/autonomous_kart/nodes/pathfinder/pathfinder_node.pyR144-R148](https://github.com/EVC-Purdue/AutonomousKart/pull/41/files#diff-2e4443c2a5a6c41c70b412efbe8db892cbf492bc27ab9f35830815800a7ee255R144-R148))

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR broadens configuration/telemetry support around the racing line (static + dynamic) and makes the dev compose setup less hardware-dependent, by introducing a line_path parameter, adding dynamic-line publishing/consumption, and exposing additional HTTP endpoints for visualization/inspection.

Changes:

  • Comment out device mappings in compose/docker-compose.yml to avoid requiring host devices by default.
  • Add line_path to system params and use it from master_api (plus new /map and /lines endpoints).
  • Publish a dynamic line from PathfinderNode, ingest it in MasterNode, and expand metrics/master odom snapshots.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/autonomous_kart/setup.py Packages the new pathfinder.strategies subpackage.
src/autonomous_kart/autonomous_kart/params/system.yaml Adds line_path parameter for shared configuration.
src/autonomous_kart/autonomous_kart/nodes/pathfinder/strategies/__init__.py Establishes strategies as a Python package.
src/autonomous_kart/autonomous_kart/nodes/pathfinder/pathfinder_node.py Publishes dynamic line JSON on a new ROS topic at 2 Hz.
src/autonomous_kart/autonomous_kart/nodes/metrics/metrics_node.py Adds odom subscription logging with pose/twist fields.
src/autonomous_kart/autonomous_kart/nodes/master/master_node.py Stores richer odom snapshot data and subscribes to dynamic line updates.
src/autonomous_kart/autonomous_kart/nodes/master/master_api.py Switches racing-line path source to MasterNode.path and adds /map + /lines endpoints.
compose/docker-compose.yml Comments out devices: mappings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/autonomous_kart/autonomous_kart/nodes/master/master_api.py
Comment on lines +123 to +143
@app.route("/map", methods=["GET"])
def map_endpoint():
waypoints = _load_static_line(master_node.path)
if not waypoints:
return jsonify({"error": "racing line not found", "waypoints": []}), 404
return jsonify({
"path": master_node.path,
"count": len(waypoints),
"waypoints": waypoints,
})


@app.route("/lines", methods=["GET"])
def lines_endpoint():
if not master_node:
return jsonify({"error": "not initialized"}), 500
static_xy = [[w["x"], w["y"]] for w in _load_static_line(master_node.path)]
return jsonify({
"static": static_xy,
"dynamic": master_node.get_dynamic_line(),
})
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New HTTP endpoints /map and /lines are added here, but the existing e2e suite already tests other master_api routes (see test_e2e_launch.py). Add coverage for these new routes (status codes + response schema) to prevent regressions (and to catch issues like dynamic line serialization).

Copilot uses AI. Check for mistakes.
Comment thread compose/docker-compose.yml
Comment thread src/autonomous_kart/autonomous_kart/nodes/master/master_node.py Outdated
Comment thread src/autonomous_kart/autonomous_kart/nodes/master/master_node.py Outdated
Comment thread src/autonomous_kart/autonomous_kart/nodes/master/master_api.py
Copy link
Copy Markdown
Member

@LelsersLasers LelsersLasers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty reasonable to me (may want to update the PR title tho)

@ShayManor ShayManor changed the title chore(docker-compose): comment out device mappings in configuration feat(apis): add line and odom APIs to get called by UI Apr 27, 2026
@ShayManor ShayManor merged commit e053dfe into main Apr 27, 2026
5 checks passed
@ShayManor ShayManor deleted the smanor/better-apis branch April 27, 2026 17:05
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.

3 participants