Add a config_file argument to the gateway launchfile to allow using an external config file.#408
Conversation
…n external config file.
bburda
left a comment
There was a problem hiding this comment.
Nice, backward-compatible addition - defaulting config_file to the packaged config keeps existing launches unchanged.
One thing before merge: docs. config_file is a new public launch argument and isn't documented - the README has a launch-args table for gateway_https.launch.py, and gateway.launch.py should get an equivalent entry. Please also call out the replace semantics there (see inline).
Out of scope, your call: gateway_https.launch.py uses the same parameters=[default_config, {...}] pattern and could take the same config_file arg for parity.
| name='ros2_medkit_gateway', | ||
| output='screen', | ||
| parameters=[default_config, param_overrides], | ||
| parameters=[LaunchConfiguration('config_file'), param_overrides], |
There was a problem hiding this comment.
Worth documenting: when config_file is overridden the packaged gateway_params.yaml is no longer loaded at all - only the supplied file is. Any parameter absent from it falls back to the node's compiled-in declare_parameter defaults, not to the packaged YAML values. So the external file has to be a complete gateway config, not a fragment - a partial file would silently run with default discovery / auth / fault-manager / plugin settings.
gateway.launch.py doesn't have a launch-args table in the README yet (only gateway_https.launch.py does). Could you add one near the Configuration Examples section, e.g.:
### Launch Arguments (`gateway.launch.py`)
| Launch Argument | Default | Description |
| --------------------- | ------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| `config_file` | packaged `config/gateway_params.yaml` | Path to the YAML parameter file. **Replaces** the packaged config entirely - must be a complete gateway config, not a fragment. |
| `server_host` | `127.0.0.1` | Host to bind the REST server (`127.0.0.1` or `0.0.0.0`). |
| `server_port` | `8080` | Port for the REST API. |
| `refresh_interval_ms` | `30000` | Safety-backstop refresh interval in ms (graph events drive the primary refresh). |
Use a config file from another package:
```bash
ros2 launch ros2_medkit_gateway gateway.launch.py \
config_file:=$(ros2 pkg prefix my_bringup)/share/my_bringup/config/gateway_params.yaml
```| f'{graph_provider_path} - plugin will not load') | ||
| graph_provider_path = '' | ||
|
|
||
| declare_overide_config_arg = DeclareLaunchArgument( |
There was a problem hiding this comment.
nit: typo overide -> override in the variable name.
…
Pull Request
Summary
Added an optional config_file argument to the ros2_mekdit_gateway to be able to set the gateway parameters from outside the ros2_mekdit_gateway. This feature is proposed for large projects where the gateway config lives in another bringup package and needs to be feed to the gateway.
Issue
Link the related issue (required):
No issues, its new feature.
Type
Testing
How was this tested / how should reviewers verify it?:
I launched the gateway with and without the new config_file orverride:
and
In my
gateway_params.yamlfrom mybringup_package, I enable the CORS parameters. So when I launched the gateway without the config file, therosoutlog showed that CORS was disabled, and when I launched with the config_file, the log said CORS was enabled.Also, I did all the test in https://github.com/selfpatch/ros2_medkit/blob/main/CONTRIBUTING.md with success.
Since no code had to be build, there wasn't that much build test to do.
Checklist