Data Collection and Simulation Comparison: Difference between revisions
No edit summary |
|||
| Line 232: | Line 232: | ||
5. Run the system at 50% throttle and measure the steady-state voltage during the test. | 5. Run the system at 50% throttle and measure the steady-state voltage during the test. | ||
{| class="wikitable" style="text-align:center" | |||
|- | |||
| [[Image:PowerSplitter.jpg|200px]] | |||
| [[Image:QuadMultiCon.jpg |200px]] | |||
| [[Image:QuadMultiSet.JPG |200px]] | |||
| [[Image:QuadMeasESCcon.JPG|200px]] | |||
|- | |||
| Splitter cord. | |||
| Connect splitter to multimeter. | |||
| Settings for multimeter. | |||
| Connecting ESC through splitter. | |||
|} | |||
== Post processing and Simulation == | == Post processing and Simulation == | ||
Revision as of 20:49, 2 August 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.
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 to 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 supplu because it is the only power supply that we have 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. |
While the YouTube video linked above should explain how to use the charger. Currently three different Lithium polymer batteries (Lipo): 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. 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 gets run 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 mAr 4-cell generally charge in 10-20 minutes apiece while I generally fine it takes the 2600 mAh 2-cell 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 which is 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 be named like TrackingToolsProject YYYY-MM-DD timeStamp.ttp. This is normally the most recently edited file when sorting by data 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 main project scree arrange themselves like out camera 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 pop up 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 are named like 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 trackless 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 check to make sure the system is zeroed.
1. 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 it is the side opposite of the switches and the side with the trackable constellation on it. 2. Make sure that the motor with the red motor mount is also facing the wall with the white boards. 3. Make sure the quad system is aligned along Eris Axis by standing behind the system and seeing if you can use the pole to block mounting bolts of the front propeller motor mount when looking at the pole while facing the east wall. 4. 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. 5. 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 with in 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. 6. 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 directs 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. 7. Save the new trackable orientation by going to File->Save Trakables... and save a file using the same naming conventions as the trackable file you opened earlier except 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. In order to 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 is a 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 cause 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 propllers 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 a 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 acclerate 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 packed 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 fond that even on a good strt the [ok] messages will still print.
Turing on RADA
Turing 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 swiches), 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 only the WIFI adapter or Ethernet plugged in at the same time or VRPN my listen to the camera data broadcast over both connects 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 with out needing to close the connection. If you are using a WIFI connect use the command ssh root@192.168.0.53. If you are connected to Eris through a LAN connaction use the command ssh root@192.168.0.54. If the connection goes though you should be proped 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 firs 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 the the NFS server running on CO3050-11. This is accomplished by running 1_co3050-11.sh, this shell scrip will setup the NFS, 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 produces 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 an warning that when coping the log file Eris couldn't maintain the file permisiion 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 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 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 ./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 start up you don't need to run this script. See the Section about Running additional tests below.
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
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.
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.
| Splitter cord. | Connect splitter to multimeter. | Settings for multimeter. | Connecting ESC through splitter. |