Skip to content

Commit

Permalink
add node_waitables_ to copy constructor. (backport #1799) (#1834)
Browse files Browse the repository at this point in the history
* add node_waitables_ to copy constructor.

Signed-off-by: Tomoya Fujita <[email protected]>

* add node_time_source_ to copy constructor.

Signed-off-by: Tomoya Fujita <[email protected]>

* add construction_and_destruction_sub_node for action server.

Signed-off-by: Tomoya Fujita <[email protected]>

Co-authored-by: Abrar Rahman Protyasha <[email protected]>
(cherry picked from commit 3019575)

Co-authored-by: Tomoya Fujita <[email protected]>
  • Loading branch information
mergify[bot] and fujitatomoya authored Dec 3, 2021
1 parent a58f8c1 commit a8baa3c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions rclcpp/src/rclcpp/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ Node::Node(
node_services_(other.node_services_),
node_clock_(other.node_clock_),
node_parameters_(other.node_parameters_),
node_time_source_(other.node_time_source_),
node_waitables_(other.node_waitables_),
node_options_(other.node_options_),
sub_namespace_(extend_sub_namespace(other.get_sub_namespace(), sub_namespace)),
effective_namespace_(create_effective_namespace(other.get_namespace(), sub_namespace_))
Expand Down
21 changes: 21 additions & 0 deletions rclcpp_action/test/test_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,27 @@ TEST_F(TestServer, construction_and_destruction_wait_set_error)
}, rclcpp::exceptions::RCLError);
}

TEST_F(TestServer, construction_and_destruction_sub_node)
{
auto parent_node = std::make_shared<rclcpp::Node>("construct_node", "/rclcpp_action/construct");
auto sub_node = parent_node->create_sub_node("construct_sub_node");

ASSERT_NO_THROW(
{
using GoalHandle = rclcpp_action::ServerGoalHandle<Fibonacci>;
auto as = rclcpp_action::create_server<Fibonacci>(
sub_node, "fibonacci",
[](const GoalUUID &, std::shared_ptr<const Fibonacci::Goal>) {
return rclcpp_action::GoalResponse::REJECT;
},
[](std::shared_ptr<GoalHandle>) {
return rclcpp_action::CancelResponse::REJECT;
},
[](std::shared_ptr<GoalHandle>) {});
(void)as;
});
}

TEST_F(TestServer, handle_goal_called)
{
auto node = std::make_shared<rclcpp::Node>("handle_goal_node", "/rclcpp_action/handle_goal");
Expand Down

0 comments on commit a8baa3c

Please sign in to comment.