This repo is not officially Beckhoff. If you do need further help with TwinCAT, please contact your local Beckhoff Subsidiary/Representatives.
This is a fork of the example docker container from Beckhoff's repo.
This version now implements a ROS2 node to control a Dobot CR3, while using a PyADS node to poll TwinCAT XAR running locally to send certain commands.
Before you start with the sample, ensure that you have fullfill the follwoing requirements: - Setup and Install the Beckhoff Real-Time Linux® Distribution on a supported ePC/IPC - Configure the package server - Install TwinCAT - Install Docker Engine on Debian - Install make via sudo apt install make With the requirements set, simply follow these steps:
-
Add/Update StaticRoutes.xml of TwinCAT on the Host machine:
/etc/TwinCAT/3.1/Target -
Build the container image via :
sudo make build-image- Start up the container:
sudo docker run -it --rm --network host --entrypoint /bin/bash tc31-xar-base- Open second terminal and search for the container's ID:
sudo docker container -ls- The run the following:
docker exec -u root -t -i <container_id> /bin/bashsource install/setup.bashros2 launch dobot_bringup_v3 dobot_bringup_ros2.launch.py- Open a third terminal and run:
docker exec -u root -t -i <container_id> /bin/bashsource install/setup.bash
ros2 run py_srvcli client
The repository is organized as follows:
- Dockerfile: the dockerfile that is used to create the image used in this example project
- docker-compose.yaml: Sample to define the run configuration for the containers.
- Makefile: Used to simplify and automate common Docker tasks.
- StaticRoutes.xml: A sample of what the StaticRoutes file should look like within TwinCAT directory as you have to manually add a route for PyADS node to communicate with the TwinCAT XAR.
- tc31-xar-base/: Contains all required files to build a Docker image for a TwinCAT 3.1 XAR
environment
- apt-config/
- bhf.conf: Template for authentication against beckhoff.com package server
- bhf.list: apt source list sample for Beckhoff package repo
- debian.sources.list: apt source list for Beckhoff Debian mirror
- apt-config/
- py_srvcli/: Contains all required files to build a Docker image for ROS2 and PyADS.
- setup.py: python programmed that is used to create the py_srvcli package and which python programs to be included
- setup.cfg:
- package.xml:
- CMake.txt:
- py_srvcli/:
- TwinCAT_Add_Route.py: a python program containing functions for connecting to the TwinCAT Runtime
- client_member_function.py: a python programmed that was created from ROS2 Humble example for services and clients
- resource/:
- com_comfig.yaml: file containing Username, password, and IP/AmsNetID addresses that are used to make a connection to the TwinCAT Runtime. This needs to be altered per sample to meet your local IP range and AmsNetIDs
- variables.yaml: file containing variables and the path to find the associate variables in the TwinCAT Runtime and associate service in the ROS2 node
The Makefile in this repository is used to simplify and automate common Docker tasks in this sample.
It includes the following targets:
build-image: Builds the Docker image using the Dockerfile located in thetc31-xar-basedirectory.push-image: Pushes the built Docker image to a specified Docker registry.run-containers: Starts the containers defined in thedocker-compose.yamlfile.list-containers: Lists the running containers managed by Docker Compose.stop-and-remove-containers: Stops and removes all containers defined in thedocker-compose.yamlfile.container-logs: Displays the logs of the running containers.
The Makefile uses variables to define the image name, tag, and registry, allowing for easy customization.
You can install make on your host via:
sudo apt install make
Afterwards you can use the Makefile for building the image.
sudo make build-image
Alternatively, navigate to tc31-xar-base of the repository and run the following command:
sudo docker build --network host -t tc31-xar-base .