feat(apis): add line and odom APIs to get called by UI#41
Conversation
…Kart into smanor/better-apis
There was a problem hiding this comment.
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.ymlto avoid requiring host devices by default. - Add
line_pathto system params and use it frommaster_api(plus new/mapand/linesendpoints). - Publish a dynamic line from
PathfinderNode, ingest it inMasterNode, 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.
| @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(), | ||
| }) |
There was a problem hiding this comment.
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).
LelsersLasers
left a comment
There was a problem hiding this comment.
Looks pretty reasonable to me (may want to update the PR title tho)
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:
/mapand/linesendpoints to themaster_api.pyFlask app to expose static and dynamic racing line data, using a new_load_static_linefunction 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))racing_lineendpoint 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.pynow exposes the current dynamic line viaget_dynamic_line, and subscribes to the newpathfinder/dynamic_linetopic. ([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:
master_node.pyto 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))[[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:
pathfinder/dynamic_linetopic, 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:
line_pathparameter 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))[src/autonomous_kart/setup.pyR23](https://github.com/EVC-Purdue/AutonomousKart/pull/41/files#diff-a057cd6dae0c14b25a829ca0ec6003249bbc0f44acb2c5853fb549ef7698dd9eR23))docker-compose.ymlfor 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:
pathfinder.pyfor 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))[src/autonomous_kart/autonomous_kart/nodes/pathfinder/pathfinder_node.pyR144-R148](https://github.com/EVC-Purdue/AutonomousKart/pull/41/files#diff-2e4443c2a5a6c41c70b412efbe8db892cbf492bc27ab9f35830815800a7ee255R144-R148))