Motion Master C++ application installation guide

The Synapticon Motion Master is an application that is used for communicating with Synapticon SOMANET devices over EtherCAT.

This tutorial describes the steps needed to install and use the Motion Master natively on a Linux client computer and shows how to build and run a simple C++ motion application.

Note

Please note that the Motion Master is for development purposes only and is not supported by Synapticon.

Prerequisites

In order to use the Motion Master and build its client applications, the development environment must be installed :

  • Docker CE : Installation guide for Ubuntu

  • Synapticon version of the Etherlab IgH EtherCAT master

    • The Synapticon repository provides a more detailed install script which includes the relevant libraries. Just do the following:

      1. Clone the repository
      2. Checkout the v1.5.2-sncn-7 tag
      3. Follow the Synapticon installation instructions in the INSTALL file
    • Documentation on how to use the IgH EtherCAT master can be found on http://www.etherlab.org.

for C++ for Pythonfor C++

In order for all of the required libraries to be built successfully, a GCC version 6 must be used. Newer Linux distributions usually have GCC version 7 installed (e.g. Ubuntu 18.04), but they also offer a native way of installing and using older versions. This is how it is done in Ubuntu for example, if GCC version 7 is already installed:

sudo apt update
sudo apt install gcc-6 g++-6
sudo update-alternatives --install "/usr/bin/gcc" "gcc" "/usr/bin/gcc-6" 60 --slave "/usr/bin/g++" "g++" "/usr/bin/g++-6"
sudo update-alternatives --install "/usr/bin/gcc" "gcc" "/usr/bin/gcc-7" 50 --slave "/usr/bin/g++" "g++" "/usr/bin/g++-7"
sudo update-alternatives --config gcc

At this point the required GCC version should be selected - GCC version 6 in this case

gcc --version
g++ --version

After the appropriate GCC version was selected, the required libraries can be built and installed:

  • ZeroMQ library (v4.2.1)
  • C++ binding for ZeroMQ (v4.2.1)
  • Google Protocol Buffers library (v3.4.1)

The instructions for installing the ZeroMQ library and the C++ binging for ZeroMQ can be found here and the instructions for installing the Google Protocol Buffers can be found here

Important

It is very important to use the exact same library versions that have been specified above.

for Python

The Motion Master Python client applications require Python version 2 to be installed, as well as several libraries:

  • python2
sudo apt install python
python-pip
sudo apt-get install python-pip
  • pyzmq

    pip install pyzmq
    
  • protobuf

    pip install protobuf
    

Pull the Motion Master

The Motion Master is run as a docker container. From this container the API and the application examples can be pulled.

To pull the Motion Master docker container to your environment, please enter the command:

sudo docker pull synapticon/motion-master

Once the docker is pulled you can run it :

sudo docker run -d -P --network=host --restart=always --privileged --name=motion-master --device=/dev/EtherCAT0:/dev/EtherCAT0 --volume=/opt/etherlab/bin/ethercat:/usr/local/bin/ethercat synapticon/motion-master

The previous commands should be run in one command line, the commands should only be separated by spaces

Important

Before launching the Motion Master, the IgH EtherCAT master needs to be started:

sudo /etc/init.d/ethercat start

If it is not, the Motion Master will restart automatically until it can find the master in /dev/EtherCAT0

From this docker container it is possible to download the Motion Master API and the example applications:

sudo /etc/init.d/ethercat start
sudo docker cp motion-master:/opt/motion-master-client.zip .

To check the status of the Motion Master enter:

sudo docker logs motion-master -f

Create and run an application

  • The folder API contains a zip file with API files to communicate with the Motion Master.
  • The folder bindings contains a list of simplified functions to easily take a motor into operation. These functions can be used without any knowledge of Google Protobuf or ZeroMQ.
  • The folder examples/{C++ | python} contains a demonstration application that simply gives periodically a torque command demo_simple_commands_client.

To build the application, simply run the make command when you are in the application folder. A bin folder containing the executable application is created.

bin/demo_simple_commands_client

You can build your own application on top of this application, or use the script create_application.sh to make your own.

In the file bindings/C++/motion_master_functions.h you can find the list of functions used to control one or multiple drives through the Motion Master.

Important

  • In order to control a servo motor, it should be connected to the computer running the client application and detected by the EtherCAT master.
  • The drive should be first commissioned and configured with Oblac Drives.

Run Motion master via OBLAC Drives Box

in C++ in Pythonin C++

Open the demo file and add the address of the OBLAC Drives Box as a second argument in the initialization of the motion_master e.g:

CommandMaster motion_master(1,"oblac-drives-3d3a5d72.local");
in Python

Open the demo file and add the address of the OBLAC Drives Box as a second argument in the initialization of the motion_master e.g:

m = motion_master.CommandMaster("oblac-drives-3d3a5d72.local")

You can find a list of functions in C++ in the following document:

/motion-master/bindings/C++/motion_master_functions.h