|
| 1 | +.. _ursim_docker: |
| 2 | + |
| 3 | +Setup URSim with Docker |
| 4 | +======================= |
| 5 | +URSim is the offline simulator by Universal Robots. Packed into a remote or virtual machine it acts almost |
| 6 | +identically to a real robot connected over the network. While it is possible to get URSim running |
| 7 | +locally on a Linux system or inside a VirtualBox virtual machine, we will focus on getting things |
| 8 | +setup using Docker. Using Docker for your simulated robot allows you to very quickly spin up a robot |
| 9 | +testing instance with very little computational overload. |
| 10 | + |
| 11 | +This guide will assume that you have Docker already installed and setup such that you can startup |
| 12 | +Docker containers using your current user. |
| 13 | + |
| 14 | +Start a URSim docker container |
| 15 | +------------------------------ |
| 16 | + |
| 17 | +To startup a simulated robot run the following command. This will start a Docker container named |
| 18 | +``ursim`` and startup a simulated UR5e robot. It exposes ports 5900 and 6080 for the browser-based |
| 19 | +polyscope access. Note that this will expose the simulated robot to your local area network if you |
| 20 | +don't have any further level of security such as a firewall active. To prevent this, you can either |
| 21 | +skip the port forwarding instructions (skip the two ``-p port:port`` statements) in which case |
| 22 | +you'll have to use the container's IP address to access the polyscope gui rather than ``localhost`` or |
| 23 | +you can restrict the port forwarding to a certain network interface (such as the looppack interface) |
| 24 | +see Docker's upstream documentation on port exposure for further information. |
| 25 | + |
| 26 | +.. code-block:: bash |
| 27 | +
|
| 28 | + docker run --rm -it -p 5900:5900 -p 6080:6080 --name ursim universalrobots/ursim_e-series |
| 29 | +
|
| 30 | +External Control |
| 31 | +---------------- |
| 32 | + |
| 33 | +To use the external control functionality, we will need the ``external_control`` URCap installed on |
| 34 | +the robot and a program containing its *ExternalControl* program node. Both can be prepared on the |
| 35 | +host machine either by creating an own Dockerfile containing those or by mounting two folders |
| 36 | +containing installed URCaps and programs. See the Dockerfile's upstream `documentation <https://hub.docker.com/r/universalrobots/ursim_e-series>`_. |
| 37 | + |
| 38 | +In this example, we will bind-mount a folder for the programs and URCaps. First, let's create a |
| 39 | +local folder where we can store things inside: |
| 40 | + |
| 41 | +.. code-block:: bash |
| 42 | +
|
| 43 | + mkdir -p ${HOME}/.ursim/programs |
| 44 | + mkdir -p ${HOME}/.ursim/urcaps |
| 45 | +
|
| 46 | +Then, we can "install" the URCap by placing its ``.jar`` file inside the urcaps folder |
| 47 | + |
| 48 | +.. code-block:: bash |
| 49 | +
|
| 50 | + URCAP_VERSION=1.0.5 # latest version as if writing this |
| 51 | + curl -L -o ${HOME}/.ursim/urcaps/externalcontrol-${URCAP_VERSION}.jar \ |
| 52 | + https://github.com/UniversalRobots/Universal_Robots_ExternalControl_URCap/releases/download/v${URCAP_VERSION}/externalcontrol-${URCAP_VERSION}.jar |
| 53 | +
|
| 54 | +With this, start your URSim containers with the following command: |
| 55 | + |
| 56 | +.. code-block:: bash |
| 57 | +
|
| 58 | + docker run --rm -it -p 5900:5900 -p 6080:6080 -v ${HOME}/.ursim/urcaps:/urcaps -v ${HOME}/.ursim/programs:/ursim/programs --name ursim universalrobots/ursim_e-series |
| 59 | +
|
| 60 | +With this, you should be able to setup the ``external_control`` URCap and create a program as |
| 61 | +described in :ref:`URCap setup guide <install-urcap-e-series>`. |
| 62 | + |
| 63 | +Network setup |
| 64 | +------------- |
| 65 | + |
| 66 | +As described above, you can always start the URSim container using the default network setup. As long |
| 67 | +as you don't have any other docker containers running, it will most probably always get the same IP |
| 68 | +address assigned every time. However, to make things a bit more explicit, we can setup our own |
| 69 | +docker network where we can assign a static IP address to our URSim container. |
| 70 | + |
| 71 | +.. code-block:: bash |
| 72 | +
|
| 73 | + docker network create --subnet=192.168.56.0/24 ursim_net |
| 74 | + docker run --rm -it -p 5900:5900 -p 6080:6080 --net ursim_net --ip 192.168.56.101 universalrobots/ursim_e-series |
| 75 | +
|
| 76 | +The above commands first create a network for docker and then create a container with the URSim |
| 77 | +image attaching to this network. |
| 78 | + |
| 79 | +As we now have a fixed IP address we can also skip the port exposure as we know the robot's IP |
| 80 | +address. The VNC web server will be available at `<http://192.168.56.101:6080/vnc.html>`_ |
| 81 | + |
| 82 | +Script startup |
| 83 | +-------------- |
| 84 | + |
| 85 | +All of the above is put together in a script in the ``ur_client_library`` package. |
| 86 | + |
| 87 | +.. tabs:: |
| 88 | + |
| 89 | + |
| 90 | + .. tab:: ROS 1 |
| 91 | + |
| 92 | + .. code-block:: bash |
| 93 | + |
| 94 | + rosrun ur_client_library start_ursim.sh |
| 95 | + |
| 96 | + This will start a URSim docker container running on ``192.168.56.101`` with the ``external_control`` |
| 97 | + URCap preinstalled. Created programs and installation changes will be stored persistently inside |
| 98 | + ``${HOME}/.ursim/programs``. |
| 99 | + |
| 100 | + With this, you can run |
| 101 | + |
| 102 | + .. code-block:: bash |
| 103 | + |
| 104 | + roslaunch ur_robot_driver ur5e_bringup.launch robot_ip:=192.168.56.101 |
| 105 | +
|
| 106 | + .. tab:: ROS 2 |
| 107 | + |
| 108 | + .. code-block:: bash |
| 109 | + |
| 110 | + ros2 run ur_client_library start_ursim.sh |
| 111 | + |
| 112 | + This will start a URSim docker container running on ``192.168.56.101`` with the ``external_control`` |
| 113 | + URCap preinstalled. Created programs and installation changes will be stored persistently inside |
| 114 | + ``${HOME}/.ursim/programs``. |
| 115 | + |
| 116 | + With this, you can run |
| 117 | + |
| 118 | + .. code-block:: bash |
| 119 | + |
| 120 | + ros2 launch ur_robot_driver ur_control.launch.py ur_type:=ur5e robot_ip:=192.168.56.101 |
| 121 | +
|
| 122 | + .. tab:: Other |
| 123 | + |
| 124 | + If you have installed the client library from another source than ROS / ROS 2 or have |
| 125 | + compiled it yourself, run the ``start_ursim.sh`` script directly from the package's |
| 126 | + ``scripts`` folder. |
0 commit comments