Skip to content

Conversation

@ivanpauno
Copy link
Member

@ivanpauno ivanpauno commented Jun 2, 2021

5007b22 fixes a bug.
90a4fc9 implements the compressing and decompressing modes.

There are a lot of things that could be improved but this is an okay first prototype.

e.g.:

# decompressing_bridge.yaml
name: decompressing_bridge
from_domain: 3
to_domain: 2
mode: decompress
topics:
  chatter:
    type: example_interfaces/msg/String
    qos:
      reliability: best_effort
# compressing_bridge.yaml
name: compressing_bridge
from_domain: 0
to_domain: 3
mode: compress
topics:
  chatter:
    type: example_interfaces/msg/String
    qos:
      reliability: best_effort

In one terminal:

ros2 run domain_bridge domain_bridge decompressing_bridge.yaml &
ros2 run domain_bridge domain_bridge compressing_bridge.yaml &
ros2 topic pub /chatter example_interfaces/msg/String "{data: asd}"

In another terminal:

ROS_DOMAIN_ID=2 ros2 topic echo /chatter

@ivanpauno
Copy link
Member Author

FYI @jacobperron

@clalancette
Copy link
Contributor

Just as a thought, it is probably worthwhile to look at the pluggable compression that rosbag2 has. It's probably overkill for right now, but it might a) allow you to have pluggable compression, and b) share some code with rosbag2.

@ivanpauno
Copy link
Member Author

Just as a thought, it is probably worthwhile to look at the pluggable compression that rosbag2 has. It's probably overkill for right now, but it might a) allow you to have pluggable compression, and b) share some code with rosbag2.

Yes, I actually copy-pasted part of the code from there.
I thought about using their compression plugins, but I found it easier to use zstd directly here for a first prototype.

@ivanpauno
Copy link
Member Author

I tried this with the pc_pipe demo, and the compression rate is pretty good.

Results using a 640x480 rgb image:

  • A 921600B image was compressed to 187077B (~1/5).
  • A 4915200B pointcloud to 297651B (~1/16).

That's a really promising bandwidth reduction.

@ivanpauno
Copy link
Member Author

I think that the bridge mode (compressing/decompressing/normal) could be specified per topic and not globally, once we merge this I'll work on improving that.

@ivanpauno
Copy link
Member Author

@jacobperron friendly ping, I think we should at least merge the first commit 5007b22.

Copy link
Member

@jacobperron jacobperron left a comment

Choose a reason for hiding this comment

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

The approach sounds good to me; relying on zstd directly and later we can consider a plugin-based approach.

I think that we should make the compression mode per topic (as you suggest), since it's at the topic-level where this compression is happening.

I'd also like to see the following:

  • Tests for the compression feature (to prevent regression)
  • Green CI (Gpr and Rpr jobs).
    • There's linter errors on Rolling
    • It looks like there's an rclcpp API being used that's not available in Galactic. Preferable we could workaround this so we don't need to branch, but it's not a blocker.

@jacobperron
Copy link
Member

@ivanpauno Submitting the bug fix as a separate PR would be nice, then we can merge that independently.

@ivanpauno
Copy link
Member Author

@ivanpauno Submitting the bug fix as a separate PR would be nice, then we can merge that independently.

Done, see #27.

@ivanpauno
Copy link
Member Author

There's linter errors on Rolling

Sorry, I forgot to check that. Fixed in ee83cad, 940dca3.

@ivanpauno
Copy link
Member Author

It looks like there's an rclcpp API being used that's not available in Galactic. Preferable we could workaround this so we don't need to branch, but it's not a blocker.

Fixed in ffef015, 53b0628.

@ivanpauno
Copy link
Member Author

Tests for the compression feature (to prevent regression)

I have refactored some of the existing tests in 7ce726e, to deduplicate code.
New tests were added in 6a438f3.

@ivanpauno
Copy link
Member Author

I think that we should make the compression mode per topic (as you suggest), since it's at the topic-level where this compression is happening.

I think that we can do that in a follow-up PR, IIUC the current plan was to compress of the traffic.

@ivanpauno
Copy link
Member Author

The Gpr branch is failing because main isn't compatible with galactic anymore (see #27).

@jacobperron
Copy link
Member

The Gpr branch is failing because main isn't compatible with galactic anymore (see #27).

I misunderstood the nature of #27. Is it possible we can keep the main branch compatible with Galactic if we factor out the generic pub/sub code (#28)? @rebecca-butler is taking a look at doing this right now.

@ivanpauno
Copy link
Member Author

ivanpauno commented Jun 16, 2021

I misunderstood the nature of #27. Is it possible we can keep the main branch compatible with Galactic if we factor out the generic pub/sub code (#28)?

I think so.
There will probably be some conflicts with this PR when we introduce the rclcpp generic pub/sub, as the generic pub/sub API changed a bit.

@jacobperron should we merge this as-is to avoid conflicts or do you prefer to first reintroduce compatibility with the galactic branch?

@ivanpauno
Copy link
Member Author

#29 reintroduces compatibility with galactic, I think we can merge that one first and then go ahead with this one.

@jacobperron
Copy link
Member

Now that #30 is merged. I'm hopeful that rebasing on main will resolve Galactic compatibility issues.

* Add domain_bridge/msg/CompressedMsg interface.
* Add compress and decompress mode to the bridge.
* Refactor existing tests to better reuse code.
* Add tests for compress and decompress modes.

Signed-off-by: Ivan Santiago Paunovic <[email protected]>
@ivanpauno ivanpauno force-pushed the ivanpauno/add-compressing-and-decompressing-modes branch from 6a438f3 to 4122e0b Compare June 17, 2021 22:05
@ivanpauno
Copy link
Member Author

Now that #30 is merged. I'm hopeful that rebasing on main will resolve Galactic compatibility issues.

Rebased.
The rebase wasn't as easy as I would've wanted, because either:

  • The API create a GenericPublisher isn't flexible enough.
  • PublisherBase doesn't have a method to publish serialized messages.

Either thing would have made this patch easier.

Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Copy link
Member

@jacobperron jacobperron left a comment

Choose a reason for hiding this comment

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

LGTM. I've left a few minor comments.

The rebase wasn't as easy as I would've wanted, because either:

The API create a GenericPublisher isn't flexible enough.
PublisherBase doesn't have a method to publish serialized messages.

That's too bad. I suppose we should support one of those options (or both) in rclcpp. If you agree, can you create an rclcpp ticket and reference it the code here as a comment? Thanks 🙇

{
public:
explicit ScopedAsyncSpinner(std::shared_ptr<rclcpp::Context> context)
: executor_{get_executor_options_with_context(std::move(context))},
Copy link
Member

Choose a reason for hiding this comment

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

Are the std:move calls necessary? It seems like the code would be more straightforward without them.

Copy link
Member Author

Choose a reason for hiding this comment

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

They aren't necessary, but it's cheaper to move a shared pointer passed by value than to copy it again.
(i.e. this is avoiding to increment the reference count and then decrement it again in the destructor of the context argument)

IMO this is the standard way of getting part ownership of a shared_ptr.

ivanpauno and others added 2 commits June 22, 2021 10:46
Signed-off-by: Ivan Santiago Paunovic <[email protected]>

Co-authored-by: Jacob Perron <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
@ivanpauno ivanpauno requested a review from jacobperron June 22, 2021 21:03
Copy link
Member

@jacobperron jacobperron left a comment

Choose a reason for hiding this comment

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

LGTM

@ivanpauno ivanpauno merged commit 1030a4a into ros2:main Jun 23, 2021
@ivanpauno ivanpauno deleted the ivanpauno/add-compressing-and-decompressing-modes branch June 23, 2021 14:14
@aprotyas aprotyas mentioned this pull request Oct 28, 2021
7 tasks
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