Skip to content

Exposed rcl_actions to the NodeGraph class#2188

Open
CursedRock17 wants to merge 9 commits intoros2:rollingfrom
CursedRock17:actions_exposed
Open

Exposed rcl_actions to the NodeGraph class#2188
CursedRock17 wants to merge 9 commits intoros2:rollingfrom
CursedRock17:actions_exposed

Conversation

@CursedRock17
Copy link
Copy Markdown
Contributor

This pull request is meant to address issue #1473 which needs rcl_action functions exposed to the NodeGraph class. As mentioned:

  • rcl_action_get_client_names_and_types_by_node
  • rcl_action_get_server_names_and_types_by_node
  • rcl_action_get_names_and_types

were all meant to be exposed from rcl to rclcpp, which based on the previous comment meant to make methods similar to rclpy. So each of the functions developed in this PR all follow a similar format of gaining access to the original rcl_action methods with a rcl_ret_t type and return a map of all the names and types.

@fujitatomoya fujitatomoya self-requested a review May 8, 2023 17:57
@fujitatomoya fujitatomoya self-assigned this May 8, 2023
@fujitatomoya
Copy link
Copy Markdown
Collaborator

@CursedRock17 thanks for the PR, i will take a look. in the meantime, can you address DCO error? https://github.com/ros2/rclcpp/pull/2188/checks?check_run_id=13298073729

Copy link
Copy Markdown
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in addition to comments, it would be ideal to add the test cases to rclcpp/test/rclcpp/node_interfaces/test_node_graph.cpp.

Comment thread rclcpp/include/rclcpp/node_interfaces/node_graph.hpp Outdated
Comment thread rclcpp/include/rclcpp/node_interfaces/node_graph.hpp
Comment thread rclcpp/include/rclcpp/node_interfaces/node_graph.hpp
Comment thread rclcpp/include/rclcpp/node_interfaces/node_graph.hpp
Comment thread rclcpp/src/rclcpp/node_interfaces/node_graph.cpp Outdated
Comment thread rclcpp/src/rclcpp/node_interfaces/node_graph.cpp Outdated
Comment thread rclcpp/src/rclcpp/node_interfaces/node_graph.cpp Outdated
Comment thread rclcpp/src/rclcpp/node_interfaces/node_graph.cpp
Comment thread rclcpp/src/rclcpp/node_interfaces/node_graph.cpp Outdated
Comment thread rclcpp/src/rclcpp/node_interfaces/node_graph.cpp
@CursedRock17
Copy link
Copy Markdown
Contributor Author

in addition to comments, it would be ideal to add the test cases to rclcpp/test/rclcpp/node_interfaces/test_node_graph.cpp.

The most recent commit I pushed contained the tests for the rcl_action_get_names_and_types I followed format for other similar methods in the file. Was that the way that made testing the most efficient for those types of functions, if so, I can replicate with so more tests for the other new functions.

@fujitatomoya
Copy link
Copy Markdown
Collaborator

@CursedRock17 thanks for iterating and being responsive. i will take a look tomorrow, in the meantime can you address DCO error?

Copy link
Copy Markdown
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add the test cases to check if it can actually get names and types? for example,

TEST_F(TestNodeGraph, get_service_names_and_types_by_node)

Copy link
Copy Markdown
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CursedRock17 can you check building and testing with your local environment? i cannot build or test this PR... thanks in advance.


RCLCPP_PUBLIC
std::map<std::string, std::vector<std::string>>
get_action_names_and_types() const override;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this cannot be built since there is no virtual function exists. Could you update NodeGraphInterface accordingly?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EXPECT_THROW(
node_graph()->get_action_names_and_types("action", false),
rclcpp::exceptions::RCLError);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs brackets at the end of this test case?

Suggested change
}

Comment on lines +739 to +740
auto client =
node()->create_client<test_msgs::srv::Empty>("node1_service");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we need to create action but service for this test case.


TEST_F(TestNodeGraph, get_action_client_names_and_types_by_node_rcl_error)
{
auto client = node()->create_client<test_msgs::srv::Empty>("node1_service");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, this is creating service but action. rclcpp_action::create_client should be called instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this makes sense, I cannot include the rclcpp_action part of the library in the rclcpp section, otherwise a linking error is thrown because rclcpp_action uses rclcpp, so this would result in an infinite loop. We need to both, have these functions in the node_graph_interface section, and utilize the rclcpp_action commands.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing that we could do is add specifically the tests to the rclcpp_action part of the rclcpp library with a new file along the names of test_action_calls. Since rclcpp_action has to include rclcpp in its cmake file and already has the ability to include rclcpp_action::create_server there would be no linking issues. The problem is just the location of these files because the rcl_action wrapper interfaces are in the rclcpp/nodeinterfaces section of the codebase, which makes this location a bit awkward for naming purpose. The functions like get_action_types_and_names make the most sense where they are now, but it seems the tests have to be moved simply because including rclcpp_action in rclcpp isn't possible.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This conversation is making me question whether we want to expose this as part of rclcpp at all. That is, I wonder if it would make more sense to move all of this to rclcpp_action (possibly with a new NodeActionGraph class), which avoids this whole problem. That said, I haven't looked at this implementation closely yet, so maybe this doesn't make much sense.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have to agree with moving this entire implementation to rclcpp_action. The folder is already quite slim with files and seems to be a better place to place wrapped rcl_action functions. While keeping all three of these functions in the node_graph.cpp section would be simpler; the fact that we would need to move tests to a different part of the project entirely showcases a design flaw.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm now less confident in moving the entire implementation of NodeGraph into rclcpp_action as NodeActionGraph. While we are only using it for action based activities, it's not action specific, simply just an rcl_action wrapper, we then have to move all of the other general overrides to this new class. This will add another ~500 lines that we probably could have avoided.

Additionally, if the user has some long-running process using an action server/client, while they have a small publisher/subscriber maybe keeping track of the environment, they won't be able to track these processes from one NodeGraph. If we did move the action side of things over to a new class, they have to create both a NodeGraph and NodeActionGraph, so if the user were to call get_graph_event and gain another user on the NodeGraph, the NodeActionGraph wouldn't see that change, thus won't be able to accurately track the processes running.


TEST_F(TestNodeGraph, get_action_client_names_and_types_by_node_rcl_fini_error)
{
auto client = node()->create_client<test_msgs::srv::Empty>("node1_service");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here.

};
auto handle_accepted = [](std::shared_ptr<test_msgs::msg::Empty>){};

const server = node()->create_server<test_msgs::msg::Empty(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, this is service.

@CursedRock17
Copy link
Copy Markdown
Contributor Author

@CursedRock17 can you check building and testing with your local environment? i cannot build or test this PR... thanks in advance.

Yes I can test, I can do it on both my computer and Docker for Ubuntu 22.04 correct?

@fujitatomoya
Copy link
Copy Markdown
Collaborator

Docker for Ubuntu 22.04 correct?

yes, as long as the userland is Ubuntu 22.04, i believe there should be no problem for this PR verification.

Signed-off-by: CursedRock17 <mtglucas1@gmail.com>
Signed-off-by: CursedRock17 <mtglucas1@gmail.com>
Signed-off-by: CursedRock17 <mtglucas1@gmail.com>
Signed-off-by: CursedRock17 <mtglucas1@gmail.com>
Signed-off-by: CursedRock17 <mtglucas1@gmail.com>
Signed-off-by: CursedRock17 <mtglucas1@gmail.com>
Signed-off-by: CursedRock17 <mtglucas1@gmail.com>
Signed-off-by: CursedRock17 <mtglucas1@gmail.com>
Signed-off-by: CursedRock17 <mtglucas1@gmail.com>

Making requests action related

Signed-off-by: CursedRock17 <mtglucas1@gmail.com>

Testing suite

Signed-off-by: CursedRock17 <mtglucas1@gmail.com>

Moving Tests

Signed-off-by: CursedRock17 <mtglucas1@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants