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

[Iron] Add new node interface TypeDescriptionsInterface to provide GetTypeDescription service (backport #2224) #2236

Merged
merged 5 commits into from
Jul 18, 2023

Conversation

emersonknapp
Copy link
Collaborator

@emersonknapp emersonknapp commented Jul 7, 2023

backports #2224 to Iron

Depends on ros2/rcl#1082
Linked to ros2/system_tests#521

  • TypeDescriptions interface with readonly param configuration
  • Add parameter descriptor, to make read only
  • example of spinning in thread for get_type_description service
  • Add a basic test for the new interface
  • Fix tests with new parameter
  • Add comments about builtin parameters

…scription service (ros2#2224)

* TypeDescriptions interface with readonly param configuration

* Add parameter descriptor, to make read only

* example of spinning in thread for get_type_description service

* Add a basic test for the new interface

* Fix tests with new parameter

* Add comments about builtin parameters

Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
Signed-off-by: William Woodall <william@osrfoundation.org>
@emersonknapp emersonknapp changed the title Add new node interface TypeDescriptionsInterface to provide GetTypeDescription service (backport #2224) [Iron] Add new node interface TypeDescriptionsInterface to provide GetTypeDescription service (backport #2224) Jul 7, 2023
@emersonknapp
Copy link
Collaborator Author

Using https://github.com/ros2/rclcpp/pull/2183/files as a reference for ABI-stable backport

Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
@emersonknapp emersonknapp force-pushed the emersonknapp/iron-backport-2224 branch from d7c8669 to 75e180c Compare July 7, 2023 22:22
@@ -1591,6 +1597,9 @@ class Node : public std::enable_shared_from_this<Node>
const rclcpp::NodeOptions node_options_;
const std::string sub_namespace_;
const std::string effective_namespace_;

class BackportMemberMaps;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note to reviewer: went with a generic name to leave it open for possible other members usage

Copy link
Contributor

Choose a reason for hiding this comment

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

At the risk of bikeshedding, I think the name is a little too generic. That is, the class embeds a

std::unordered_map<
    const Node *, rclcpp::node_interfaces::NodeTypeDescriptionsInterface::SharedPtr
  > type_descriptions_map_;

which feels very specific to this backport. I think I'd go with BackportTypeDescriptionsInterface, or something like that.

Copy link
Collaborator Author

@emersonknapp emersonknapp Jul 12, 2023

Choose a reason for hiding this comment

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

Maybe the intention wasn't clear. This class could have more maps within it, controlled by the same access mutex, that create more "members" for the owning class' instances. Given that members would be created all at once, and removed all at once, there would be no partial construction or partial deletion of these "members", it makes sense to use the same mutex and manage all the maps at once. That was the intention here - this thing is "all extra backported members" - and maybe that ends up being only one from this backport, but if we do want to backport more member-based features to Iron we don't need to create any new classes or static members, this one does the whole job via new maps within it. I like it as a generic backport pattern that could be reused.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The implementation could actually be a singular map to some "tuple" or struct of extra members, that is added and deleted atomically.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, OK. Thanks for the explanation. In that case, I'm fine with the name as-is. I'll just suggest you put some of that explanation there into a comment (either here in the .hpp or in the .cpp, I don't care which).

@emersonknapp emersonknapp marked this pull request as ready for review July 7, 2023 22:24
Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
@emersonknapp
Copy link
Collaborator Author

emersonknapp commented Jul 7, 2023

Pulls: ros2/rcl#1082, #2236, ros2/system_tests#521
Gist: https://gist.githubusercontent.com/emersonknapp/c9f2e76b044e7842b85a6ac7bb40dce3/raw/54f8236b734b80bddc3b50b3786083c2304c3ebf/ros2.repos
BUILD args: --packages-above-and-dependencies rclcpp rclcpp_lifecycle test_rclcpp
TEST args: --packages-above rclcpp rclcpp_lifecycle test_rclcpp
ROS Distro: iron
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/12350

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status
    • Build Status (manual rerun, flaky check)

Copy link
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

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

I've left only nitpicky stuff that we should fix before merging.

@@ -1591,6 +1597,9 @@ class Node : public std::enable_shared_from_this<Node>
const rclcpp::NodeOptions node_options_;
const std::string sub_namespace_;
const std::string effective_namespace_;

class BackportMemberMaps;
Copy link
Contributor

Choose a reason for hiding this comment

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

At the risk of bikeshedding, I think the name is a little too generic. That is, the class embeds a

std::unordered_map<
    const Node *, rclcpp::node_interfaces::NodeTypeDescriptionsInterface::SharedPtr
  > type_descriptions_map_;

which feels very specific to this backport. I think I'd go with BackportTypeDescriptionsInterface, or something like that.

void add(Node * key)
{
// Adding a new instance to the maps requires exclusive access
std::unique_lock lock(map_access_mutex_);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: #include <mutex> at the top of the file for this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a really good eye you have for these - do you know of any include-what-you-use linters that could handle this so you don't have to?

Copy link
Contributor

Choose a reason for hiding this comment

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

There is iwyu: https://include-what-you-use.org/ . It's even packaged for Ubuntu under the same name. The major issue with it (from an automation standpoint) is that it relies on clang, so we could only conceivably run it in our clang CI jobs.

Copy link
Member

Choose a reason for hiding this comment

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

I'm surprised that cpplint.py doesn't catch this, it used to catch things like this. Maybe its coverage is just not as good.

rclcpp/src/rclcpp/node.cpp Show resolved Hide resolved
rclcpp/src/rclcpp/node.cpp Show resolved Hide resolved
Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
Copy link
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

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

One more minor thing to fix, then this will be good to go.

@@ -1591,6 +1597,9 @@ class Node : public std::enable_shared_from_this<Node>
const rclcpp::NodeOptions node_options_;
const std::string sub_namespace_;
const std::string effective_namespace_;

class BackportMemberMaps;
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, OK. Thanks for the explanation. In that case, I'm fine with the name as-is. I'll just suggest you put some of that explanation there into a comment (either here in the .hpp or in the .cpp, I don't care which).

Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
Copy link
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

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

This looks good to me.

@emersonknapp With this approved, I think that is everything needed for the Iron backport. I think I'd like to see one more CI run on all 5 of the PRs here. Assuming that is green, I'll go ahead and merge the group of them.

Copy link
Member

@wjwwood wjwwood left a comment

Choose a reason for hiding this comment

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

lgtm from an ABI/API stability point of view

@emersonknapp
Copy link
Collaborator Author

emersonknapp commented Jul 17, 2023

@clalancette clalancette merged commit 6d4a99f into ros2:iron Jul 18, 2023
nachovizzo pushed a commit to nachovizzo/rclcpp that referenced this pull request Oct 3, 2023
…tTypeDescription service (backport ros2#2224) (ros2#2236)

* Add new node interface TypeDescriptionsInterface to provide GetTypeDescription service (ros2#2224)

* TypeDescriptions interface with readonly param configuration

* Add parameter descriptor, to make read only

* example of spinning in thread for get_type_description service

* Add a basic test for the new interface

* Fix tests with new parameter

* Add comments about builtin parameters

* Hide new member for ABI stability

* Add typedescription interface smoke test

Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
Signed-off-by: William Woodall <william@osrfoundation.org>
Signed-off-by: Ignacio Vizzo <ignacio@dexory.com>
nightduck pushed a commit to nightduck/rclcpp that referenced this pull request Jan 25, 2024
…tTypeDescription service (backport ros2#2224) (ros2#2236)

* Add new node interface TypeDescriptionsInterface to provide GetTypeDescription service (ros2#2224)

* TypeDescriptions interface with readonly param configuration

* Add parameter descriptor, to make read only

* example of spinning in thread for get_type_description service

* Add a basic test for the new interface

* Fix tests with new parameter

* Add comments about builtin parameters

* Hide new member for ABI stability

* Add typedescription interface smoke test

Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
Signed-off-by: William Woodall <william@osrfoundation.org>
nightduck pushed a commit to nightduck/rclcpp that referenced this pull request Jan 25, 2024
…tTypeDescription service (backport ros2#2224) (ros2#2236)

* Add new node interface TypeDescriptionsInterface to provide GetTypeDescription service (ros2#2224)

* TypeDescriptions interface with readonly param configuration

* Add parameter descriptor, to make read only

* example of spinning in thread for get_type_description service

* Add a basic test for the new interface

* Fix tests with new parameter

* Add comments about builtin parameters

* Hide new member for ABI stability

* Add typedescription interface smoke test

Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
Signed-off-by: William Woodall <william@osrfoundation.org>
Signed-off-by: Oren Bell <oren.bell@wustl.edu>
nightduck pushed a commit to nightduck/rclcpp that referenced this pull request Jan 25, 2024
…tTypeDescription service (backport ros2#2224) (ros2#2236)

* Add new node interface TypeDescriptionsInterface to provide GetTypeDescription service (ros2#2224)

* TypeDescriptions interface with readonly param configuration

* Add parameter descriptor, to make read only

* example of spinning in thread for get_type_description service

* Add a basic test for the new interface

* Fix tests with new parameter

* Add comments about builtin parameters

* Hide new member for ABI stability

* Add typedescription interface smoke test

Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
Signed-off-by: William Woodall <william@osrfoundation.org>
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