I would like to be able to read ROS2 parameters of the form:
/**:
ros__parameters:
people:
- name: "Alice"
age: 30
grade: "A+"
- name: "Bob"
age: 25
grade: "B-"
From what I can tell, there doesn't seem to be a great way to do this in ROS2.
The workaround I've been using looks like this:
/**:
ros__parameters:
people_id:
- "Alice"
- "Bob"
people:
Alice:
name: "Alice"
age: 30
grade: "A+"
Bob:
name: "Bob"
age: 25
grade: "B-"
This method works alright. However, It's a pain to need to forward declare all the people
you want to configure. (In this example we could technically drop the name field since that's what we're using for the ID.)
In ROS1 I would just read the people
parameter as yaml and parse it directly, without the need to forward declare.
Another option I've tried (and least like) is just declaring vectors of everything
/**:
ros__parameters:
names: ["Alice", "Bob"]
ages: [30 , 25]
grades:["A+" , "B-" ]
for this simple example it's ok, however, I find it easy to get an "off by 1" error when your're configuring more complex objects. It also doesn't support default of name, age, grade if you don't want to specify in your config.