I have create a ros2 node which simply declares and get parameter. I am getting the following error.

/home/user/ros_ws/src/vector_int_pkg/src/test_vector_int.cpp:14:22:   required from here
/opt/ros/iron/include/rclcpp/rclcpp/node_impl.hpp:343:17: error: no matching function for call to ‘std::vector<int>::vector(std::vector<long int, std::allocator<long int> >)’
  343 |     parameter = static_cast<ParameterT>(parameter_variant.get_value<ParameterT>());
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Here is the code:

#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");

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

  // Getting Params
  std::vector<int> clamps_iters = {1,2,3};
  node->get_parameter("param", clamps_iters);


Here is a similar issue which is already resolved and is working on my system as well.

To reproduce the error, follow the steps mentioned in the link above and replace the node code with the one I provided above.



1 Answer 1


I have posted this as a issue at ros2 rclcpp repo. Someone suggested that it is because there is no default conversion function from std::vector<int64_t> to std:vector<int>. He also suggested a workaround to replace std::vector<int> clamps_iters = {1,2,3}; with std::vector<int64_t> clamps_iters = {1,2,3};. Checkout the link provided above for more info.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.