backgound
previously, we had integrated ads ros nodes into one launch file. now we try to put ads nodes into docker, and talk to lgsvl simulator in another docker.
run dockerimage
|
|
unable to run cakin_make in dockerfile
|
|
ros envs
set ROS_IP
on all involved containers to their IP, and set ROS_MASTER_URI
to the IP of the roscore container. That would avoid the DNS problem. understand ros environment variables
$ROS_ROOT : set the location whre the ROS core packages are installed
$ROS_MASTER_URI : a required setting that tells nodes where they can locate the master
$ROS_IP or $ROS_HOSTNAME : sets the declared network address of a ROS node
get docker container’s IP
docker inspect -f "{{ .NetworkSettings.Networks..IPAddress }}" <container_name||container_id>
tips, network_name: e.g. host, bridge, ingress e.t.c.
with docker host net, then the container doesn’t have its own IP address allocated, but the application is available on the host’s IP address with customized port.
run roscore in docker and talk to rosnodes at host
start roscore from docker container as following :
sudo docker run -it –net host ads_ros /bin/bash
roscorestart other ros nodes at host
|
|
then access webUI in host machine, and add host: 10.20.181.132
in Clusters
page, and add 10.20.181.132:9090
for Selected Vehicles. as lgsvl is also in host network
. so these two docker can communicate through ros well !!
ads ros container talk to lgsvl container with ROS_IP
since lgsvl will run in docker swarm env, we can’t depend on host network
, which requires ROS_IP env. the following test is in one host machine.
- in host terminal
|
|
actually, the host terminal can talk to the ads ros container directly, with no need to set $ROS_HOSTNAME
& $ROS_MASTER_URI
specially; as well as another docker container in this host machine, e.g. lgsvl.
a little bit knowledge about docker network. so each docker container does have an virtual IP, e.g. 172.17.0.1. while if run the docker image with host network
, there is no special container IP, but the container directly share the IP of the host machine. as multi docker containers run in the same host machine, even without host network
, they are in the same network range, so they can communicate to each other. additionaly for ros_master
, which may requires to add $ROS_HOSTNAME
& $ROS_MASTER_URI
.
- start lgsvl in another docker
|
|
in summary
so far, we have host ads ros in one docker, and lgsvl in another docker, and they are in the same machine, and they can talk to each other. the next thing is to put ads ros and lgsvl in one image.
refer
docker 1.10 container’s IP in LAN
listening to ROS messages in docker containers
exposing ROS containers to host machine