Skip to content

Nav2 build fails due to deprecated declare_parameter #2220

@AlexeyMerzlyakov

Description

@AlexeyMerzlyakov

Bug report

Navigation2 stack build fails on latest ros2 rolling release with following message:

--- stderr: nav2_lifecycle_manager                                                                              
/home/leha/navigation2_ws/src/navigation2/nav2_lifecycle_manager/src/lifecycle_manager.cpp: In constructor ‘nav2_lifecycle_manager::LifecycleManager::LifecycleManager()’:
/home/leha/navigation2_ws/src/navigation2/nav2_lifecycle_manager/src/lifecycle_manager.cpp:41:33: error: ‘const rclcpp::ParameterValue& rclcpp::Node::declare_parameter(const string&)’ is deprecated: declare_parameter() with only a name is deprecated and will be deleted in the future.\nIf you want to declare a parameter that won't change type without a default value use:\n`node->declare_parameter<ParameterT>(name)`, where e.g. ParameterT=int64_t.\n\nIf you want to declare a parameter that can dynamically change type use:\n```\nrcl_interfaces::msg::ParameterDescriptor descriptor;\ndescriptor.dynamic_typing = true;\nnode->declare_parameter(name, rclcpp::ParameterValue{}, descriptor);\n``` [-Werror=deprecated-declarations]
   41 |   declare_parameter("node_names");
      |                                 ^
In file included from /home/leha/ros2_foxy/install/rclcpp/include/rclcpp/executors/single_threaded_executor.hpp:28,
                 from /home/leha/ros2_foxy/install/rclcpp/include/rclcpp/executors.hpp:22,
                 from /home/leha/ros2_foxy/install/rclcpp/include/rclcpp/rclcpp.hpp:146,
                 from /home/leha/navigation2_ws/install/nav2_util/include/nav2_util/node_utils.hpp:19,
                 from /home/leha/navigation2_ws/install/nav2_util/include/nav2_util/service_client.hpp:20,
                 from /home/leha/navigation2_ws/install/nav2_util/include/nav2_util/lifecycle_service_client.hpp:24,
                 from /home/leha/navigation2_ws/src/navigation2/nav2_lifecycle_manager/include/nav2_lifecycle_manager/lifecycle_manager.hpp:24,
                 from /home/leha/navigation2_ws/src/navigation2/nav2_lifecycle_manager/src/lifecycle_manager.cpp:15:
/home/leha/ros2_foxy/install/rclcpp/include/rclcpp/node.hpp:359:3: note: declared here
  359 |   declare_parameter(const std::string & name);
      |   ^~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [CMakeFiles/nav2_lifecycle_manager_core.dir/build.make:63: CMakeFiles/nav2_lifecycle_manager_core.dir/src/lifecycle_manager.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:150: CMakeFiles/nav2_lifecycle_manager_core.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:141: all] Error 2
---
Failed   <<< nav2_lifecycle_manager	[ Exited with code 2 ]

Required Info:

Steps to reproduce issue

  1. Build latest ROS2 rolling release:
$ mkdir -p ~/ros2_foxy/src
$ cd ~/ros2_foxy
$ wget https://raw.githubusercontent.com/ros2/ros2/master/ros2.repos
$ vcs import src < ros2.repos
(rosdep update & install)
$ colcon build --symlink-install
  1. Build nav2 dependencies:
$ mkdir -p ~/nav2_depend_ws/src
$ cd ~/nav2_depend_ws
$ wget https://raw.githubusercontent.com/ros-planning/navigation2/main/tools/underlay.repos
$ vcs import src < underlay.repos
(rosdep install)
$ colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release
  1. Source ros2_foxy and nav2_depend_ws workspaces
  2. Build nav2 stack and got the failure from above.

Additional information

From the ros2 headers I've got the following:

$ vim ~/ros2_foxy/install/rclcpp/include/rclcpp/node.hpp
...
  /// Declare a parameter
  [[deprecated(
    "declare_parameter() with only a name is deprecated and will be deleted in the future.\n" \
    "If you want to declare a parameter that won't change type without a default value use:\n" \
    "`node->declare_parameter<ParameterT>(name)`, where e.g. ParameterT=int64_t.\n\n" \
    "If you want to declare a parameter that can dynamically change type use:\n" \
    "```\n" \
    "rcl_interfaces::msg::ParameterDescriptor descriptor;\n" \
    "descriptor.dynamic_typing = true;\n" \
    "node->declare_parameter(name, rclcpp::ParameterValue{}, descriptor);\n" \
    "```"
  )]]
  RCLCPP_PUBLIC
  const rclcpp::ParameterValue &
  declare_parameter(const std::string & name);

So, it looks indeed the declare_parameter("with_one_argument") API will be closed soon. So we will need to prepare for this.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions