RoPod/Tutorials/Matlab and ROPOD platform interface
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
Download the repositories
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)
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:
In Matlab, open the ropod_global_libraries folder, and run the Installations.m file to build and install the necessary files.
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.
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:
Make and build the interface test
First make the ropod simulink libraries to run your test. Run in matlab:
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:
- 0x00 = Velocity control, 0x01 = current only control
- Action request sent to the motor
- Velocity setpoint (rad/sec) when velocity control is active. In velocity control mode, the internal controller has a sampling time of 1kHz.
- 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:
- Cyclic counter, increments after each packet exchange with motor controllers
|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|
- Motor current in Amperes
- Angular velocity in rad/sec
- Wheel position in rad
- Motor voltage in Volts
- 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:
- Cyclic counter, increments after each packet exchange.
- Temperature of gyro sensor in Celsius degrees.
- Acceleration in local x axis in m/sec^2
- Acceleration in local y axis in m/sec^2
- Acceleration in local z axis in m/sec^2
- Gyro Velocity in local x axis in rad/sec
- Gyro Velocity in local y axis in rad/sec
- 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:
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:
All wheels should start moving then.
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.