Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(pose_initializer): rework parameters #5773

Conversation

PhoebeWu21
Copy link
Member

Description

Implement the ROS Node configuration layout described in https://github.com/orgs/autowarefoundation/discussions/3371 for the pose_initializer package.

  • Create the schema

Tests performed

Package build and launch locally.
colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release --packages-up-to pose_initializer

Effects on system behavior

More reliable and faster parameter configuration file creation.

Pre-review checklist for the PR author

The PR author must check the checkboxes below when creating the PR.

In-review checklist for the PR reviewers

The PR reviewers must check the checkboxes below before approval.

  • The PR follows the pull request guidelines.
  • The PR has been properly tested.
  • The PR has been reviewed by the code owners.

Post-review checklist for the PR author

The PR author must check the checkboxes below before merging.

  • There are no open discussions or they are tracked via tickets.
  • The PR is ready for merge.

After all checkboxes are checked, anyone who has write access can merge the PR.

@github-actions github-actions bot added type:documentation Creating or refining documentation. (auto-assigned) component:localization Vehicle's position determination in its environment. (auto-assigned) labels Dec 5, 2023
@KYabuuchi
Copy link
Contributor

@PhoebeWu21 Thanks for making the PR!
Unfortunately, we want to avoid managing ndt_enabled and others in pose_initializer.param.yaml.
For example, this launch file rewrites ndt_enabled based on the runtime arguments.

Therefore, I would like you to revert the changes to pose_initializer.param.yaml and pose_initializer.launch.xml and make the PR just add a schema.json file. 🙏

(Also, I am not familiar with the syntax of json.scheme, but I think the default in json.scheme needs to be removed if my request is to be reflected.)

@KYabuuchi KYabuuchi self-requested a review December 5, 2023 07:21
@PhoebeWu21
Copy link
Member Author

PhoebeWu21 commented Dec 5, 2023

@KYabuuchi Got it. But if remove ndt_enabled and others from the pose_initializer.param.yaml file, they should also be removed from the schema file to pass the build-and-test check.

@KYabuuchi
Copy link
Contributor

@PhoebeWu21 Hmm, I'm not familier in JSON schema validation, but is the only way to pass the build-and-test to remove parameters not included in param.yaml from the json.schema?
In my understanding, the purpose of json.schema is to define the parameters that nodes require, so I thought that json.schema should include ndt_enabled and others as much as possible.

If we have no choice except to remove them, I would like you to proceed in that manner.

@PhoebeWu21
Copy link
Member Author

@PhoebeWu21 Thanks for making the PR! Unfortunately, we want to avoid managing ndt_enabled and others in pose_initializer.param.yaml. For example, this launch file rewrites ndt_enabled based on the runtime arguments.

Therefore, I would like you to revert the changes to pose_initializer.param.yaml and pose_initializer.launch.xml and make the PR just add a schema.json file. 🙏

(Also, I am not familiar with the syntax of json.scheme, but I think the default in json.scheme needs to be removed if my request is to be reflected.)

@KYabuuchi Got it. But if remove ndt_enabled and others from the pose_initializer.param.yaml file, they should also be removed from the schema file to pass the build-and-test check.

@PhoebeWu21 Hmm, I'm not familier in JSON schema validation, but is the only way to pass the build-and-test to remove parameters not included in param.yaml from the json.schema? In my understanding, the purpose of json.schema is to define the parameters that nodes require, so I thought that json.schema should include ndt_enabled and others as much as possible.

If we have no choice except to remove them, I would like you to proceed in that manner.

Hi @kaspermeck-arm @ambroise-arm, I am not sure if there is other methods to deal with this situation. Please give me some advice, thank you.

@ambroise-arm
Copy link
Contributor

ambroise-arm commented Dec 5, 2023

Unfortunately, we want to avoid managing ndt_enabled and others in pose_initializer.param.yaml.

@KYabuuchi The goal of the change is not to manage the parameters in pose_initializer.param.yaml. The goal is to move the default values of the parameters from the launch file of the package to the config file of the package.

Looking at another launch file from the same tier4_localization_launch package you linked to, I see https://github.com/autowarefoundation/autoware.universe/blob/main/launch/tier4_localization_launch/launch/pose_twist_fusion_filter/pose_twist_fusion_filter.launch.xml#L41 simply references the default values from the config file.

So @PhoebeWu21 it may just be about adding a <arg name="config_file" value="$(find-pkg-share pose_initializer)/config/pose_initializer.param.yaml"/> line to https://github.com/autowarefoundation/autoware.universe/blob/main/launch/tier4_localization_launch/launch/pose_twist_estimator/pose_twist_estimator.launch.xml#L14 (or something like that)

EDIT: and also double-checking whether other launch files are affected in the same way

@KYabuuchi
Copy link
Contributor

@ambroise-arm Thank you for clarifying the goal. 😄
I believe the issue is that the launch file dynamically change the ndt_enabled based on the runtime argument 'pose_source'.
For example, ros2 launch autoware_launch autoware_launch.xml pose_source:=ndt will result in ndt_enabled=true, ros2 launch ... pose_source:=eagleye will result in ndt_enabled=false.
Are you suggesting placing distinct config files for each condition in pose_initializer/config/*.param.yaml?

@ambroise-arm
Copy link
Contributor

ambroise-arm commented Dec 5, 2023

Are you suggesting placing distinct config files for each condition in pose_initializer/config/*.param.yaml?

Now that you mention it, it sounds like an excellent idea! It would provide a tidier code in pose_twist_estimator.launch.xml, and it would simplify the interface between the two launch files with only the path to the config file to be used. And it matches the design described in https://autowarefoundation.github.io/autoware-documentation/main/contributing/coding-guidelines/ros-nodes/parameters/#parameter-file under "Launch parameter file". Yes, that's probably the best way to go.

However, I was suggesting a more modest change: keeping the <arg name="..."/> interface as it currently exists for all the parameters, but still adding the missing parameters to the config file as part of this PR. It shouldn't affect any packages that include the launch file from this package but satisfy the new schema linting. What I suggested above with config_file didn't make much sense on its own.

The first option sounds like a bigger change than the second. I don't know if we want the scope of this PR to be this big.

@KYabuuchi
Copy link
Contributor

I see. The approach I suggested, involving multiple file placements, is a big changes.
I think it would be better to keep it a modest change that leaves <arg name="..." /> as ambroise-arm says.
As for me, I believe the current commit, in which all parameters independent on runtime arguments are included in param.yaml and passes the json-schema-check, is approvable.

@PhoebeWu21 Are you ok with the current style?
If OK, the code owner will review and approve.

@PhoebeWu21
Copy link
Member Author

PhoebeWu21 commented Dec 6, 2023

@KYabuuchi Ok. Thank you.
I made a new commit please check if my understanding is correct.

@KYabuuchi
Copy link
Contributor

KYabuuchi commented Dec 6, 2023

@PhoebeWu21 Oh? I apologize. I was approvable in the last state.
So if you agree with me, you did not have to commit 095de6b.

As for me, I believe the current commit, in which all parameters independent of runtime arguments are included in param.yaml and passes the json-schema-check, is approvable.

What I mean here is to include only parameters independent of runtime arguments in param.yaml, excluding dependent parameters (such as ndt_enabled) from both param.yaml and json.schema.

@PhoebeWu21 PhoebeWu21 force-pushed the refactor-node-config-pose_initializer branch from 095de6b to a626d53 Compare December 6, 2023 06:23
@PhoebeWu21
Copy link
Member Author

@KYabuuchi Ahh got it. Sorry for the misunderstanding.

@KYabuuchi
Copy link
Contributor

@YamatoAndo Now it is ready to review. Please review and approve 🙏

@ambroise-arm
Copy link
Contributor

ambroise-arm commented Dec 6, 2023

So if you agree with me, you did not have to commit 095de6b.

I disagree. The point of https://github.com/orgs/autowarefoundation/discussions/3371 (that this PR implements) is to have a 1 to 1 match between the parameters used in the C++ node and the schema/parameter files. I don't see the issue with having this commit in the PR. And having the PR without it doesn't fulfill the goal of the configuration dojo. (at least not my understanding of it)

cc @kaspermeck-arm

@KYabuuchi
Copy link
Contributor

@ambroise-arm Sorry for the misunderstanding. I would like to confirm again, do you intend to put both <param from="$(var config_file)"> and <param name="ndt_enabled"> in the launch file?
And since <param name="ndt_enabled"> takes priority (I'm not sure), we can pass the parameters corresponding to the runtime arguments as before?

@isamu-takagi
Copy link
Contributor

isamu-takagi commented Dec 7, 2023

@PhoebeWu21 @KYabuuchi @ambroise-arm

Autoware allows parameters to be split into multiple parameter files and launch files. Therefore, there is no guarantee that the parameter file and schema file will match exactly. (To be more precise, schema matches the temporary merged parameter file that the ROS launch system gives to the node.)

It has been pointed out that due to file splitting, schema and parameter file validation cannot be done one-on-one.

Therefore, possible solutions are as follows (some are temporary solutions)

  • Define only the schema file and do not validate the parameter file
  • Split the schema file into expected division units of parameter file
  • Create a dummy parameter file that is not actually used but for validation (because it is unclear which parameter in the launch file or the parameter file will be used)
  • Create a mechanism to validate the temporary merged parameter file given to the node by the ROS launch system

Edit:

  • Remove "required" field from schema file

@ambroise-arm
Copy link
Contributor

ambroise-arm commented Dec 7, 2023

do you intend to put both <param from="$(var config_file)"> and <param name="ndt_enabled"> in the launch file?

@KYabuuchi Yes, in the pose_initializer.launch.xml launch file. But it is already like this, so it is more about keeping it this way.

And since <param name="ndt_enabled"> takes priority (I'm not sure), we can pass the parameters corresponding to the runtime arguments as before?

@KYabuuchi Exactly. I also assume it takes priority.

Create a dummy parameter file that is not actually used but for validation (because it is unclear which parameter in the launch file or the parameter file will be used)

@isamu-takagi I think it will result in something a bit like this, but I don't think the issue your are linking to is a problem here. What will happen is that we will have a schema file in this package that has all its fields as "required", and a config file that list all the fields. So it should be validated correctly. The launch file of this package then uses this config file as a default, while also requiring some of its arguments to be passed directly. So in practice the ndt_enabled, gnss_enabled, ekf_enabled, yabloc_enabled and stop_check_enabled arguments will always be overridden. At least until changes as described in #5773 (comment) are done.

@KYabuuchi
Copy link
Contributor

For this package, I think the approach mentioned by ambroise-arm is fine.
However, as isamu-takagi says, some packages have split multiple parameter files, so it will be an issue that will have to be tackled eventually.

@isamu-takagi
Copy link
Contributor

So in practice the ndt_enabled, gnss_enabled, ekf_enabled, yabloc_enabled and stop_check_enabled arguments will always be overridden.

@KYabuuchi @ambroise-arm
Is this behavior guaranteed by the launch_ros specification?

@KYabuuchi
Copy link
Contributor

i am not sure😞

@isamu-takagi
Copy link
Contributor

@KYabuuchi
I found a description that the last parameter has priority. So be careful about the order of parameters in the launch file. Also, note that namespace also affects priority.
https://github.com/ros2/launch_ros/blob/humble/launch_ros/launch_ros/actions/node.py#L175-L182

@KYabuuchi
Copy link
Contributor

@isamu-takagi Thank you for finding the description. Very useful information!

@KYabuuchi
Copy link
Contributor

I realized that the override rules are complex, and the current approach might actually introduce more bugs.
(I have created tests to verify the parameter override rules, so please take a look. https://github.com/KYabuuchi/ros2_launch_learn/tree/feat/minimum_case?tab=readme-ov-file#the-result)

I also posted this issue in the github-actions thread. I don't think we should merge PRs with parameter overrides at this time.

@KYabuuchi
Copy link
Contributor

@PhoebeWu21 Sorry to keep you waiting for so long.
As a method to pass parameters from the launch file, the chosen approach is to use substitution within YAML.
reference , example

If it's not too inconvenient, would you mind revising this PR to incorporate that method? If it is troublesome, I am willing to work on it and create a new PR.
Thank you

@PhoebeWu21
Copy link
Member Author

@KYabuuchi Sure, I can deal with the modifying. But I am a bit confused about the revising of the pose_initializer.launch.xml file. Should I revise it to the format like pose_twist_estimator.launch.xml?

@KYabuuchi
Copy link
Contributor

@PhoebeWu21 Thanks for your cooperation. What I want you to do is the following:

  • Remove all <param name=... /> from pose_initializer.launch.xml.
  • Replace <param from="$(var config_file)" allow_substs="true"/> in pose_initializer.launch.xml. ref
  • Add ndt_enabled: $(var ndt_enabled) etc. in pose_initializer.param.yaml. ref
  • Add ndt_enabled etc. to pose_initializer.schema.json.
  • Create a PR to change param.yaml in autoware_launch, too. ref

You do not need to refer to pose_twist_estimator.launch.xml to make this change.

Copy link
Contributor

@KYabuuchi KYabuuchi left a comment

Choose a reason for hiding this comment

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

Thank you for your help!

Since autoware_launch has the same parameter.yaml, please create a PR to modify that as well. Sorry for bothering you.

@KYabuuchi KYabuuchi added the run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) label Feb 6, 2024
Copy link

codecov bot commented Feb 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (765a596) 15.32% compared to head (0359901) 7.56%.
Report is 580 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #5773       +/-   ##
==========================================
- Coverage   15.32%   7.56%    -7.76%     
==========================================
  Files        1721      10     -1711     
  Lines      118559     185   -118374     
  Branches    37995       7    -37988     
==========================================
- Hits        18169      14    -18155     
+ Misses      79657     165    -79492     
+ Partials    20733       6    -20727     
Flag Coverage Δ
differential 7.56% <ø> (?)
total ?

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@KYabuuchi KYabuuchi left a comment

Choose a reason for hiding this comment

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

Thank you for your patient support!

I have confirmed that pose_initializer runs correctly in logging_simulator.launch.xml & planning_simulator.launch.xml.

@KYabuuchi KYabuuchi merged commit 02bc6d8 into autowarefoundation:main Feb 7, 2024
32 of 35 checks passed
@PhoebeWu21 PhoebeWu21 deleted the refactor-node-config-pose_initializer branch February 7, 2024 00:40
anhnv3991 pushed a commit to anhnv3991/autoware.universe that referenced this pull request Feb 13, 2024
* refactor(pose_initializer): rework parameters

Signed-off-by: PhoebeWu21 <[email protected]>

* refactor(pose_initializer): rework parameters

Signed-off-by: PhoebeWu21 <[email protected]>

* refactor(pose_initializer): rework parameters

Signed-off-by: PhoebeWu21 <[email protected]>

* style(pre-commit): autofix

* refactor(pose_initializer): rework parameters

Signed-off-by: PhoebeWu21 <[email protected]>

* refactor(pose_initializer): rework parameters

Signed-off-by: PhoebeWu21 <[email protected]>

---------

Signed-off-by: PhoebeWu21 <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
StepTurtle pushed a commit to StepTurtle/autoware.universe that referenced this pull request Feb 28, 2024
* refactor(pose_initializer): rework parameters

Signed-off-by: PhoebeWu21 <[email protected]>

* refactor(pose_initializer): rework parameters

Signed-off-by: PhoebeWu21 <[email protected]>

* refactor(pose_initializer): rework parameters

Signed-off-by: PhoebeWu21 <[email protected]>

* style(pre-commit): autofix

* refactor(pose_initializer): rework parameters

Signed-off-by: PhoebeWu21 <[email protected]>

* refactor(pose_initializer): rework parameters

Signed-off-by: PhoebeWu21 <[email protected]>

---------

Signed-off-by: PhoebeWu21 <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
karishma1911 pushed a commit to Interplai/autoware.universe that referenced this pull request Jun 3, 2024
* refactor(pose_initializer): rework parameters

Signed-off-by: PhoebeWu21 <[email protected]>

* refactor(pose_initializer): rework parameters

Signed-off-by: PhoebeWu21 <[email protected]>

* refactor(pose_initializer): rework parameters

Signed-off-by: PhoebeWu21 <[email protected]>

* style(pre-commit): autofix

* refactor(pose_initializer): rework parameters

Signed-off-by: PhoebeWu21 <[email protected]>

* refactor(pose_initializer): rework parameters

Signed-off-by: PhoebeWu21 <[email protected]>

---------

Signed-off-by: PhoebeWu21 <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:localization Vehicle's position determination in its environment. (auto-assigned) run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) type:documentation Creating or refining documentation. (auto-assigned)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants