Skip to content

Declaration of parameter of type std::vector<int> won't build #1585

@AugusteBourgois

Description

@AugusteBourgois

Bug report

Required Info:

  • Operating System: Ubuntu 20.04
  • Installation type: binaries
  • Version or commit hash: Foxy
  • DDS implementation: Fast-RTPS
  • Client library (if applicable): rclcpp

Steps to reproduce issue

  1. Create a ros2 package
ros2 pkg create --build-type ament_cmake vector_int_pkg
  1. Create a simple node the declares a parameter of type std::vector<int> in file src/test_vector_int.cpp
#include "rclcpp/rclcpp.hpp"

int main(int argc, char ** argv)
{
  rclcpp::init(argc, argv);

  std::shared_ptr<rclcpp::Node> node = rclcpp::Node::make_shared("vector_integer_parameters");

  node->declare_parameter("param", std::vector<int>{});

  rclcpp::spin(node);
  rclcpp::shutdown();
}
  1. Adjust the CMakeLists.txt file
cmake_minimum_required(VERSION 3.5)
project(vector_int_pkg)

if (NOT CMAKE_C_STANDARD)
    set(CMAKE_C_STANDARD 99)
endif ()

if (NOT CMAKE_CXX_STANDARD)
    set(CMAKE_CXX_STANDARD 14)
endif ()

if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
    add_compile_options(-Wall -Wextra -Wpedantic)
endif ()

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)


add_executable(test_vector_int src/test_vector_int.cpp)
ament_target_dependencies(test_vector_int rclcpp)

ament_package()
  1. Adjust the package.xml file
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
    <name>vector_int_pkg</name>
    <version>0.0.0</version>
    <description>TODO: Package description</description>
    <maintainer email="john@doe.com">John Doe</maintainer>
    <license>TODO: License declaration</license>

    <buildtool_depend>ament_cmake</buildtool_depend>

    <depend>rclcpp</depend>

    <test_depend>ament_lint_auto</test_depend>
    <test_depend>ament_lint_common</test_depend>

    <export>
        <build_type>ament_cmake</build_type>
    </export>
</package>
  1. Build the package
colcon build --packages-select vector_int_pkg 

Expected behavior

The package builds successfully.

Actual behavior

The build fails with the following errors :

Starting >>> vector_int_pkg
--- stderr: vector_int_pkg                             
In file included from /opt/ros/foxy/include/rclcpp/node.hpp:1221,
                 from /opt/ros/foxy/include/rclcpp/executors/single_threaded_executor.hpp:28,
                 from /opt/ros/foxy/include/rclcpp/executors.hpp:22,
                 from /opt/ros/foxy/include/rclcpp/rclcpp.hpp:146,
                 from /home/john/Dev/qpta_ws/src/vector_int_pkg/src/test_vector_int.cpp:1:
/opt/ros/foxy/include/rclcpp/node_impl.hpp: In instantiation of ‘auto rclcpp::Node::declare_parameter(const string&, const ParameterT&, const ParameterDescriptor&, bool) [with ParameterT = std::vector<int>; std::string = std::__cxx11::basic_string<char>; rcl_interfaces::msg::ParameterDescriptor = rcl_interfaces::msg::ParameterDescriptor_<std::allocator<void> >]’:
/home/john/Dev/qpta_ws/src/vector_int_pkg/src/test_vector_int.cpp:9:54:   required from here
/opt/ros/foxy/include/rclcpp/node_impl.hpp:169:23: error: no matching function for call to ‘rclcpp::ParameterValue::get<std::vector<int, std::allocator<int> > >() const’
  169 |     ).get<ParameterT>();
      |                       ^
In file included from /opt/ros/foxy/include/rclcpp/parameter.hpp:26,
                 from /opt/ros/foxy/include/rclcpp/node_interfaces/node_parameters_interface.hpp:28,
                 from /opt/ros/foxy/include/rclcpp/node.hpp:51,
                 from /opt/ros/foxy/include/rclcpp/executors/single_threaded_executor.hpp:28,
                 from /opt/ros/foxy/include/rclcpp/executors.hpp:22,
                 from /opt/ros/foxy/include/rclcpp/rclcpp.hpp:146,
                 from /home/john/Dev/qpta_ws/src/vector_int_pkg/src/test_vector_int.cpp:1:
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:148:3: note: candidate: ‘template<rclcpp::ParameterType type> constexpr typename std::enable_if<(type == rclcpp::PARAMETER_BOOL), const bool&>::type rclcpp::ParameterValue::get() const’
  148 |   get() const
      |   ^~~
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:148:3: note:   template argument deduction/substitution failed:
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:159:3: note: candidate: ‘template<rclcpp::ParameterType type> constexpr typename std::enable_if<(type == rclcpp::PARAMETER_INTEGER), const long int&>::type rclcpp::ParameterValue::get() const’
  159 |   get() const
      |   ^~~
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:159:3: note:   template argument deduction/substitution failed:
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:170:3: note: candidate: ‘template<rclcpp::ParameterType type> constexpr typename std::enable_if<(type == rclcpp::PARAMETER_DOUBLE), const double&>::type rclcpp::ParameterValue::get() const’
  170 |   get() const
      |   ^~~
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:170:3: note:   template argument deduction/substitution failed:
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:181:3: note: candidate: ‘template<rclcpp::ParameterType type> constexpr typename std::enable_if<(type == rclcpp::PARAMETER_STRING), const std::__cxx11::basic_string<char>&>::type rclcpp::ParameterValue::get() const’
  181 |   get() const
      |   ^~~
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:181:3: note:   template argument deduction/substitution failed:
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:193:3: note: candidate: ‘template<rclcpp::ParameterType type> constexpr typename std::enable_if<(type == rclcpp::PARAMETER_BYTE_ARRAY), const std::vector<unsigned char, std::allocator<unsigned char> >&>::type rclcpp::ParameterValue::get() const’
  193 |   get() const
      |   ^~~
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:193:3: note:   template argument deduction/substitution failed:
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:205:3: note: candidate: ‘template<rclcpp::ParameterType type> constexpr typename std::enable_if<(type == rclcpp::PARAMETER_BOOL_ARRAY), const std::vector<bool, std::allocator<bool> >&>::type rclcpp::ParameterValue::get() const’
  205 |   get() const
      |   ^~~
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:205:3: note:   template argument deduction/substitution failed:
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:217:3: note: candidate: ‘template<rclcpp::ParameterType type> constexpr typename std::enable_if<(type == rclcpp::PARAMETER_INTEGER_ARRAY), const std::vector<long int, std::allocator<long int> >&>::type rclcpp::ParameterValue::get() const’
  217 |   get() const
      |   ^~~
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:217:3: note:   template argument deduction/substitution failed:
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:229:3: note: candidate: ‘template<rclcpp::ParameterType type> constexpr typename std::enable_if<(type == rclcpp::PARAMETER_DOUBLE_ARRAY), const std::vector<double, std::allocator<double> >&>::type rclcpp::ParameterValue::get() const’
  229 |   get() const
      |   ^~~
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:229:3: note:   template argument deduction/substitution failed:
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:241:3: note: candidate: ‘template<rclcpp::ParameterType type> constexpr typename std::enable_if<(type == rclcpp::PARAMETER_STRING_ARRAY), const std::vector<std::__cxx11::basic_string<char> >&>::type rclcpp::ParameterValue::get() const’
  241 |   get() const
      |   ^~~
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:241:3: note:   template argument deduction/substitution failed:
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:254:3: note: candidate: ‘template<class type> constexpr typename std::enable_if<std::is_same<T, bool>::value, const bool&>::type rclcpp::ParameterValue::get() const’
  254 |   get() const
      |   ^~~
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:254:3: note:   template argument deduction/substitution failed:
/opt/ros/foxy/include/rclcpp/parameter_value.hpp: In substitution of ‘template<class type> constexpr typename std::enable_if<std::is_same<T, bool>::value, const bool&>::type rclcpp::ParameterValue::get() const [with type = std::vector<int>]’:
/opt/ros/foxy/include/rclcpp/node_impl.hpp:169:23:   required from ‘auto rclcpp::Node::declare_parameter(const string&, const ParameterT&, const ParameterDescriptor&, bool) [with ParameterT = std::vector<int>; std::string = std::__cxx11::basic_string<char>; rcl_interfaces::msg::ParameterDescriptor = rcl_interfaces::msg::ParameterDescriptor_<std::allocator<void> >]’
/home/john/Dev/qpta_ws/src/vector_int_pkg/src/test_vector_int.cpp:9:54:   required from here
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:254:3: error: no type named ‘type’ in ‘struct std::enable_if<false, const bool&>’
/opt/ros/foxy/include/rclcpp/node_impl.hpp: In instantiation of ‘auto rclcpp::Node::declare_parameter(const string&, const ParameterT&, const ParameterDescriptor&, bool) [with ParameterT = std::vector<int>; std::string = std::__cxx11::basic_string<char>; rcl_interfaces::msg::ParameterDescriptor = rcl_interfaces::msg::ParameterDescriptor_<std::allocator<void> >]’:
/home/john/Dev/qpta_ws/src/vector_int_pkg/src/test_vector_int.cpp:9:54:   required from here
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:263:3: note: candidate: ‘template<class type> constexpr typename std::enable_if<(std::is_integral<_Tp>::value && (! std::is_same<T, bool>::value)), const long int&>::type rclcpp::ParameterValue::get() const’
  263 |   get() const
      |   ^~~
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:263:3: note:   template argument deduction/substitution failed:
/opt/ros/foxy/include/rclcpp/parameter_value.hpp: In substitution of ‘template<class type> constexpr typename std::enable_if<(std::is_integral<_Tp>::value && (! std::is_same<T, bool>::value)), const long int&>::type rclcpp::ParameterValue::get() const [with type = std::vector<int>]’:
/opt/ros/foxy/include/rclcpp/node_impl.hpp:169:23:   required from ‘auto rclcpp::Node::declare_parameter(const string&, const ParameterT&, const ParameterDescriptor&, bool) [with ParameterT = std::vector<int>; std::string = std::__cxx11::basic_string<char>; rcl_interfaces::msg::ParameterDescriptor = rcl_interfaces::msg::ParameterDescriptor_<std::allocator<void> >]’
/home/john/Dev/qpta_ws/src/vector_int_pkg/src/test_vector_int.cpp:9:54:   required from here
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:263:3: error: no type named ‘type’ in ‘struct std::enable_if<false, const long int&>’
/opt/ros/foxy/include/rclcpp/node_impl.hpp: In instantiation of ‘auto rclcpp::Node::declare_parameter(const string&, const ParameterT&, const ParameterDescriptor&, bool) [with ParameterT = std::vector<int>; std::string = std::__cxx11::basic_string<char>; rcl_interfaces::msg::ParameterDescriptor = rcl_interfaces::msg::ParameterDescriptor_<std::allocator<void> >]’:
/home/john/Dev/qpta_ws/src/vector_int_pkg/src/test_vector_int.cpp:9:54:   required from here
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:271:3: note: candidate: ‘template<class type> constexpr typename std::enable_if<std::is_floating_point<_Tp>::value, const double&>::type rclcpp::ParameterValue::get() const’
  271 |   get() const
      |   ^~~
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:271:3: note:   template argument deduction/substitution failed:
/opt/ros/foxy/include/rclcpp/parameter_value.hpp: In substitution of ‘template<class type> constexpr typename std::enable_if<std::is_floating_point<_Tp>::value, const double&>::type rclcpp::ParameterValue::get() const [with type = std::vector<int>]’:
/opt/ros/foxy/include/rclcpp/node_impl.hpp:169:23:   required from ‘auto rclcpp::Node::declare_parameter(const string&, const ParameterT&, const ParameterDescriptor&, bool) [with ParameterT = std::vector<int>; std::string = std::__cxx11::basic_string<char>; rcl_interfaces::msg::ParameterDescriptor = rcl_interfaces::msg::ParameterDescriptor_<std::allocator<void> >]’
/home/john/Dev/qpta_ws/src/vector_int_pkg/src/test_vector_int.cpp:9:54:   required from here
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:271:3: error: no type named ‘type’ in ‘struct std::enable_if<false, const double&>’
/opt/ros/foxy/include/rclcpp/node_impl.hpp: In instantiation of ‘auto rclcpp::Node::declare_parameter(const string&, const ParameterT&, const ParameterDescriptor&, bool) [with ParameterT = std::vector<int>; std::string = std::__cxx11::basic_string<char>; rcl_interfaces::msg::ParameterDescriptor = rcl_interfaces::msg::ParameterDescriptor_<std::allocator<void> >]’:
/home/john/Dev/qpta_ws/src/vector_int_pkg/src/test_vector_int.cpp:9:54:   required from here
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:279:3: note: candidate: ‘template<class type> constexpr typename std::enable_if<std::is_convertible<type, std::__cxx11::basic_string<char> >::value, const std::__cxx11::basic_string<char>&>::type rclcpp::ParameterValue::get() const’
  279 |   get() const
      |   ^~~
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:279:3: note:   template argument deduction/substitution failed:
/opt/ros/foxy/include/rclcpp/parameter_value.hpp: In substitution of ‘template<class type> constexpr typename std::enable_if<std::is_convertible<type, std::__cxx11::basic_string<char> >::value, const std::__cxx11::basic_string<char>&>::type rclcpp::ParameterValue::get() const [with type = std::vector<int>]’:
/opt/ros/foxy/include/rclcpp/node_impl.hpp:169:23:   required from ‘auto rclcpp::Node::declare_parameter(const string&, const ParameterT&, const ParameterDescriptor&, bool) [with ParameterT = std::vector<int>; std::string = std::__cxx11::basic_string<char>; rcl_interfaces::msg::ParameterDescriptor = rcl_interfaces::msg::ParameterDescriptor_<std::allocator<void> >]’
/home/john/Dev/qpta_ws/src/vector_int_pkg/src/test_vector_int.cpp:9:54:   required from here
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:279:3: error: no type named ‘type’ in ‘struct std::enable_if<false, const std::__cxx11::basic_string<char>&>’
/opt/ros/foxy/include/rclcpp/node_impl.hpp: In instantiation of ‘auto rclcpp::Node::declare_parameter(const string&, const ParameterT&, const ParameterDescriptor&, bool) [with ParameterT = std::vector<int>; std::string = std::__cxx11::basic_string<char>; rcl_interfaces::msg::ParameterDescriptor = rcl_interfaces::msg::ParameterDescriptor_<std::allocator<void> >]’:
/home/john/Dev/qpta_ws/src/vector_int_pkg/src/test_vector_int.cpp:9:54:   required from here
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:289:3: note: candidate: ‘template<class type> constexpr typename std::enable_if<std::is_convertible<type, const std::vector<unsigned char, std::allocator<unsigned char> >&>::value, const std::vector<unsigned char, std::allocator<unsigned char> >&>::type rclcpp::ParameterValue::get() const’
  289 |   get() const
      |   ^~~
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:289:3: note:   template argument deduction/substitution failed:
/opt/ros/foxy/include/rclcpp/parameter_value.hpp: In substitution of ‘template<class type> constexpr typename std::enable_if<std::is_convertible<type, const std::vector<unsigned char, std::allocator<unsigned char> >&>::value, const std::vector<unsigned char, std::allocator<unsigned char> >&>::type rclcpp::ParameterValue::get() const [with type = std::vector<int>]’:
/opt/ros/foxy/include/rclcpp/node_impl.hpp:169:23:   required from ‘auto rclcpp::Node::declare_parameter(const string&, const ParameterT&, const ParameterDescriptor&, bool) [with ParameterT = std::vector<int>; std::string = std::__cxx11::basic_string<char>; rcl_interfaces::msg::ParameterDescriptor = rcl_interfaces::msg::ParameterDescriptor_<std::allocator<void> >]’
/home/john/Dev/qpta_ws/src/vector_int_pkg/src/test_vector_int.cpp:9:54:   required from here
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:289:3: error: no type named ‘type’ in ‘struct std::enable_if<false, const std::vector<unsigned char, std::allocator<unsigned char> >&>’
/opt/ros/foxy/include/rclcpp/node_impl.hpp: In instantiation of ‘auto rclcpp::Node::declare_parameter(const string&, const ParameterT&, const ParameterDescriptor&, bool) [with ParameterT = std::vector<int>; std::string = std::__cxx11::basic_string<char>; rcl_interfaces::msg::ParameterDescriptor = rcl_interfaces::msg::ParameterDescriptor_<std::allocator<void> >]’:
/home/john/Dev/qpta_ws/src/vector_int_pkg/src/test_vector_int.cpp:9:54:   required from here
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:299:3: note: candidate: ‘template<class type> constexpr typename std::enable_if<std::is_convertible<type, const std::vector<bool, std::allocator<bool> >&>::value, const std::vector<bool, std::allocator<bool> >&>::type rclcpp::ParameterValue::get() const’
  299 |   get() const
      |   ^~~
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:299:3: note:   template argument deduction/substitution failed:
/opt/ros/foxy/include/rclcpp/parameter_value.hpp: In substitution of ‘template<class type> constexpr typename std::enable_if<std::is_convertible<type, const std::vector<bool, std::allocator<bool> >&>::value, const std::vector<bool, std::allocator<bool> >&>::type rclcpp::ParameterValue::get() const [with type = std::vector<int>]’:
/opt/ros/foxy/include/rclcpp/node_impl.hpp:169:23:   required from ‘auto rclcpp::Node::declare_parameter(const string&, const ParameterT&, const ParameterDescriptor&, bool) [with ParameterT = std::vector<int>; std::string = std::__cxx11::basic_string<char>; rcl_interfaces::msg::ParameterDescriptor = rcl_interfaces::msg::ParameterDescriptor_<std::allocator<void> >]’
/home/john/Dev/qpta_ws/src/vector_int_pkg/src/test_vector_int.cpp:9:54:   required from here
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:299:3: error: no type named ‘type’ in ‘struct std::enable_if<false, const std::vector<bool, std::allocator<bool> >&>’
/opt/ros/foxy/include/rclcpp/node_impl.hpp: In instantiation of ‘auto rclcpp::Node::declare_parameter(const string&, const ParameterT&, const ParameterDescriptor&, bool) [with ParameterT = std::vector<int>; std::string = std::__cxx11::basic_string<char>; rcl_interfaces::msg::ParameterDescriptor = rcl_interfaces::msg::ParameterDescriptor_<std::allocator<void> >]’:
/home/john/Dev/qpta_ws/src/vector_int_pkg/src/test_vector_int.cpp:9:54:   required from here
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:309:3: note: candidate: ‘template<class type> constexpr typename std::enable_if<std::is_convertible<type, const std::vector<long int, std::allocator<long int> >&>::value, const std::vector<long int, std::allocator<long int> >&>::type rclcpp::ParameterValue::get() const’
  309 |   get() const
      |   ^~~
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:309:3: note:   template argument deduction/substitution failed:
/opt/ros/foxy/include/rclcpp/parameter_value.hpp: In substitution of ‘template<class type> constexpr typename std::enable_if<std::is_convertible<type, const std::vector<long int, std::allocator<long int> >&>::value, const std::vector<long int, std::allocator<long int> >&>::type rclcpp::ParameterValue::get() const [with type = std::vector<int>]’:
/opt/ros/foxy/include/rclcpp/node_impl.hpp:169:23:   required from ‘auto rclcpp::Node::declare_parameter(const string&, const ParameterT&, const ParameterDescriptor&, bool) [with ParameterT = std::vector<int>; std::string = std::__cxx11::basic_string<char>; rcl_interfaces::msg::ParameterDescriptor = rcl_interfaces::msg::ParameterDescriptor_<std::allocator<void> >]’
/home/john/Dev/qpta_ws/src/vector_int_pkg/src/test_vector_int.cpp:9:54:   required from here
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:309:3: error: no type named ‘type’ in ‘struct std::enable_if<false, const std::vector<long int, std::allocator<long int> >&>’
/opt/ros/foxy/include/rclcpp/node_impl.hpp: In instantiation of ‘auto rclcpp::Node::declare_parameter(const string&, const ParameterT&, const ParameterDescriptor&, bool) [with ParameterT = std::vector<int>; std::string = std::__cxx11::basic_string<char>; rcl_interfaces::msg::ParameterDescriptor = rcl_interfaces::msg::ParameterDescriptor_<std::allocator<void> >]’:
/home/john/Dev/qpta_ws/src/vector_int_pkg/src/test_vector_int.cpp:9:54:   required from here
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:319:3: note: candidate: ‘template<class type> constexpr typename std::enable_if<std::is_convertible<type, const std::vector<double, std::allocator<double> >&>::value, const std::vector<double, std::allocator<double> >&>::type rclcpp::ParameterValue::get() const’
  319 |   get() const
      |   ^~~
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:319:3: note:   template argument deduction/substitution failed:
/opt/ros/foxy/include/rclcpp/parameter_value.hpp: In substitution of ‘template<class type> constexpr typename std::enable_if<std::is_convertible<type, const std::vector<double, std::allocator<double> >&>::value, const std::vector<double, std::allocator<double> >&>::type rclcpp::ParameterValue::get() const [with type = std::vector<int>]’:
/opt/ros/foxy/include/rclcpp/node_impl.hpp:169:23:   required from ‘auto rclcpp::Node::declare_parameter(const string&, const ParameterT&, const ParameterDescriptor&, bool) [with ParameterT = std::vector<int>; std::string = std::__cxx11::basic_string<char>; rcl_interfaces::msg::ParameterDescriptor = rcl_interfaces::msg::ParameterDescriptor_<std::allocator<void> >]’
/home/john/Dev/qpta_ws/src/vector_int_pkg/src/test_vector_int.cpp:9:54:   required from here
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:319:3: error: no type named ‘type’ in ‘struct std::enable_if<false, const std::vector<double, std::allocator<double> >&>’
/opt/ros/foxy/include/rclcpp/node_impl.hpp: In instantiation of ‘auto rclcpp::Node::declare_parameter(const string&, const ParameterT&, const ParameterDescriptor&, bool) [with ParameterT = std::vector<int>; std::string = std::__cxx11::basic_string<char>; rcl_interfaces::msg::ParameterDescriptor = rcl_interfaces::msg::ParameterDescriptor_<std::allocator<void> >]’:
/home/john/Dev/qpta_ws/src/vector_int_pkg/src/test_vector_int.cpp:9:54:   required from here
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:329:3: note: candidate: ‘template<class type> constexpr typename std::enable_if<std::is_convertible<type, const std::vector<std::__cxx11::basic_string<char> >&>::value, const std::vector<std::__cxx11::basic_string<char> >&>::type rclcpp::ParameterValue::get() const’
  329 |   get() const
      |   ^~~
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:329:3: note:   template argument deduction/substitution failed:
/opt/ros/foxy/include/rclcpp/parameter_value.hpp: In substitution of ‘template<class type> constexpr typename std::enable_if<std::is_convertible<type, const std::vector<std::__cxx11::basic_string<char> >&>::value, const std::vector<std::__cxx11::basic_string<char> >&>::type rclcpp::ParameterValue::get() const [with type = std::vector<int>]’:
/opt/ros/foxy/include/rclcpp/node_impl.hpp:169:23:   required from ‘auto rclcpp::Node::declare_parameter(const string&, const ParameterT&, const ParameterDescriptor&, bool) [with ParameterT = std::vector<int>; std::string = std::__cxx11::basic_string<char>; rcl_interfaces::msg::ParameterDescriptor = rcl_interfaces::msg::ParameterDescriptor_<std::allocator<void> >]’
/home/john/Dev/qpta_ws/src/vector_int_pkg/src/test_vector_int.cpp:9:54:   required from here
/opt/ros/foxy/include/rclcpp/parameter_value.hpp:329:3: error: no type named ‘type’ in ‘struct std::enable_if<false, const std::vector<std::__cxx11::basic_string<char> >&>’
make[2]: *** [CMakeFiles/test_vector_int.dir/build.make:63: CMakeFiles/test_vector_int.dir/src/test_vector_int.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:78: CMakeFiles/test_vector_int.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
---
Failed   <<< vector_int_pkg [3.58s, exited with code 2]
                                
Summary: 0 packages finished [3.69s]
  1 package failed: vector_int_pkg
  1 package had stderr output: vector_int_pkg

Additional information

These don't work either

node->declare_parameter("param", std::vector<float>{});
// --------------------------------------
node->declare_parameter<std::vector<int>>("param", std::vector<int>{});
// --------------------------------------
std::vector<int> v = {};
node->declare_parameter("param", v);

while these work

node->declare_parameter<std::vector<double>>("param", std::vector<double>{});
// --------------------------------------
node->declare_parameter("param", std::vector<uint8_t>{});
node->declare_parameter("param", std::vector<bool>{});
node->declare_parameter("param", std::vector<int64_t>{});
node->declare_parameter("param", std::vector<double>{});
node->declare_parameter("param", std::vector<std::string>{});
// --------------------------------------
node->declare_parameter("param", rclcpp::ParameterValue(std::vector<int>{}));

Here are the lines 104 to 121 from the /opt/ros/foxy/include/rclcpp/parameter_value.hpp file

  /// Construct a parameter value with type PARAMETER_BOOL_ARRAY.
  RCLCPP_PUBLIC
  explicit ParameterValue(const std::vector<bool> & bool_array_value);
  /// Construct a parameter value with type PARAMETER_INTEGER_ARRAY.
  RCLCPP_PUBLIC
  explicit ParameterValue(const std::vector<int> & int_array_value);
  /// Construct a parameter value with type PARAMETER_INTEGER_ARRAY.
  RCLCPP_PUBLIC
  explicit ParameterValue(const std::vector<int64_t> & int_array_value);
  /// Construct a parameter value with type PARAMETER_DOUBLE_ARRAY.
  RCLCPP_PUBLIC
  explicit ParameterValue(const std::vector<float> & double_array_value);
  /// Construct a parameter value with type PARAMETER_DOUBLE_ARRAY.
  RCLCPP_PUBLIC
  explicit ParameterValue(const std::vector<double> & double_array_value);
  /// Construct a parameter value with type PARAMETER_STRING_ARRAY.
  RCLCPP_PUBLIC
  explicit ParameterValue(const std::vector<std::string> & string_array_value);

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions