j3soon / ros2-essentials

A repo containing essential ROS2 (Humble) features for controlling Autonomous Mobile Robots (AMRs).
Apache License 2.0
7 stars 3 forks source link

Workspace with ROS1 bridge #9

Closed YuZhong-Chen closed 10 months ago

YuZhong-Chen commented 10 months ago

For the first issue, I attempted to reproduce it on my laptop, and it yielded the same result.

When I examined the communication between ros1 and ros1-bridge-ws, it appeared to be working fine. However, when I inspected the communication between ros2 and ros1-bridge-ws, I noticed that ros2 wasn't receiving messages from the ros1-bridge-ws.

This issue has puzzled me for quite some time, but I believe I've identified the problem.

As mentioned in https://github.com/eProsima/Fast-DDS/issues/1698#issuecomment-778039676, when you intend to use shared memory for communication between two containers, they should run with the same UID, which is typically 1000 in most cases. The problem arises from the fact that the ros2 container runs the talker node with root. Consequently, the ros1-bridge-ws can detect the presence of a topic but cannot receive messages due to the UID mismatch.

There are two possible solutions. The first is to run the ros1-bridge-ws with root, while the second is to run ros2 with UID 1000. I would recommend the latter option, as it aligns with the common practice of running nodes with UID 1000 in container, which is the same as the template-ws.

https://github.com/j3soon/ros2-agv-essentials/blob/d9992f0947dc77699999d1bc3af4e55f63308bbb/template_ws/docker/Dockerfile#L6-L19

YuZhong-Chen commented 10 months ago

For the second issue, to minimize the image size, I've only included the necessary executable files for the ros1-bridge. Consequently, tools such as ros2 topic or rostopic cannot be used in the release version.

If you intend to use any tools within the ros1-bridge-ws, it's essential to utilize the build stage, which corresponds to the ros1-bridge-build service in compose.debug.yaml.

YuZhong-Chen commented 10 months ago

By the way, the use of depends_on in Docker Compose is quite intriguing. I never thought it could be applied here.

Thanks for the insight! XD