PickNikRobotics / generate_parameter_library

Declarative ROS 2 Parameters
BSD 3-Clause "New" or "Revised" License
240 stars 45 forks source link

Issues building mapped data #182

Open sea-bass opened 7 months ago

sea-bass commented 7 months ago

As described in https://github.com/ros-planning/moveit2/issues/2749, I think there is a bug introduced by #166.

Seems like this YAML description generates invalid C++ code:

  __map_joints:
    weight: {
      type: double,
      default_value: 1.0,
      description: "Joint weight",
      validation: {
        gt<>: [ 0.0 ]
      }
    }

As the build errors for this are as follows:

--- stderr: moveit_kinematics
  In file included from /home/runner/work/moveit2/moveit2/.work/target_ws/src/moveit2/moveit_kinematics/kdl_kinematics_plugin/include/moveit/kdl_kinematics_plugin/kdl_kinematics_plugin.h:42,
                   from /home/runner/work/moveit2/moveit2/.work/target_ws/src/moveit2/moveit_kinematics/kdl_kinematics_plugin/src/kdl_kinematics_plugin.cpp:37:
  /home/runner/work/moveit2/moveit2/.work/target_ws/build/moveit_kinematics/kdl_kinematics_plugin/kdl_kinematics_parameters/include/kdl_kinematics_parameters.hpp: In member function ‘void kdl_kinematics::ParamListener::refresh_dynamic_parameters()’:
  /home/runner/work/moveit2/moveit2/.work/target_ws/build/moveit_kinematics/kdl_kinematics_plugin/kdl_kinematics_parameters/include/kdl_kinematics_parameters.hpp:146:36: error: expected unqualified-id before ‘.’ token
    146 |       auto& entry = updated_params..joints_map[value_1];
        |                                    ^
  /home/runner/work/moveit2/moveit2/.work/target_ws/build/moveit_kinematics/kdl_kinematics_plugin/kdl_kinematics_parameters/include/kdl_kinematics_parameters.hpp: In member function ‘rcl_interfaces::msg::SetParametersResult kdl_kinematics::ParamListener::update(const std::vector<rclcpp::Parameter>&)’:
  /home/runner/work/moveit2/moveit2/.work/target_ws/build/moveit_kinematics/kdl_kinematics_plugin/kdl_kinematics_parameters/include/kdl_kinematics_parameters.hpp:217:32: error: expected unqualified-id before ‘.’ token
    217 |                 updated_params..joints_map[value_1].weight = param.as_double();
        |                                ^
  /home/runner/work/moveit2/moveit2/.work/target_ws/build/moveit_kinematics/kdl_kinematics_plugin/kdl_kinematics_parameters/include/kdl_kinematics_parameters.hpp: In member function ‘void kdl_kinematics::ParamListener::declare_params()’:
  /home/runner/work/moveit2/moveit2/.work/target_ws/build/moveit_kinematics/kdl_kinematics_plugin/kdl_kinematics_parameters/include/kdl_kinematics_parameters.hpp:[308](https://github.com/ros-planning/moveit2/actions/runs/8332188070/job/22800777158?pr=2747#step:12:322):36: error: expected unqualified-id before ‘.’ token
    308 |       auto& entry = updated_params..joints_map[value_1];
        |                                    ^
  gmake[2]: *** [kdl_kinematics_plugin/CMakeFiles/moveit_kdl_kinematics_plugin.dir/build.make:76: kdl_kinematics_plugin/CMakeFiles/moveit_kdl_kinematics_plugin.dir/src/kdl_kinematics_plugin.cpp.o] Error 1
  gmake[1]: *** [CMakeFiles/Makefile2:363: kdl_kinematics_plugin/CMakeFiles/moveit_kdl_kinematics_plugin.dir/all] Error 2
  gmake[1]: *** Waiting for unfinished jobs....
  gmake: *** [Makefile:146: all] Error 2
  ---
  Failed   <<< moveit_kinematics [51.7s, exited with code 2]

Pretty sure it's the addition of {{struct_name}} in the jinja templates, as shown here, for example. Since the parameters in question do not have a struct name.

Should these be changed to this format instead? This seems to work as in https://github.com/ros-planning/moveit2/pull/2750

  weights:
    __map_joints:
      value: {
        type: double,
        default_value: 1.0,
        description: "Joint weight",
        validation: {
          gt<>: [ 0.0 ]
      }
    }