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

yaml aliases/anchors not supported #106

Closed
Timple opened this issue Nov 19, 2019 · 8 comments
Closed

yaml aliases/anchors not supported #106

Timple opened this issue Nov 19, 2019 · 8 comments

Comments

@Timple
Copy link
Contributor

Timple commented Nov 19, 2019

We use yaml aliases to prevent configuration duplication.
When two nodes use a very similar set of parameters we can setup a parameter file like this:
(The two nodes being: kalman_filter_odom and kalman_filter_map

kalman_filter_odom: &KALMAN_FILTER_ODOM
  world_frame: "odom"

  imu0: imu/data
  imu0_config: [false, false, false,  # X,Y,Z,
                true,  true,  true,   # roll,pitch,yaw,
                false, false, false,  # X`,Y`,Z`,
                true,  true,  true,   # roll`,pitch`,yaw`,
                true,  true,  true]   # X``,Y``,Z``

  odom0: wheels/odom
  odom0_config: [false, false, false,  # X,Y,Z,
                  false, false, false,  # roll,pitch,yaw,
                  true,  true,  false,  # X`,Y`,Z`,
                  false, false, true,   # roll`,pitch`,yaw`,
                  false, false, false]  # X``,Y``,Z``

kalman_filter_map:
  <<: *KALMAN_FILTER_ODOM  # All settings and inputs kalman_filter_odom has and:
  world_frame: "map"

  odom1: absolute/odom
  odom1_config: [true,  true,  true,   # X,Y,Z,
                 false, false, false,  # roll,pitch,yaw,
                 false, false, false,  # X`,Y`,Z`,
                 false, false, false,  # roll`,pitch`,yaw`,
                 false, false, false]  # X``,Y``,Z``

This is supported by roslaunch in melodic. But rosmon crashes with the following error:

Running as '/rosmon_1574149719933920064'

terminate called after throwing an instance of 'ros::InvalidNameException'
  what():  Character [<] at element [19] is not valid in Graph Resource Name [/kalman_filter_map/<</frequency].  Valid characters are a-z, A-Z, 0-9, / and _.
Aborted (core dumped)
@xqms
Copy link
Owner

xqms commented Nov 19, 2019

Hi, thanks for the report! Could you share a full .launch file that shows how you include the YAML data?

I'm kind of surprised since rosmon uses yaml-cpp as the YAML parser, which should be pretty feature-complete. Well, you never know ;-)

@xqms
Copy link
Owner

xqms commented Nov 19, 2019

also I just noticed: Where is frequency coming from? I guess the YAML file you tried has more fields?

@Timple
Copy link
Contributor Author

Timple commented Nov 19, 2019

param.launch.txt
robot_localization.yaml.txt

Here ya go. Sorry for the .txt extension, seemed most convenient to attach to issue.

I tried to create a minimal example.
These example files work with roslaunch but not with mon launch

@xqms
Copy link
Owner

xqms commented Nov 19, 2019

Thanks! I had a look and I think the syntax you are using is not supported by yaml-cpp. See here for a PR against yaml-cpp: jbeder/yaml-cpp#300

Furthermore, the syntax is not even in the YAML spec: https://stackoverflow.com/a/47203224

Maybe it is possible to work around this in rosmon, but I doubt it, so we will have to wait for the yaml-cpp developers to implement this.

But there is an alternative: You can do the same at launch file level. Example:

<node ...>
  <rosparam command="load" file=".../generic.yaml">
  <rosparam command="load" file=".../special_A.yaml">
</node>

<node ...>
  <rosparam command="load" file=".../generic.yaml">
  <rosparam command="load" file=".../special_B.yaml">
</node>

rosmon guarantees that <rosparam> tags are executed in order. Because the <rosparam> tags are scoped inside the node tag, the contents will be loaded inside the node namespace.

@Timple
Copy link
Contributor Author

Timple commented Nov 19, 2019

That must be a discrepancy with the python yaml import then.
That's a bummer...

Thanks for the alternative though! I'll see if we want to convert the files (this will place some of the substitution in two places, param & launch) or switch back to roslaunch.

Implementing a workaround in rosmon sounds like the least neat solution. And since your referenced PR is open since 2015 I have little hopes there...

@xqms
Copy link
Owner

xqms commented Nov 19, 2019

Implementing a workaround in rosmon sounds like the least neat solution. And since your referenced PR is open since 2015 I have little hopes there...

That could actually be quite easy - just do a first pass over the YAML nodes to find all << nodes and work on these, then the rest (overwriting already set parameters). If you are interested in working on this, I'd be happy to consider a PR - otherwise I might have time to look at this next week.

@Timple
Copy link
Contributor Author

Timple commented Nov 21, 2019

Hmm, might still be an option then to include this. Would be consistent with roslaunch 👍
Working towards a deadline I won't get to this again before the holidays :(
If your up to speed with the code, feel free to check next week. Otherwise I might pick it up later!

@xqms
Copy link
Owner

xqms commented May 24, 2020

Fixed by @Cartoonman in #117.

@xqms xqms closed this as completed May 24, 2020
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

No branches or pull requests

2 participants