Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions rclcpp/include/rclcpp/parameter_value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,11 @@ class ParameterValue
constexpr
typename std::enable_if<
std::is_convertible<
type, const std::vector<int> &>::value, const std::vector<int64_t> &>::type
type, const std::vector<int> &>::value, std::vector<int>>::type
get() const
{
return get<ParameterType::PARAMETER_INTEGER_ARRAY>();
const auto & value = get<ParameterType::PARAMETER_INTEGER_ARRAY>();
return std::vector<int>(value.begin(), value.end());
}

template<typename type>
Expand Down
13 changes: 13 additions & 0 deletions rclcpp/test/rclcpp/test_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2726,6 +2726,19 @@ TEST_F(TestNode, get_parameter_undeclared_parameters_not_allowed) {
}
}

TEST_F(TestNode, get_parameter_with_vector_int) {
auto node = std::make_shared<rclcpp::Node>("test_get_parameter_node"_unq);
auto name = "parameter"_unq;
const std::vector<int> expected_value = {
42, -99, std::numeric_limits<int>::max(), std::numeric_limits<int>::lowest(), 0};

node->declare_parameter(name, expected_value);

std::vector<int> value;
EXPECT_TRUE(node->get_parameter(name, value));
EXPECT_EQ(expected_value, value);
}

// test get_parameter with undeclared allowed
TEST_F(TestNode, get_parameter_undeclared_parameters_allowed) {
auto node = std::make_shared<rclcpp::Node>(
Expand Down