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

Demo nodes for raw publish and subscribe #185

Merged
merged 21 commits into from
Jun 16, 2018
Merged

Demo nodes for raw publish and subscribe #185

merged 21 commits into from
Jun 16, 2018

Conversation

Karsten1987
Copy link
Contributor

@Karsten1987 Karsten1987 commented Oct 23, 2017

I am making this the top level PR to gather all related PRs. This is WIP but as it affects basically all packages down the stack, I open this PR for early visibility.

This PR (and all others) aim to expose the raw CDR stream through the ROS2 API. This enables to send a raw data stream directly to the wire and in return take the data without going through the serialization process.
This ultimately serves as the base for a future upcoming ROSbag implementation.

while (rclcpp::ok()) {
sprintf(raw_msg.buffer, "%c%c%c%c%c%c%c%c%s %d",
0x00, 0x01, 0x00, 0x00, 0x0f, 0x00, 0x00,0x00, "hello world", (++i));
std::cout << "Publishing: '" << raw_msg.buffer << "'" << std::endl;
Copy link
Member

Choose a reason for hiding this comment

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

Use printf.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

copied from the existing talker example. It's outside of this PR, but I'll update the talker code accordingly.

Copy link
Member

Choose a reason for hiding this comment

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

The other demo code will be updated to use logging pretty soon so I think it's fine to just use printf in the new code without modifying existing one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mikaelarguedas Just saw your comment. I'll rebase accordingly if necessary.

@@ -57,7 +57,7 @@ int main(int argc, char * argv[])

while (rclcpp::ok()) {
msg->data = "Hello World: " + std::to_string(i++);
std::cout << "Publishing: '" << msg->data << "'" << std::endl;
printf("Publishing: %s\n", msg->data.c_str());
Copy link
Member

Choose a reason for hiding this comment

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

If we modify this in this PR, it needs to print the exacte same message as before (with single quotes around the data). Otherwise the tests will fail because they expect them:

Publishing: 'Hello World: 1'

@Karsten1987
Copy link
Contributor Author

I think this is up for review.

As I believe this is a quite huge PR, I'll explain the details on each referenced PR if necessary.

CI:
linux: Build Status
osx: Build Status
win: Build Status (unrelated)

@Karsten1987 Karsten1987 added in review Waiting for review (Kanban column) and removed in progress Actively being worked on (Kanban column) labels Mar 6, 2018
@@ -0,0 +1,95 @@
// Copyright 2014 Open Source Robotics Foundation, Inc.
Copy link
Member

Choose a reason for hiding this comment

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

This file is copyright 2014 but the talker is 2017, so is this one a copy of another and the talker is not or...?

[this]() -> void
{
rcutils_snprintf(raw_msg_.buffer, raw_msg_.buffer_length, "%c%c%c%c%c%c%c%c%s %zu",
0x00, 0x01, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, "Hello World:", (count_++));
Copy link
Member

Choose a reason for hiding this comment

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

I think this deverse a comment explaining that this is basically manual serialization of a string to CDR, and/or a TODO to replace this with a call to the serialization API which is forthcoming (I assume).

Copy link
Member

Choose a reason for hiding this comment

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

Also, the () around count++ are redundant.

: Node("raw_talker")
{
raw_msg_.buffer_length = 24;
raw_msg_.buffer = new char[raw_msg_.buffer_length];
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be deleted in the destructor of the class.

Copy link
Member

Choose a reason for hiding this comment

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

While the delete in the destructor is sufficient for the demo code to be "correct" I would suggest to use a smart pointer. Otherwise this might encourage people to copy-n-paste this code which is "incomplete" without a copy constructor and assignment operator.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agreed, a smart pointer would be nice, but I don't think it's more user friendly. I would rather say it's even more error prone to make copy-paste mistakes as you can't simply instantiate a shared ptr with that c-struct. You have to pass a custom deleter function / callable object with the smart pointer to clean up correctly. Does this make sense?

Copy link
Member

Choose a reason for hiding this comment

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

A std::unique_ptr is specialized for arrays and should be fine to use (as of C++11) without a custom deleter afaik (see http://en.cppreference.com/w/cpp/memory/unique_ptr).

@wjwwood
Copy link
Member

wjwwood commented Mar 21, 2018

@Karsten1987 Should/can this be put into "in progress"? I have outstanding comments in ros2/rmw_fastrtps#186 and ros2/rmw_connext#259 (at least I think so) and this has stayed in review for several days. It would help me to put it in progress until issues are addressed so that I don't have to reevaluate its state each time I go through waffle to check for needed reviews.

@mikaelarguedas mikaelarguedas added in progress Actively being worked on (Kanban column) and removed in review Waiting for review (Kanban column) labels Mar 22, 2018
@wjwwood wjwwood added in review Waiting for review (Kanban column) and removed in progress Actively being worked on (Kanban column) labels Jun 14, 2018
@dhood dhood added the in progress Actively being worked on (Kanban column) label Jun 14, 2018
@clalancette clalancette removed the in review Waiting for review (Kanban column) label Jun 14, 2018
@wjwwood wjwwood removed their assignment Jun 14, 2018
@wjwwood wjwwood added in review Waiting for review (Kanban column) and removed in progress Actively being worked on (Kanban column) labels Jun 14, 2018
@wjwwood
Copy link
Member

wjwwood commented Jun 15, 2018

I've re-reviewed all the pull requests and so here's some CI:

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

@Karsten1987
Copy link
Contributor Author

linux: Build Status
osx: Build Status
aarch: Build Status
win: Build Status

I further opened a PR against rmw_opensplice_cpp which implements the missing functions and sets the error message accordingly when calling them.

@wjwwood
Copy link
Member

wjwwood commented Jun 15, 2018

Rerun of Windows CI after ros2/rmw_connext@8eaeb9e: Build Status

@wjwwood
Copy link
Member

wjwwood commented Jun 16, 2018

Rerun of Windows CI after ros2/rmw_connext@f778624: Build Status

@wjwwood
Copy link
Member

wjwwood commented Jun 16, 2018

Rerun of Windows CI after ros2/rmw_connext@27cd763: Build Status

@Karsten1987 Karsten1987 merged commit b026e52 into master Jun 16, 2018
@dirk-thomas dirk-thomas removed the in review Waiting for review (Kanban column) label Jun 16, 2018
@Karsten1987 Karsten1987 deleted the expose_cdr branch June 16, 2018 08:37
@Karsten1987
Copy link
Contributor Author

So I merged this!
Thanks @wjwwood for finishing up the last hiccup on Windows! Appreciated!

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.

None yet

8 participants