Data Collection and Simulation Comparison: Difference between revisions
| Line 53: | Line 53: | ||
##Align ERIS so it is near zero yaw first (eye ball it). | ##Align ERIS so it is near zero yaw first (eye ball it). | ||
##Get a level and a friend. Have your friend use a level to ensure that the pendulum is level in both directions and hold it there. | ##Get a level and a friend. Have your friend use a level to ensure that the pendulum is level in both directions and hold it there. | ||
##With the UAV constellation selected go to the ''Orientation'' tab (next to ''Real-Time Info'' tab) and click on ''Reset To Current Orientation | ##With the UAV constellation selected go to the ''Orientation'' tab (next to ''Real-Time Info'' tab) and click on ''Reset To Current Orientation'' button | ||
##Now your friend can set the pendulum down and you can zero ERIS the same way. | ##Now your friend can set the pendulum down and you can zero ERIS the same way. | ||
#Save the new trackable orientation by going to ''File->Save Trackables...'' and save a file using the same naming conventions as the trackable file you opened earlier. Use the current data so you don't have to re-zero the system the next time you test. | #Save the new trackable orientation by going to ''File->Save Trackables...'' and save a file using the same naming conventions as the trackable file you opened earlier. Use the current data so you don't have to re-zero the system the next time you test. | ||
Revision as of 23:31, 21 September 2016
This page will take you though setting up and testing RADA, retrieving the log file and other necessary data to run a simulation of that test and processing the data in MATLAB. Then actually running the simulation of RADA in Simulink. The initial setup and how to test the system can also be applied to demoing RADA.
Setting Up a RADA Test
Testing RADA is not overly difficult once you get the hang of the steps to setup RADA. The following steps may seem like a long process to go from starting the testing process to having completed simulation and plotting of the test results but this whole test procedure (with the exception of battery charging) can be completed in about 15-20 minutes. These steps are meant to be as detailed as possible in order to help new users of RADA get up and running as quickly as possible.
NOTE: Always run RADA with at least 2 people! The pendulum arm can crash into the ground if the network starts to drop packets and one person cannot give commands to RADA and spot the pendulum. This is a safety issue for both you and the RADA platform.
Charging Batteries
The lab currently uses mostly Hyperion batteries. We charge our batteries with a Hyperion EOS 1420i Net3 battery charger. For some general information about how to use this charger see this video.. In the lab we power this charger using the old Kepco Power supply because it is the only power supply that can supply enough current. Make sure that the power supply is set to an output voltage between 10.5V-29V.
| Kepco Power Supply off. | Kepco Power Supply on with correct voltage supply range. |
The YouTube video link above should explain how to use the charger. RADA currently uses three different Lithium polymer (Lipo) batteries: 1600 mAh 2-cell Lipo for the wheels, 2600 mAh 2-cell Lipo for the electronics of Eris, and a 2600 mAh 4-cell Lipo for the propellers. The 1600 mAh 2-cell Lipo can be charged using memory slot 2 of the charger. The 2600 mAh 2-cell Lipos can be charged using memory slot 3 for fast charging and memory slot 4 for slower charging (use this if the battery voltage drops really low for 10-20 minutes then switch to fast charging). The 2600 mAh 4-cell Lipo can be charged using memory slot 8. The 1600 mAh 2-cell and 2600 mAh 4-cell generally charge in 10-20 minutes apiece while the 2600 mAh 2-cell generally take up to 70 minutes to charge fully.
Setting up the Camera System
The camera system is run on the windows computer CO3050-07. You can log into this computer using a local microcart username and password (not posted here for security reasons, but any one who works in the lab should know it). Once logged in, look for Tracking Tools in the start menu or look for the shortcut shown below:
Once the program opens the screen should look something like this:
In the Tracking Tools Quick Start pop up menu select Open Existing Project and then navigate to D:\Optitrack_Configuration (It should open to this directory by default) and select the most recent Tracking Tools project. It should have the naming scheme TrackingToolsProject YYYY-MM-DD timeStamp.ttp. This is normally the most recently edited file when sorting by date modified. The most recent one as of August 1st, 2016 is TrackingToolsProject 2015-09-23 2.30pm.ttp.
You should notice that the cameras shown in the main project screen arrange themselves like the camera system configuration once the project has been opened. Now the constellations need to be loaded. This can be done by going to File->Open and another popup window will open. Navigate back to D:\Optitrack_Configuration (It should open to this directory by default) and select the most recently dated set of RADA trackables. They have the naming scheme RADA_entireSystem_M_D_YYYY.tra. The most recent one as of August 1st, 2016 is RADA_entireSystem_7_8_2016.tra.
Once the project and trackables are open, the cameras should appear in their constellation (square) and there should be two constellations under Project Explorer->Trackables. One named UAV for the pendulum and one named ERIS for the ground vehicle. In order to get additional information about each constellation, left click on the the name of the desired trackable.
Once a trackable is selected more information about it is available in the Trackables Tab on the right side of the screen. For the current position and orientation look at the Real-Time Info sub-tab. This gives the orientation in the wrong order for how we currently use the Euler angles. When two or three of the angles are near zero you can switch yaw and pitch to get roughly the correct orientation.
Now we need to check to make sure the system is zeroed.
- Hold RADA so that the front of the ground robot (ERIS is facing the wall with the white boards (east)). The front side of Eris is labeled. If it isn't, the front is the side opposite the switches and the side with the trackable constellation on it.
- Make sure that the motor with the red motor mount is also facing the wall with the white boards.
- Make sure the quad system is aligned along Eris Axis by standing behind the system. If the system is aligned, you should be able to block the mounting bolts of the front propeller motor with the pole while facing the east wall.
- While holding the pendulum approximately vertical, see if the camera system reads zeros for the pendulum (UAV) pitch and roll (yaw and roll in Real-Time Info). If yaw is off by a few degrees that is fine.
- Compare the yaw of the UAV to that of ERIS (Remember this is pitch in Real-Time Info). If they are both near zero and within a few degrees and the pendulum's pitch/roll were also near zero then you are ready to use the camera system. Otherwise, go to the next step.
- You need to zero the pendulum.
- Align ERIS so it is near zero yaw first (eye ball it).
- Get a level and a friend. Have your friend use a level to ensure that the pendulum is level in both directions and hold it there.
- With the UAV constellation selected go to the Orientation tab (next to Real-Time Info tab) and click on Reset To Current Orientation button
- Now your friend can set the pendulum down and you can zero ERIS the same way.
- Save the new trackable orientation by going to File->Save Trackables... and save a file using the same naming conventions as the trackable file you opened earlier. Use the current data so you don't have to re-zero the system the next time you test.
Building Software
The development environment for running RADA is hosted on CO3050-11, a Linux Red Hat environment. This computer has a local ucart user name that you should use (the password isn't put here for security reasons). First, ensure that the RADA software is setup correctly for the test you want to run. To do this, you will need to open the main.cpp and logger.cpp files and make sure all of the compile time macros you want are defined correctly. All of the c++ files you should need to edit are in the directory ~/Desktop/rada_research_project/ErisResearchCode/CppProjects/MainProgram_PacketLoss/src/Korebot Below are compiler macro options for main.cpp:
-H2ctrl : This will cause the system to enter H2 controller mode where the whole RADA system is controlled by an H2 controller. -ssTracking : H2ctrl must also be defined for this macro to do anything. This macro will has the system to be controlled by a tracking H2 controller. -ssMotors : H2ctrl must also be defined for this macro to do anything. This macro will has the system to be controlled by an H2 contorller that contains propeller states. This also causes the system to "Dance." -ssDrop : Cause the system to go into packet drop controller mode. This mode allows controllers designed for lossy networks to be tested. Based off of other definitions how lossy the network is can be simulated. If nothing else is defined this controller becomes basically a H2 controller. -drop10 : Will put the packet drop mode into 10% loss mode and use a controller designed for 10% loss. -drop30 : Will put the packet drop mode into 30% loss mode and use a controller designed for 30% loss. -drop50 : Will put the packet drop mode into 50% loss mode and use a controller designed for 50% loss. -mot50 : This macro over-rides all other macros. If this is turned on the wheels will not run and the propellers will be run at 50% command. This is used for measuring the effective battery voltage seen by the ESCs. This is always run after a test. -RADAlqi : This macro will cause the system to use an LQI controller on the whole system. The linear velocity states are calculated with no filter and the angular velocity states are calculated with filters. -RADAlqi_est : This macro will cause the system to use an LQI controller on the whole system. A traditional estimator is used to estimate the states. -rada_lqg : This macro will cause the entire system to be controlled by an LQG controller/estimator system. -rada_split_lqg : This macro will cause the pendulum and ground robot to be controlled by their own LQG systems. -rada_split_lqg_ol : This macro will cause the pendulum to be controlled by an LQG controller, the yaw of the ground robot to be controlled by a PID controller, and the ground robot linear velocities to be controlled with open-loop commands. -yaw_off : This macro will cause the yaw control to be disabled on some controllers. *accR : This macro will cause the PID linear velocity controllers to be given ramps to accelerate from one velocity to another instead of steps. -posRamp : This macro will cause the linear velocities of RADA to be controlled by position PIDs with ramp reference instead of velocity commands. -If no controller selection is made all controllers revert to PID controllers
All of these macros can be defined simply by uncommenting the corresponding define statement in main.cpp. The macros in the logger.cpp can be seen below:
-ssDrop : This macro puts the logger into packet drop controller mode and logs the correct values for the packet drop controllers. -RADAlqi : This macro puts the logger into full system LQI controller logging mode. -RADAlqi_est : This macro puts the logger into full system LQI controller plus estimator logging mode. -rada_lqg : This puts the logger into full system LQG controller logging mode. -rada_split_lqg : This macro causes the logger to log data about the subsystem LQG controllers. -rada_split_lqg_ol : This cause the system to log data about the pendulum LQG system and the open-loop linear velocity commands. -H2ctrl : This macro causes the logger to log data about the full system H2 controllers. -If no logging mode is selected then the logger will default to logging PID data.
Because the system only calculates controllers for one set of controllers it is important to ensure that the logger is in the correct mode based off of what is defined in main.cpp. As of August 1st, 2016 the defines in main.cpp are not seen in logger.cpp.
Finally in a command prompt navigate to the driectroy: ~/Desktop/rada_research_project/ErisResearchCode/CppProjects/MainProgram_PacketLoss
Here just type: make. The code will compile for your desired mode. For setting up a new development directory see Setting up a new development environment from the RADA Senior Design wiki.
The complied executable code ends up in /home/shared/MainProject. The /home/shared directory is setup as a network file share (NFS).
This service needs to be restarted when CO3050-11 is restarted. Configure NFS shares for the robot from the RADA Senior Design wiki. Be sure to use the new Linux install command in step six. Though I have found that even on a good strt the [ok] messages will still print.
Turning on RADA
Turning on Eris is fairly simple. Each system has its own battery. There is one for the wheels that plugs in at the front of Eris (opposite side of the switches), one for the electronics in the back of Eris (in between the switches), and one for the propellers that goes on top of Eris.
The wheel battery is normally 1600 mAh 2-cell Lipo but any 2-cell Lipo will work. The wheels are turned on by flipping the silver switch so the top points away from the system. The electronics normally use a 2600 mAh 2-cell Lipo. The electronics are turned on by flipping the green switch away from the system. It is important that you use EITHER the WIFI adapter OR hardwired Ethernet, because the VRPN may listen to the camera data broadcast over both connections which could cause problems. The propeller system is powered via a 2600 mAh 4-cell Lipo that connects to a power cable at the base of the pendulum. There is a switch to turn on the power to the propellers system. You will know it is on when the 1 on the switch is flush with the switch housing instead of sticking out. It takes about 30 seconds to a minute for Eris to boot up and start the networking connections. When the WIFI is plugged in, you will know it is ready when a blue light turns on, on the module.
Connecting to RADA
RADA is controlled through an SSH connection. in a commands prompt, not the one you compile the code from so that you can recompile for different setup without needing to close the connection. If you are using a WIFI connection use the command ssh root@192.168.0.53. If you are connected to Eris through a LAN connection use the command ssh root@192.168.0.54. If the connection goes though you should be prompted for a password.
The password is rootme.
It is important to close the SSH connection before turning off Eris because the terminal you are using will hang up if you don't. You can close the connection by using the command exit.
Testing RADA
Now that you are connected to Eris you can run tests. The testing is started by a few different methods.
Running the First Test After Power Up
For the first test after powering on Eris, a few additional steps need to be completed in order to test the system. The FPGA motor controller needs to be programmed and Eris needs to connect to the NFS server running on CO3050-11. This is accomplished by running 1_co3050-11.sh, this shell script will setup the NFS, and load the bit file into the FPGA configuration memory. Then it retrieves the executable file from the NFS server /mnt/nfs/MainProject and runs the executable. Once the user exits the executable, the log file produced is copied from the ~/Logs/YYYY_MM_DD_Day directory on Eris to /home/shared/MainProject/Logs/YYYY_MM_DD_Day on CO3050-11. When the folder for the current Eris date doesn't exist it creates this directory in CO3050-11 and then removes the directory and log file from Eris. You may see a warning that when copying the log file Eris couldn't maintain the file permission settings. This is normal as Eris doesn't have the same access to the NSF server as it has to its own files. This date stamp uses the date on Eris, which is currently in June of 2008 as of August 2nd, 2016.
Before starting the test, it is best to have someone spotting the pendulum and holding it near vertical so that the pendulum doesn't have issues when entering a control mode. Always ensure the pendulum is spotted by a second person when testing so you don't hurt yourself, others in the lab, or the RADA system. Once the spotter is ready, run the shell script by using the command ./1_co3050-11.sh in the terminal with the open SSH connection to Eris from the home, /root, directory of Eris. When you run this script there will be a bunch of information printed out about the PIC bus and loading the bit file to configure the FPGA. You will know that RADA is ready for the test when it asks you to select a running mode. See the Testing Modes section below. This script can take a while to complete so beyond the first test after startup you don't need to run this script. See the Section about Running additional tests below.r
Testing Modes
The RADA system has three testing modes: Robot Control Mode, Tuning Mode, and Box Step Mode. Additionally you can exit the execution at any time by pressing the Esc key. Once the terminal asks you to chose a mode you can use the following commands to enter the desired mode with a three second delay or exit the program. You can also use these commands to switch between the modes.
-v : Enters the pendulum PID tuning mode, this will only really work when using PIDs to control the pendulum. -b : Enter Robot control mode, in this mode you can drive the robot around and the pendulum will try to stay vertical. This is the main mode used for testing the whole RADA system. -n : Enters box step mode, where the pendulum will change its desired pitch and roll angles every 20 seconds and move in a box shape. -Esc : By hitting the escape key the program will exit the program.
You will almost always want to run Robot Control Mode as the other modes are legacy modes from when we initially built and tested RADA and only works with the pendulum PID controllers. There are also a few utility commands that can be used in all modes.
-2 : Resets I composts of the Pitch/Roll PIDs and only the PIDs. -m : Adds a marker to the Log file incase odd things happen somewhere. This just increments a counter so if you use it look for changes in the marker value.
Robot Control Model
In Robot control mode you can control the motion of Eris. For PID control of Eris or 1D state feedback system the directional commands command Eris body velocity were for full system and Eris system state feedback controllers control the global velocity. All of these keys only need to be pressed not held down.
-w : Moves Eris forward (+x) at some velocity depending on the controller. -s : Moves Eris in reverse (-x) at some velocity depending on the controller. -d : Moves Eris in right (+y) at some velocity depending on the controller. -a : Moves Eris in left (-y) at some velocity depending on the controller. -p : Stops the motion of Eris (Set all velocity set points to zero). I.e. if you hit w then hit s then Eris will be moving in reverse. -y : Moves Eris forward and to the right (+x/+y) simultaneously at some velocity depending on the controller. -t : Moves Eris forward and to the left (+x/-y) simultaneously at some velocity depending on the controller. -i : Moves Eris reverse and to the right (-x/+y) simultaneously at some velocity depending on the controller. -y : Moves Eris reverse and to the left (-x/-y) simultaneously at some velocity depending on the controller. -e : Rotate Eris clockwise (+yaw) at some angular rate. This only worked when RADA used the closed-loop FPGA control of the wheels. There is currently no controllers that use this command. -q : Rotate Eris counter-clockwise (-yaw) at some angular rate. This only worked when RADA used the closed-loop FPGA control of the wheels. There is currently no controllers that use this command. -< : Increment Eris' desired heading 45 degrees counter-clockwise (-yaw). -> : Increment Eris' desired heading 45 degrees clockwise (+yaw). -7 : Increments the pitch set point (+pitch). -4 : Decrements the pitch set point (-pitch). -8 : Increments the roll set point (+roll). -5 : Decrements the roll set point (-roll).
Tuning Mode
Tuning mode allows you to tune the PID controllers for both pitch and roll. The UI commands here are also available in Box Step Mode.
-1 : Tune the Pitch PID. -3 : Tune the Roll PID. -7 : Increase proportional gain of PID being tuned. -4 : Decrease proportional gain of PID being tuned. -8 : Increase integral gain of PID being tuned. -5 : Decrease integral gain of PID being tuned. -9 : Increase derivative gain of PID being tuned. -6 : Decrease derivative gain of PID being tuned. -i : Increase set point of PID being tuned. -k : Decrease set point of PID being tuned. -o : Increase integral windup term of PID being tuned. (Not used) -l : Decrease integral windup term of PID being tuned. (Not used)
Box Step Mode
Box set mode will automatically change the set points of the pendulum every 20 seconds. The case statement for this mode can be changed for 1D and 2D step modes. This mode allows the user to use he same commands as Tuning Mode.
Running additional Tests
Once you have run one test with Eris on it is unnecessary to configure the FPGA or connect to the NFS server again. This is what took much of the time in the initial setup. This is what the script 3_stat_eris.sh was developed for. It does everything that 1_co3050-11.sh does but without reprogramming the FPGA or reconnecting to the NFS server. As a result it is ready to test much quicker.
Before starting the test it is best to have someone spotting the pendulum a holding it near vertical so that the pendulum doesn't have issues when entering a control mode. Always run ensure the pendulum is spotted by a second person when testing so you don't hurt yourself, others in the lab, or the RADA system. Once you spotter is ready run the shell scrip by= using the command ./3_start_eris.sh in the terminal with the open SSH connection to Eris from the home, /root, directory of Eris.
Locating and retrieving log files
If you are only demoing the system there is no need to go beyond this point. Once you are done with a test that you want to compare to the model you should retrieve the log file right away so you don't mix it up with other test. On CO3050-11 go to the dircetory /home/shared/MainProject/Logs using the file browser (you can do this in a terminal but it is easier from the file explorer). Once there, look for the folder that has been modified most recently as Eris date is normally out of sync with its date and time. Then look for the newest log file. Log files are named like log(hh.mm.ss).txt (ex. log(13.04.51).txt). This naming convention works well to ensure that no log file is over written but it isn't useful of describing what the test was of or for. Copy this log to the Desktop or to a USB drive and rename it. A good method is to name the file something like RADA_ctrl_otherNote#.txt, where Describes what system you tested (ex. RADA, RADA1D, PEN1D, PEN2D), what typ of controller was used, other notes and then a number if this is a repeat of another test. This is much more useful when looking back at these logs later on. Before transferring the log file for processing you should record the wheel and propeller battery voltages in the header of the log file. The log file format is both human readable and can be parsed by MATALB. It was designed by the first RADA Senior Design Team and more information about the log files can be found here. See he section below on measuring battery voltage below in order to get the best measurements for simulation of RADA.
Measuring battery voltages
The last thing that you need to do before simulating an experiment of the RADA platform is record the battery voltages for both the wheels and propellers. The wheel battery can be measured unloaded as there isn't large line losses between the battery and the H-bridges. The propeller battery voltage needs to be measured under load because the power cord running up the pendulum has significant line losses at the currents the propellers draw when in use. The battery voltages can be recorded in the log file for the test. Open the log file for the test you just completed (Use KWrite for Linux machines or Notepad++ for Windows machines). The first few lines of the log is the headder. It should look like this:
#Constants pitch_P pitch_I pitch_D #PIDValues 48000 18000 21000 #Constants roll_P roll_I roll_D #PIDValues 48000 18000 21000 #Battery Vquad Vwheels #Voltage
Follow the procedure for measuring the voltage of each battery and then record the voltage under the corresponding battery. Then save the log file and close out of your text editor and the test will be ready for processing. Recoding the battery voltages in this way makes it much easier to find if you need the value latter. The final log file header should look like this once you are done
#Constants pitch_P pitch_I pitch_D #PIDValues 48000 18000 21000 #Constants roll_P roll_I roll_D #PIDValues 48000 18000 21000 #Battery Vquad Vwheels #Voltage 14.44 8.257
Wheel Battery
1. After test disconnect wheel battery from the system. 2. Measure voltage of battery using multimeter.
You can use the plug used for charging the 2-cell Lipos but make sure to connect the plug to the multimeter before connecting the battery and disconnect the battery before disconnecting the plug from the mulitmeter. It is generally the best practice to give the multimeter a few minutes to allow for the voltage measurement to stabilize as the battery measurement tends to be a little low right after the test. The multimeter will report data out to four decimal places it is best just to round to three decimal places for the wheel voltage.
Quad Battery
1. Setup code to run all four propellers at 50% throttle, uncomment the definition of mot50 in main.cpp and compile the project. 2. Power off propellers by turning off the switch to the ESCs. 3. Connect multimeter to measure the voltage across one of the ESCs. This is done by using the power splitter cord. -Connect one of the female XT60 connectors on the splitter to a male XT60 connector to banana connector cable. -The banana connector connect to the hand held multimeter. The multimeter should be set to the 20VDC measurement setting. -Next unplug one the ESCs' power connection. -reconnect the ESC to power through the two remain connectors on the spliter cable. 4. Power on the propellers. 5. Run the system at 50% throttle and measure the steady-state voltage during the test. The battery will slow the voltage decay significantly, meaning it will keep the same measurement for a few seconds. 6. Stop the test and record the voltage in the log file. Make sure to disconnect the batter before removing the splitter cable.
| Splitter cord. | Connect splitter to multimeter. | Settings for multimeter. | Connecting ESC through splitter. |
The testing setup should look like the image below:
Post processing and Simulation
Simulating a test of RADA starts with processing and storing the data. Then all of the parameters of the model are loaded in the MATLAB Workspace. Finally the Simulink file used for the simulation is opened and the length of the simulation is set to match the length of the actual test. The simulation is run and the simulation output is stored. Finally the data should be plotted and compared.
Using the MATLAB data parsing tool
In depth discussion of how to use the log file parsing tool is described here. I suggest using the version of the tool in the rada_resarch_project git repository Paul Uhing used for his Master's research. It con be found on CO3050-11 under the ucart account in the directory ~/rada_research_project/DataAnalysiTool_omnicoor/Tool. Simply open MATLAB and set the working directory to this file path. In the MATLAB Command Prompt run DataAnalysis. A popup window should open up. Select the log file you want to process and wait for the tool to finish processing the file. Once this is complete there should be four structures in the MATLAB workspace.
-main : This contains all of the data extracted from the log file and the processing parameters used. main.expData contains two time structures: Time is used for the pendulum data and Eris_time is used for the ground vehicle data. -X_ref : This contains the reference vector in m/s for x velocity that is feed into Simulink. This expedites the simulation setup process, this used to be done by hand. -Y_ref : This contains the reference vector in m/s for y velocity that is feed into Simulink. This expedites the simulation setup process, this used to be done by hand. -Yaw_ref : This contains the reference vector in radians for yaw that is feed into Simulink. This expedites the simulation setup process, this used to be done by hand. This one is new incase people start testing the system with heading changes but is not used in the current setup.
The first thing you should do is rename the main structure to the name you used for the log file. This is helpful for comparing multiple tests. Next you will want to crate two new variable Vquad_test an Vw_test. In the MATLAB Command Prompt set the measured propeller voltage from the log file to Vquad_test and set the measured the wheel voltage to Vw_test as this will be used by the simulation. Finally if you did an open-loop test of the wheels create the variable Uol and set it to the open-loop wheel command used. Save all of these variables from the MATLAB workspace to a .mat file of the same name as log file you extracted the data from and save it in the same directory as your RADA Simulink files. As of August 2nd, 2016 this directory is ~/rada_research_project/MATLAB/RADA.
Setting up the MATLAB workspace for simulation
Change your MATLAB directory to this directory. Then run the simulation setup files. Currently you just need to run modelParams_smallWheels_RADA in the MATLAB Command Prompt. Next open the Simulink file with that contains the model of RADA controlled by the controller you tested.
-RADA_psiCtrl_v2_lqi_est.slx contains LQI, LQI+estimation, and LQG controller simulations. -RADA_psiCtrl_v2.slx contains the PID controlled system. -RADA_psiCtrl_v2_LQGsep.slx contains the subsystem LQG controlled system. -RADA_psiCtrl_v2_LQGsep_ol.slx contains the simulation of the pendulum system controlled by an LQG and Eris controlled with open-loop commands.
Note all of the current (August 2nd, 2016) .slx files were created in MATLAB 2014b and will only work in MATLAB 2014B or newer. Then in the MATLAB Command Prompt type X_ref.time(end) exactly, don't add a semicolon, and hit enter. MATLAB will print the time of the last command in the X_ref structure. Set the en time of the simulation to this value and save your Simulink file.
Running simulations and storing results
Before running the simulation make sure that the simuation is using the ode23t differential equations solver. This system is a moderately stiff system of differential and the ode45 solver doesn't do well with these types of systems. When using ode23t is should only take a few minutes to run a 100+ second simulation while doing the same test using ode45 could take 8 hours. While this slow it is also bad for your hard drive as the simulation has to page between RAM and your computers hard drive a lot.
Once this check is done run the simulation. While it is running check what the output structures variables are named for for your RADA test system. Once the simulation is done go to your MATLAB Workspace and select all 15 outputs for your simulation or your sub-simulation if you used RADA_psiCtrl_v2_lqi_est.slx. Save these 15 output structures to a .mat file named as the log file with _sim appended to the end of the name.
The 15 outputs are structures containing a time vector and then the data from the simulation sampled at 100 Hz and the units of this data are the SI units (ex: radians, m/s). There is one output structure for x velocity, y velocity, x body velocity, y body velocity, theta (pitch), phi (roll), psi (yaw), and one per actuator command (ex: the command sent to a wheel). Now you have all the data you can plot it.
Plotting results
If you look at the DataSets folder below ~/rada_research_project/MATLAB/RADA directory there are plenty of examples of how Paul Uhing compared simulation to test data. Generally you should grate a .m file with the same name as the log file this data was extracted from with _plot appended to the name.
Generally you can just copy an for RADA_LQG_compPID_plot.m RADA_PID_compLQG_plot.m, RADA_LQG_sep_plot.m, or RADA_LQG_sep_ol_plot.m files and rename the structures for your test.
These files create four figures. Figure 1 plots compares the x velocity data in the first sub figure and compares pitch (theta) data in the second sub figure. Figure 2 does the same thing as Figure 1 but with y velocity and roll data. Figure 3 looks at the yaw data. Finally, Figure 4 looks at the sample period between UAV and ERIS packets from the camera system just to check for periods of time with large packet drops.
You can follow a similar pattern to compare motor commands. Just make sure that you compare Quad Motor 2 from the test data with Quad Motor 4 from simulation and vise versa because propellers 2 and 4 were switch in Eris's software compared to the Model.
That is all you need to know for testing RADA against the model.