Skip to content

Commit

Permalink
support compressed transport, update docs (#13)
Browse files Browse the repository at this point in the history
* galactic is EOL, update to Iron in README
* parameter name is image_transport, no underscore
* update subscriber example to actually support image_transport
  • Loading branch information
mikeferguson authored Feb 3, 2024
1 parent 99e6982 commit 77fa02f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
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

0 comments on commit 77fa02f

Please sign in to comment.