Skip to content

Commit

Permalink
Add accessors for request and uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
sloretz committed Nov 30, 2018
1 parent c9faf25 commit a77cc11
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
23 changes: 19 additions & 4 deletions rclcpp_action/include/rclcpp_action/server_goal_handle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,19 @@ class ServerGoalHandle : public ServerGoalHandleBase
on_terminal_state_(uuid_, result_msg);
}

/// The original request message describing the goal.
const std::shared_ptr<const typename ACTION::Goal> goal_;
/// Get the original request message describing the goal.
const std::shared_ptr<const typename ACTION::Goal>
get_goal() const
{
return goal_;
}

/// A unique id for the goal request.
const std::array<uint8_t, 16> uuid_;
/// Get the unique identifier of the goal
const std::array<uint8_t, 16>
get_uuid() const
{
return uuid_;
}

protected:
ServerGoalHandle(
Expand All @@ -145,6 +153,13 @@ class ServerGoalHandle : public ServerGoalHandleBase
{
}

/// The original request message describing the goal.
const std::shared_ptr<const typename ACTION::Goal> goal_;

/// A unique id for the goal request.
const std::array<uint8_t, 16> uuid_;


friend Server<ACTION>;

std::function<void(const std::array<uint8_t, 16>&, std::shared_ptr<void>)> on_terminal_state_;
Expand Down
6 changes: 3 additions & 3 deletions rclcpp_action/test/test_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ TEST_F(TestServer, handle_execute_called)

ASSERT_TRUE(received_handle);
ASSERT_TRUE(received_handle->is_active());
EXPECT_EQ(uuid, received_handle->uuid_);
EXPECT_EQ(*request, *(received_handle->goal_));
EXPECT_EQ(uuid, received_handle->get_uuid());
EXPECT_EQ(*request, *(received_handle->get_goal()));
}

TEST_F(TestServer, handle_cancel_called)
Expand Down Expand Up @@ -198,7 +198,7 @@ TEST_F(TestServer, handle_cancel_called)
send_goal_request(node, uuid);

ASSERT_TRUE(received_handle);
EXPECT_EQ(uuid, received_handle->uuid_);
EXPECT_EQ(uuid, received_handle->get_uuid());
EXPECT_FALSE(received_handle->is_cancel_request());

send_cancel_request(node, uuid);
Expand Down

0 comments on commit a77cc11

Please sign in to comment.