ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

ROS in Docker: messaging with host PC

asked 2022-12-13 09:30:03 -0500

akim gravatar image

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

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-12-20 03:03:20 -0500

akim gravatar image

So I figured out it was my dumb mistake
I was following these instructions, but, apparently, I somehow skipped step (3) and didn't activate group changes. Now when I did, everything seems to work

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2022-12-13 09:30:03 -0500

Seen: 105 times

Last updated: Dec 20 '22