Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some parameter arrays to set_and_get_parameters tests #235

Merged
merged 2 commits into from
May 10, 2018
Merged
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: 4 additions & 1 deletion demo_nodes_cpp/src/parameters/set_and_get_parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <memory>
#include <sstream>
#include <vector>

#include "rclcpp/rclcpp.hpp"

Expand Down Expand Up @@ -46,6 +47,8 @@ int main(int argc, char ** argv)
rclcpp::parameter::ParameterVariant("bar", "hello"),
rclcpp::parameter::ParameterVariant("baz", 1.45),
rclcpp::parameter::ParameterVariant("foobar", true),
rclcpp::parameter::ParameterVariant("foobarbaz", std::vector<bool>({true, false})),
rclcpp::parameter::ParameterVariant("toto", std::vector<uint8_t>({0xff, 0x7f})),
});
// Check to see if they were set.
for (auto & result : set_parameters_results) {
Expand All @@ -56,7 +59,7 @@ int main(int argc, char ** argv)

std::stringstream ss;
// Get a few of the parameters just set.
for (auto & parameter : parameters_client->get_parameters({"foo", "baz"})) {
for (auto & parameter : parameters_client->get_parameters({"foo", "baz", "foobarbaz", "toto"})) {
ss << "\nParameter name: " << parameter.get_name();
ss << "\nParameter value (" << parameter.get_type_name() << "): " <<
parameter.value_to_string();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <memory>
#include <sstream>
#include <vector>

#include "rclcpp/rclcpp.hpp"

Expand Down Expand Up @@ -46,6 +47,8 @@ int main(int argc, char ** argv)
rclcpp::parameter::ParameterVariant("bar", "hello"),
rclcpp::parameter::ParameterVariant("baz", 1.45),
rclcpp::parameter::ParameterVariant("foobar", true),
rclcpp::parameter::ParameterVariant("foobarbaz", std::vector<bool>({true, false})),
rclcpp::parameter::ParameterVariant("toto", std::vector<uint8_t>({0xff, 0x7f})),
});
// Wait for the results.
if (rclcpp::spin_until_future_complete(node, results) !=
Expand All @@ -62,7 +65,7 @@ int main(int argc, char ** argv)
}

// Get a few of the parameters just set.
auto parameters = parameters_client->get_parameters({"foo", "baz"});
auto parameters = parameters_client->get_parameters({"foo", "baz", "foobarbaz", "toto"});
if (rclcpp::spin_until_future_complete(node, parameters) !=
rclcpp::executor::FutureReturnCode::SUCCESS)
{
Expand Down
4 changes: 4 additions & 0 deletions demo_nodes_cpp/test/set_and_get_parameters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ Parameter name: foo
Parameter value (integer): 2
Parameter name: baz
Parameter value (double): 1.450000
Parameter name: foobarbaz
Parameter value (bool_array): [true, false]
Parameter name: toto
Parameter value (byte_array): [0xff, 0x7f]
4 changes: 4 additions & 0 deletions demo_nodes_cpp/test/set_and_get_parameters_async.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ Parameter name: foo
Parameter value (integer): 2
Parameter name: baz
Parameter value (double): 1.450000
Parameter name: foobarbaz
Parameter value (bool_array): [true, false]
Parameter name: toto
Parameter value (byte_array): [0xff, 0x7f]