ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How to use declare_parameters with a vector of floats?

asked 2021-03-05 10:47:40 -0500

Hakaishin gravatar image

I'm using ros2 source build master branch. I was trying

 this->declare_parameters<std::vector<float>>("foo", { {"bar", {1.2}},{ {"zee", {4.2}}});

but that fails with

/home/usr/ros2_foxy/install/rclcpp_lifecycle/include/rclcpp_lifecycle/lifecycle_node_impl.hpp:144:21: error: no matching function for call to ‘rclcpp::ParameterValue::get<std::vector<float, std::allocator<float> > >() const’
  144 |   ).get<ParameterT>();

Is there currently a way to specify a list of parameters which have vectors as their values?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2021-08-25 03:03:18 -0500

Hakaishin gravatar image

It's not implemented for floats, just change the syntax to double and it works.

this->declare_parameters<std::vector<double>>("foo", {
            {"bar", {1.2}},
});

and get the config with

std::map<std::string, std::vector<double>> foo;
this->get_parameters("foo", foo);
edit flag offensive delete link more

Question Tools

3 followers

Stats

Asked: 2021-03-05 10:47:40 -0500

Seen: 785 times

Last updated: Aug 25 '21