# RoPod/Tutorials/Matlab and ROPOD platform interface

Info

RoPod Configuration

Other

# Install gcc 4.9

To be able to compile the library to communicate with the ropod, the gcc compiler version 4.9 is needed. Run in a terminal the following commands:

sudo apt-get update
sudo apt-get install gcc-4.9

Create a folder in which the git repositories can be cloned. For example:

mkdir Matlab
mkdir Matlab/Github

Go to this folder (Matlab/Github is an example, different directory names can be used)

cd /Matlab/Github

Go to the RoPod GitHub page and clone the repositories.

For the RoPod global libraries go to https://github.com/tue-ropod/ropod_global_libraries. Click on the Clone or Download button and copy the link.

Go back to the terminal that is in the new folder, and use the git clone command. For example:

git clone https://github.com/tue-ropod/ropod_global_libraries.git

Do the same for the platform velocity control repository, at https://github.com/tue-ropod/ropod_platform_velocity_control.

git clone https://github.com/tue-ropod/ropod_platform_velocity_control.git

# Make and build Matlab files

Go to the home folder and open Matlab:

cd
matlab

In Matlab, open the ropod_global_libraries folder, and run the Installations.m file to build and install the necessary files.

run Installations.m

Go up a folder, and right click the ropod_global_libraries folder and add the folders and all sub folders to the path.

Or use the pathtool function in Matlab to save the path, so that this step will not have to be executed manually each time Matlab is started.

Next, go to the ropod_platform_velocity_control folder, and execute the init_model.m file.

run init_model.m

To test if everything is installed correctly, open ROPOD_Control_SIM.slx and try to build the Simulink file by pressing Ctrl+B.

Now, an executable file, which can run on the ropod platform, can be created by opening ROPOD_Control.slx and building the code by pressing Ctrl+B.

# Build and install the communication library

As the following files are not on the repository yet, you can not continue the tutorials at this moment.


Only to install the library, run matlab as administrator:

sudo matlab &

Go to the main folder containing the test example files. Then build and install SOEM (Simple Open EtherCAT Master) library, in matlab:

cd some
Build_and_Install_SOEM
cd ..

now close matlab and re-run it as user:

matlab &

# Make and build the interface test

First make the ropod simulink libraries to run your test. Run in matlab:

Make_ropod_libraries

Then, you can open the test file “Ecat_Test_Example.slx”. To build the model, press “Ctrl+B”.

The executable file “Ecat_Test_Example” should appear in the current folder

# Explore the ropod interface

Examine the file “Ecat_Test_Example.slx” and get familiar with the interface.

Each motor receives commands at a rate of 200Hz with the following formatting:

• mot_drivemode
0x00 = Velocity control, 0x01 = current only control
• mot_command:
Action request sent to the motor
• mot_velocitySP:
Velocity setpoint (rad/sec) when velocity control is active. In velocity control mode, the internal controller has a sampling time of 1kHz.
• mot_currentSP:
Current setpoint (Amperes) when current control is active. In current control mode, the internal controller has a sampling time of 10kHz.

When velocity mode is active, this current setpoint is used as maximum allowable current.

Moreover, the following data is read from each motor:

• mot_Update:
Cyclic counter, increments after each packet exchange with motor controllers
• mot_Status:
bit Description
0 Motor enabled
1 unused
2 Voltage below 18V, disables motor
3 Voltage above 32V, disables motor
4 Mosfet temperature over 85C, disables motor
5 Save to eeprom finished
6 Motor phasing in progress
7 BISS absolute sensor in calibration mode
• mot_Current:
Motor current in Amperes
• mot_Velocity:
• mot_Position:
• mot_InputVoltage:
Motor voltage in Volts
• mot_PivotPosition:
Angular position of each pair of wheels in rad.

Additionally, the platform has a gyro sensor on each pair of wheels. The gyro sensor data is:

• gyr_Update:
Cyclic counter, increments after each packet exchange.
• gyr_Temperature:
Temperature of gyro sensor in Celsius degrees.
• gyr_xacc:
Acceleration in local x axis in m/sec^2
• gyr_yacc:
Acceleration in local y axis in m/sec^2
• gyr_zacc:
Acceleration in local z axis in m/sec^2
• gyr_xvele:
Gyro Velocity in local x axis in rad/sec
• gyr_yvel:
Gyro Velocity in local y axis in rad/sec
• gyr_zvel:
Gyro Velocity in local z axis in rad/sec

# Run the interface test

For this test it is recommended to place the platform on top of some block such that the wheels can move freely. Be sure you place ONLY ONE battery (this issue will be solved).

Then connect the ethernet from your computer to the port “IN” of the ropod platform. Now you can turn on the power of the ropod.

Open a terminal and add usr/local/lib to the environment LD_LIBRARY_PATH. To do it permanently, add it to the baschrc file. You can run the following command:

echo 'export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/usr/local/lib'  >> ~/.bashrc

Then, to run the file you must log in as root user:

sudo su

Due to some technical issue of the wheels, rotate each wheel until the color markers on them are on the highest position. Then, simply run the executable file:

./Ecat_Test_Example

All wheels should start moving then.

To be able to make changes online to the constants on the model, you need to connect Simulink with the running executable file. Press the connect to target button:

You can now change the velocity commands to verify correct functionality.

Now you can create your own program to make the ropod platform move as desired. You can use blocks with s-functions (embedded c code) to implement your functionality.