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

support compressed transport, update docs #13

Merged
merged 1 commit into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ Install needed dependencies:

```
$ cd ~/image_transport_tutorials_ws/
$ source /opt/ros/galactic/setup.bash
$ rosdep install -i --from-path src --rosdistro galactic -y
$ source /opt/ros/iron/setup.bash
$ rosdep install -i --from-path src --rosdistro iron -y
$ colcon build
```

Make sure to include the correct setup file (in the above example it is for Galactic on Ubuntu and for bash).
Make sure to include the correct setup file (in the above example it is for Iron on Ubuntu and for bash).

## Writing a Simple Image Publisher (C++)
Description: This tutorial shows how to create a publisher node that will continually publish an image.
Expand Down Expand Up @@ -239,13 +239,13 @@ Notice that `compressed_image_transport` is not a dependency of your package; `i
The easiest way to add the "compressed" transport is to install the package:

```
$ sudo apt-get install ros-galactic-compressed-image-transport
$ sudo apt-get install ros-iron-compressed-image-transport
```

Or install all the transport plugins at once:

```
$ sudo apt-get install ros-galactic-image-transport-plugins
$ sudo apt-get install ros-iron-image-transport-plugins
```

But you can also build from source.
Expand All @@ -256,7 +256,7 @@ The key is that `image_transport` subscribers check the parameter `_image_transp
Let's set this parameter and start a subscriber node with name "compressed_listener":

```
$ ros2 run image_transport_tutorials my_subscriber --ros-args --remap __name:=compressed_listener -p _image_transport:=compressed
$ ros2 run image_transport_tutorials my_subscriber --ros-args --remap __name:=compressed_listener -p image_transport:=compressed
```

You should see an identical image window pop up.
Expand Down
5 changes: 4 additions & 1 deletion src/my_subscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ int main(int argc, char ** argv)
rclcpp::init(argc, argv);
rclcpp::NodeOptions options;
rclcpp::Node::SharedPtr node = rclcpp::Node::make_shared("image_listener", options);
// TransportHints does not actually declare the parameter
node->declare_parameter<std::string>("image_transport", "raw");
cv::namedWindow("view");
cv::startWindowThread();
image_transport::ImageTransport it(node);
image_transport::Subscriber sub = it.subscribe("camera/image", 1, imageCallback);
image_transport::TransportHints hints(node.get());
image_transport::Subscriber sub = it.subscribe("camera/image", 1, imageCallback, &hints);
rclcpp::spin(node);
cv::destroyWindow("view");

Expand Down
Loading