Skip to content

Commit 77fa02f

Browse files
authored
support compressed transport, update docs (#13)
* galactic is EOL, update to Iron in README * parameter name is image_transport, no underscore * update subscriber example to actually support image_transport
1 parent 99e6982 commit 77fa02f

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ Install needed dependencies:
1212

1313
```
1414
$ cd ~/image_transport_tutorials_ws/
15-
$ source /opt/ros/galactic/setup.bash
16-
$ rosdep install -i --from-path src --rosdistro galactic -y
15+
$ source /opt/ros/iron/setup.bash
16+
$ rosdep install -i --from-path src --rosdistro iron -y
1717
$ colcon build
1818
```
1919

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

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

241241
```
242-
$ sudo apt-get install ros-galactic-compressed-image-transport
242+
$ sudo apt-get install ros-iron-compressed-image-transport
243243
```
244244

245245
Or install all the transport plugins at once:
246246

247247
```
248-
$ sudo apt-get install ros-galactic-image-transport-plugins
248+
$ sudo apt-get install ros-iron-image-transport-plugins
249249
```
250250

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

258258
```
259-
$ ros2 run image_transport_tutorials my_subscriber --ros-args --remap __name:=compressed_listener -p _image_transport:=compressed
259+
$ ros2 run image_transport_tutorials my_subscriber --ros-args --remap __name:=compressed_listener -p image_transport:=compressed
260260
```
261261

262262
You should see an identical image window pop up.

src/my_subscriber.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,13 @@ int main(int argc, char ** argv)
3535
rclcpp::init(argc, argv);
3636
rclcpp::NodeOptions options;
3737
rclcpp::Node::SharedPtr node = rclcpp::Node::make_shared("image_listener", options);
38+
// TransportHints does not actually declare the parameter
39+
node->declare_parameter<std::string>("image_transport", "raw");
3840
cv::namedWindow("view");
3941
cv::startWindowThread();
4042
image_transport::ImageTransport it(node);
41-
image_transport::Subscriber sub = it.subscribe("camera/image", 1, imageCallback);
43+
image_transport::TransportHints hints(node.get());
44+
image_transport::Subscriber sub = it.subscribe("camera/image", 1, imageCallback, &hints);
4245
rclcpp::spin(node);
4346
cv::destroyWindow("view");
4447

0 commit comments

Comments
 (0)