This URCap allows you to send script code to the robot, and is primarily meant for connecting the robot to the Universal ROS/ROS2 driver, Isaac Sim driver, and the Universal Robots Client Library.
In order to build and deploy this sample, use the commands below. A rebuild of the project is required to see any changes made to the source code. If you are deploying the URCap to URSim, ensure that you have started the simulator.
Run this command to install the dependencies of the project.
npm install
Run this command to build the contribution type.
npm run build
Run this command to install the built URCap to the simulator.
npm run install-urcap
Run this command to install the built URCap to the robot.
npm run install-urcap -- --host <robot_ip_address>
This URCap uses a Flask framework to run a REST server on port 5000.
Having built and installed the URCap in the simulator you can open your terminal to see the output from the backend:
docker exec -it ursim-polyscopex-runtime-1 bash
You can find more documentation on the docker exec
functionality here.
Your terminal prompt should have switched from psxdev@<vsc_container_id>:/pwd/$
to <ursim_container_id>:/pwd/#
, meaning you can now execute commands within your simulator docker container.
List the active docker containers with
docker ps
View the backend output by using the container ID associated with the universal-robots_external-control_external-control-backend
image (e.g. 8e3)
docker logs -f <container_id>
The frontend contribution is built in Angular using no external libraries.
The application node contains two input fields. Enter your computer host IP address and desired port into the corresponding fields and press the confirm button. These fields will dictate the REST endpoint used to retrieve the robot program.
The program node will reflect the computer host IP address and socket port that was entered in the application node. If you make any changes to the program externally, you will need to press the "Update program" button.
When the update program button is pressed, you will see a new fetch call in the network section of the browser inspector. You can see the script code being sent to the robot in the response section of the fetch response. When the program is played, the robot will execute the script code.
This section will explain which networks to use in order to connect URSim to a ROS/ROS2 driver Docker container with the External Control URCap.
In order to find the IP address of the URSim, run
docker inspect ursim-polyscopex-runtime-1 bash
Look at the Networks section of the output. It shoudl look something like this
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"MacAddress": "02:42:c0:a8:d7:03",
"NetworkID": "1125e40f93f2506020d7191589013c7b286467afaf82a03e82f28c5ac05ce794",
"EndpointID": "e7b0ca51f027950aab1df40669b946b5815e9553cd83228ea4038633d76e36e8",
"Gateway": "192.168.215.1",
"IPAddress": "192.168.215.3",
"IPPrefixLen": 24,
"IPv6Gateway": "fd07:b51a:cc66:1::1",
"GlobalIPv6Address": "fd07:b51a:cc66:1:0:242:c0a8:d703",
"GlobalIPv6PrefixLen": 64,
"DriverOpts": null,
"DNSNames": null
}
}
The IP address that you will use in your ROS/ROS2 driver is the IPAddress field. In this case, it would be 192.168.215.3
.
Use host.docker.internal
in the computer host IP address field in the Application Node of the URCap. Make sure that your driver container is run with this argument.
--network="host"