Skip to content

[pybind11] Node Accessors - #719

Merged
gbalke merged 6 commits into
ros2:masterfrom
gbalke:node_accessors
Mar 19, 2021
Merged

gbalke merged 6 commits into
ros2:masterfrom
gbalke:node_accessors

Conversation

@gbalke

@gbalke gbalke commented Mar 17, 2021

Copy link
Copy Markdown
Contributor

Part of #665.

@gbalke
gbalke requested review from hidmic and sloretz March 17, 2021 22:03
@gbalke gbalke self-assigned this Mar 17, 2021
Comment thread rclpy/src/rclpy/2 Resolved
Comment thread rclpy/src/rclpy/node.cpp Outdated

const char * node_name = rcl_node_get_name(node);
if (!node_name) {
return py::none();

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.

Huh, I see this is what the code was doing already, but it seems incorrect. It looks like when rcl_node_get_name fails it sets the error state, so returning None means the error state is still set. That's not a big problem, AFAIK it means it will print extra error messages the next time something tries to set the error state again.

I would recommend changing this API to throw RCLError instead of returning None. That means the return type could be const char * too (IIUC pybind11 will handle the conversion to a python string from that return type).

Comment thread rclpy/src/rclpy/node.cpp Outdated

const char * node_namespace = rcl_node_get_namespace(node);
if (!node_namespace) {
return py::none();

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.

Same comment about making this API throw RCLError here.

Comment thread rclpy/src/rclpy/node.hpp Outdated

#include <pybind11/pybind11.h>

#include <string>

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.

Unused header?

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 forgot to clean up headers after the copy/pasting. Sorry about that!

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.

Still unused?

Comment thread rclpy/src/rclpy/node.cpp Outdated

#include "rclpy_common/exceptions.hpp"

#include "names.hpp"

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.

I think this should be including "node.hpp"

Comment thread rclpy/src/rclpy/node.cpp Outdated
#include <rmw/error_handling.h>
#include <rmw/validate_full_topic_name.h>
#include <rmw/validate_namespace.h>
#include <rmw/validate_node_name.h>

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.

It seems like there are a lot of unused headers here. I see reason for:

  • pybind11/pybind11.h for all the py:: stuff
  • rcl/node.h for rcl_node_t, rcl_node_get_name(), rcl_node_get_namespace()
  • rclpy_common/handle.h for the `rclpy_handle_get_pointer_from_capsule

And if you change the code to throw RCLError instead: "rclpy_common/exceptions.hpp"

But if you don't change it and instead just want to clear the error state: "rcl/error_handling.h"

I'm pretty sure the rest are unused.

@sloretz sloretz mentioned this pull request Mar 17, 2021
32 of 34 tasks
Greg Balke added 2 commits March 18, 2021 12:41
Signed-off-by: Greg Balke <[email protected]>

@hidmic hidmic left a comment

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.

Overall LGTM pending green CI

Comment thread rclpy/src/rclpy/node.hpp Outdated

#include <pybind11/pybind11.h>

#include <string>

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.

Still unused?

@gbalke

gbalke commented Mar 19, 2021

Copy link
Copy Markdown
Contributor Author

CI up to rclpy:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@gbalke
gbalke requested a review from sloretz March 19, 2021 23:26
@gbalke
gbalke merged commit 3edc15b into ros2:master Mar 19, 2021
@gbalke
gbalke deleted the node_accessors branch March 19, 2021 23:36
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