-
Notifications
You must be signed in to change notification settings - Fork 431
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 use_global_arguments for node options of component nodes #1776
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -211,6 +211,50 @@ TEST_F(TestComponentManager, components_api) | |
EXPECT_EQ(result->unique_id, 0u); | ||
} | ||
|
||
{ | ||
// use_global_arguments | ||
auto request = std::make_shared<composition_interfaces::srv::LoadNode::Request>(); | ||
request->package_name = "rclcpp_components"; | ||
request->plugin_name = "test_rclcpp_components::TestComponentFoo"; | ||
request->node_name = "test_component_global_arguments"; | ||
rclcpp::Parameter use_global_arguments("use_global_arguments", | ||
rclcpp::ParameterValue(true)); | ||
request->extra_arguments.push_back(use_global_arguments.to_parameter_msg()); | ||
|
||
auto future = composition_client->async_send_request(request); | ||
auto ret = exec->spin_until_future_complete(future, 5s); // Wait for the result. | ||
auto result = future.get(); | ||
EXPECT_EQ(ret, rclcpp::FutureReturnCode::SUCCESS); | ||
EXPECT_EQ(result->success, true); | ||
EXPECT_EQ(result->error_message, ""); | ||
std::cout << result->full_node_name << std::endl; | ||
EXPECT_EQ(result->full_node_name, "/test_component_global_arguments"); | ||
EXPECT_EQ(result->unique_id, 7u); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gezp nit: this tests that the manager did not fail but not that it did anything about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, |
||
} | ||
|
||
{ | ||
// use_global_arguments is not a bool type parameter | ||
auto request = std::make_shared<composition_interfaces::srv::LoadNode::Request>(); | ||
request->package_name = "rclcpp_components"; | ||
request->plugin_name = "test_rclcpp_components::TestComponentFoo"; | ||
request->node_name = "test_component_global_arguments_str"; | ||
|
||
rclcpp::Parameter use_global_arguments("use_global_arguments", | ||
rclcpp::ParameterValue("hello")); | ||
request->extra_arguments.push_back(use_global_arguments.to_parameter_msg()); | ||
|
||
auto future = composition_client->async_send_request(request); | ||
auto ret = exec->spin_until_future_complete(future, 5s); // Wait for the result. | ||
auto result = future.get(); | ||
EXPECT_EQ(ret, rclcpp::FutureReturnCode::SUCCESS); | ||
EXPECT_EQ(result->success, false); | ||
EXPECT_EQ( | ||
result->error_message, | ||
"Extra component argument 'use_global_arguments' must be a boolean"); | ||
EXPECT_EQ(result->full_node_name, ""); | ||
EXPECT_EQ(result->unique_id, 0u); | ||
} | ||
|
||
auto node_names = node->get_node_names(); | ||
|
||
auto find_in_nodes = [node_names](std::string name) { | ||
|
@@ -239,20 +283,22 @@ TEST_F(TestComponentManager, components_api) | |
auto result_node_names = result->full_node_names; | ||
auto result_unique_ids = result->unique_ids; | ||
|
||
EXPECT_EQ(result_node_names.size(), 6u); | ||
EXPECT_EQ(result_node_names.size(), 7u); | ||
EXPECT_EQ(result_node_names[0], "/test_component_foo"); | ||
EXPECT_EQ(result_node_names[1], "/test_component_bar"); | ||
EXPECT_EQ(result_node_names[2], "/test_component_baz"); | ||
EXPECT_EQ(result_node_names[3], "/ns/test_component_bing"); | ||
EXPECT_EQ(result_node_names[4], "/test_component_remap"); | ||
EXPECT_EQ(result_node_names[5], "/test_component_intra_process"); | ||
EXPECT_EQ(result_unique_ids.size(), 6u); | ||
EXPECT_EQ(result_node_names[6], "/test_component_global_arguments"); | ||
EXPECT_EQ(result_unique_ids.size(), 7u); | ||
EXPECT_EQ(result_unique_ids[0], 1u); | ||
EXPECT_EQ(result_unique_ids[1], 2u); | ||
EXPECT_EQ(result_unique_ids[2], 3u); | ||
EXPECT_EQ(result_unique_ids[3], 4u); | ||
EXPECT_EQ(result_unique_ids[4], 5u); | ||
EXPECT_EQ(result_unique_ids[5], 6u); | ||
EXPECT_EQ(result_unique_ids[6], 7u); | ||
} | ||
} | ||
|
||
|
@@ -306,18 +352,20 @@ TEST_F(TestComponentManager, components_api) | |
auto result_node_names = result->full_node_names; | ||
auto result_unique_ids = result->unique_ids; | ||
|
||
EXPECT_EQ(result_node_names.size(), 5u); | ||
EXPECT_EQ(result_node_names.size(), 6u); | ||
EXPECT_EQ(result_node_names[0], "/test_component_bar"); | ||
EXPECT_EQ(result_node_names[1], "/test_component_baz"); | ||
EXPECT_EQ(result_node_names[2], "/ns/test_component_bing"); | ||
EXPECT_EQ(result_node_names[3], "/test_component_remap"); | ||
EXPECT_EQ(result_node_names[4], "/test_component_intra_process"); | ||
EXPECT_EQ(result_unique_ids.size(), 5u); | ||
EXPECT_EQ(result_node_names[5], "/test_component_global_arguments"); | ||
EXPECT_EQ(result_unique_ids.size(), 6u); | ||
EXPECT_EQ(result_unique_ids[0], 2u); | ||
EXPECT_EQ(result_unique_ids[1], 3u); | ||
EXPECT_EQ(result_unique_ids[2], 4u); | ||
EXPECT_EQ(result_unique_ids[3], 5u); | ||
EXPECT_EQ(result_unique_ids[4], 6u); | ||
EXPECT_EQ(result_unique_ids[5], 7u); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gezp meta: thinking about your use case, I wonder if it would make sense for the
component_manager
node to expose, e.g. as a parameter, the default value ofuse_global_arguments
for the nodes it composes. Seems convenient if you're already passing a large parameter file to it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i agree with you, for my use case (use a large parameter file for all components), it seems better to use a parameter of
component_manager
to configure all componentsuse_global_arguments
, which we needn't set this for components one by one in launch file.I'm not good at naming parameter, could you give me some suggestions ? @hidmic . how about
use_global_arguments
(i think it's bad, because it seems that we setcomponent_manager
nodes to use global arguments, but we want to set this for components) orcomponent_use_global_arguments
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gezp perhaps
forward_global_arguments
? I'm not very creative either. At any rate, I won't block this patch on it.