Hi!
I would like to know how to set up connection between ROS in Docker with ROS on host PC correctly.
Following some answers like these [1][2] I can understand that connecting container to host network and exporting proper environmental variables should be enough.
However, when I try pub/echo between container and host PC, I get no response
Here is how I start everything:
On host PC I have the following in my .bashrc:
ROS_HOSTNAME=192.168.1.1
ROS_MASTER_URI=http://192.168.1.1:11311/
ROS_IP=192.168.1.1
Then I start roscore
in the first terminal. In the second terminal I run:
docker run --net=host --name ros-test -it --rm osrf/ros:noetic-desktop
And in the resulting second terminal I export the same environmental variables as shown above. Then I inspect available topics with rostopic list
and can see default topics when roscore in running:
/rosout
/rosout_agg
Then in the third terminal from host PC I try simple publish command:
rostopic pub -r 1 /test std_msgs/String "halo"
Then try to receive messages in the container which is the second terminal: rostopic echo /test
I expect to receive messages, but there is nothing coming. When I do rostopic hz /test
, it says "no new messages"
When I check rostopic info /test
from fourth terminal I get the folllowing:
Type: std_msgs/String
Publishers:
- /rostopic_178825_1670943581897 (http://risc-SYS-5049A-TR:33815/)
Subscribers: - /rostopic_111_1670945011845 (http://docker-desktop:57739/)
With publisher being my third terminal and subscriber being my second terminal which is container
Is there something wrong with how I am doing things? Please advise or help
Originally posted by akim on ROS Answers with karma: 11 on 2022-12-13
Post score: 1