Add xacro expansion service#428
Conversation
There was a problem hiding this comment.
@JenniferBuehler, thanks for the PR! This is a great addition to the toolkit and will be incredibly helpful for participants spawning entities during training.
Since these changes currently affect several core packages used in evaluation, I’d like to propose a refactor to ensure we don't introduce any regressions to the eval environment. By isolating these features, we can keep the core stable while still providing these tools to the community.
Proposed Changes:
-
Create aic_training_utils package: Let’s house this in aic_utils with dedicated
launchandscriptsdirectories. -
New Launch Logic: Create a launch file in the new package that includes the existing
aic_bringup/aic_gz_bringup.launch.pyand also starts thexacro_expandernode. -
Dedicated Interfaces: Create an
aic_training_interfacespackage withinaic_utilsto host theExpandXacro.srv.
This approach keeps the evaluation environment clean while making your training improvements easily accessible to everyone.
Let me know what you think!
Thanks @Yadunund this is a really great suggestion! I have applied the requested changes. I took the liberty to also add a convenience entrypoint, so the training-version of the eval env (which brings up the xacro expander node) can be brought up easily. I also updated the test plan accordingly. |
|
@Yadunund can you please help me out with the guidelines you have for the pixi.lock file? I have added my re-generated version for now. |
|
This looks great!
Is it possible to make minimal changes to the pixi.lock file without updating other dependencies? e.g. I reverted pixi.lock and manually ran |
Just did that, thanks for the tip! I'm still learning pixi :) |
Add an ExpandXacro ROS 2 service to the eval stack so that model-side code can request xacro-to-XML expansion without needing direct filesystem access to the eval workspace's package share directories.
Add an
ExpandXacroROS 2 service to the eval stack so that model-side code can request xacro-to-XML expansion without needing direct filesystem access to the eval workspace's package share directories.Motivation:
Model policies that need to spawn or respawn entities at training time (e.g. task boards, cables) must produce SDF/URDF XML from the xacro source files in
aic_description. Those xacro files and thexacrotool live inside the eval container's colcon workspace, which is not accessible from the model side. This service adds convenience here -- the model sends a package name, relative path, and xacro arguments, and gets back the expanded XML string.Note
I am adding this PR as proposal because I think that other participants might benefit. If however it doesn't fit in the toolkit as per your design and requirements, we can just close it. Of course, this is only a feature which would make sense at training time (not at evaluation where env resets/spawning are managed by the evaluation).
Test plan
Build and start the eval environment
Start the eval environment - there is now an entrypoint that starts up the same as
/entrypoint.shbut instead uses the wrapper launch file which also brings up the xacro expander service node:distrobox enter aic_eval -- /entrypoint_training.sh \ spawn_task_board:=true \ nic_card_mount_2_present:=true \ spawn_cable:=true \ cable_type:=sfp_sc_cable \ ground_truth:=true \ start_aic_engine:=falseVerify the service is advertised
In a second terminal (host side, pixi workspace):
pixi run ros2 service list | grep expand_xacroExpected output:
Call the service with a valid xacro file
Expand the task board xacro with a minimal set of arguments:
pixi run ros2 service call /expand_xacro aic_training_interfaces/srv/ExpandXacro \ "{package_name: 'aic_description', relative_path: 'urdf/task_board.urdf.xacro', xacro_arguments: ['ground_truth:=true', 'nic_card_mount_0_present:=true', 'nic_card_mount_0_translation:=0.0']}"Expected:
success: true,xmlcontains a non-empty SDF/URDF string,messageis"xacro expansion succeeded".Call the service with an invalid package name
pixi run ros2 service call /expand_xacro aic_training_interfaces/srv/ExpandXacro \ "{package_name: 'nonexistent_package', relative_path: 'foo.xacro', xacro_arguments: []}"Expected:
success: false,messagementions the package was not found.Call the service with a path traversal attempt
pixi run ros2 service call /expand_xacro aic_training_interfaces/srv/ExpandXacro \ "{package_name: 'aic_description', relative_path: '../../etc/passwd', xacro_arguments: []}"Expected:
success: false,messageis"relative_path must stay within the package share directory".Verify no regressions in the standard bringup
Start the eval environment with the engine enabled and confirm the existing evaluation flow still works:
Verify that the engine runs its trials normally and the
xacro_expandernode does not interfere (checkros2 node listincludes/xacro_expander; no errors in the bringup output).