dynamic_message_introspection icon indicating copy to clipboard operation
dynamic_message_introspection copied to clipboard

Needs an interface that accepts YAML::Node

Open b-adkins opened this issue 1 year ago • 0 comments

When I tried to use yaml_and_typeinfo_to_rosmsg for a robot application, I found myself having converting a YAML::Node to a string, just so yaml_and_typeinfo_to_rosmsg could re-parse it into a YAML::Node.

In my experience, robot configs that complete even simple tasks require complex YAML trees for their config file. You will be parsing many subtrees into ROS msgs, such as geometry_msgs/Pose and geometry_msgs/TransformStamped.

Specifically, my code would:

  1. Parse the tree using yamlcpp.
  2. Dive down the YAML tree to the selected key (e.g. yaml_tree["arm"]["waypoints"]["grasp_approach"])
  3. Convert that YAML::Node to a string
  4. Pass that string to yaml_and_typeinfo_to_rosmsg
  5. yaml_and_typeinfo_to_rosmsg re-parses the YAML.

Suggested Change

A new interface:

void yaml_node_and_typeinfo_to_rosmsg(
  const TypeInfo_Cpp * type_info,
  const YAML::Node& yaml_node,
  void * ros_message)

Leave the interface for yaml_and_typeinfo_to_rosmsg the same, but move most of the code inside to yaml_node_and_typeinfo_to_rosmsg.

Likewise for the other functions that take as input a yaml_str.

b-adkins avatar Aug 07 '24 22:08 b-adkins