Required setup : Ubuntu 22.04 LTS
The proposed development builds upon the IgH EtherCAT Master. Installation steps are summarized here:
-
Install required tools:
$ sudo apt-get update $ sudo apt-get upgrade $ sudo apt-get install git autoconf libtool pkg-config make build-essential net-tools
-
Setup sources for the EtherCAT Master:
$ git clone https://gitlab.com/etherlab.org/ethercat.git $ cd ethercat $ git checkout stable-1.5 $ sudo rm /usr/bin/ethercat $ sudo rm /etc/init.d/ethercat $ ./bootstrap # to create the configure script
-
Configure, build and install libs and kernel modules:
$ ./configure --prefix=/usr/local/etherlab --disable-8139too --disable-eoe --enable-generic $ make all modules $ sudo make modules_install install $ sudo depmod
NOTE: This step is needed every time the Linux kernel is updated.
-
Configure system:
$ sudo ln -s /usr/local/etherlab/bin/ethercat /usr/bin/ $ sudo ln -s /usr/local/etherlab/etc/init.d/ethercat /etc/init.d/ethercat $ sudo mkdir -p /etc/sysconfig $ sudo cp /usr/local/etherlab/etc/sysconfig/ethercat /etc/sysconfig/ethercat
-
Create a new
udev
rule:$ sudo gedit /etc/udev/rules.d/99-EtherCAT.rules
containing:
KERNEL=="EtherCAT[0-9]*", MODE="0664"
-
Configure the network adapter for EtherCAT:
$ sudo gedit /etc/sysconfig/ethercat
In the configuration file specify the mac address of the network card to be used and its driver
MASTER0_DEVICE="ff:ff:ff:ff:ff:ff" # mac address DEVICE_MODULES="generic"
Now you can start the EtherCAT master:
$ sudo /etc/init.d/ethercat start
it should print
Starting EtherCAT master 1.5.2 done
You can check connected slaves:
$ ethercat slaves
It should print information of connected slave device:
<id> <alias>:<position> <device_state> + <device_name>
Example:
0 0:0 PREOP + <device_0_name>
0 0:1 PREOP + <device_1_name>
- Install
ros2
packages. The current development is based ofros2 humble
. Installation steps are described here. - Source your
ros2
environment:NOTE: The ros2 environment needs to be sources in every used terminal. If only one distribution of ros2 is used, it can be added to thesource /opt/ros/humble/setup.bash
~/.bashrc
file. - Install
colcon
and its extensions :sudo apt install python3-colcon-common-extensions
- Create a new ros2 workspace:
mkdir ~/ros2_ws/src
- Pull relevant packages, install dependencies, compile, and source the workspace by using:
cd ~/ros2_ws git clone https://github.com/ICube-Robotics/ethercat_driver_ros2.git src/ethercat_driver_ros2 rosdep install --ignore-src --from-paths . -y -r colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release --symlink-install source install/setup.bash