Você está na página 1de 74

Multiple UAV Flight Simulation using MATLAB, Simulink, and VRML

by

David C. De La Fuente
A thesis submitted for a fulfillment requirements
for the Research Experience for Undergraduates at Utah State University

I.

Abstract

Multiple UAV Flight Simulation using MATLAB, Simulink, and VRML


by
David C. De La Fuente
Utah State University, REU, 2011
REU Professor: Dr. YangQuan Chen
Department: Electrical and Computer Engineering
This paper focuses on the design and implementation to create a UAV (Unmanned Aerial
Vehicle) simulator. It describes the processes, and VRML (Virtual Reality Model Language) concepts
involved in designing a simulator using MATLAB, Simulink and VRML. The reason for the design of
this simple UAV simulator is to be able to track a UAVs trajectory once the UAV has finished its
mission. This is important because the ground crew needs to evaluate the path of the UAV when it goes
out of the crews view point. Since the entire trajectory is sent to a ground station, we can take the data,
and visually analyze the path of the UAV, which includes the time the crew visually loses its view of the
UAV, by plotting the path into a simulator. It is also important to obtain the data when the UAV goes out
of visual range. Since, the UAV cannot be seen all the time with its programmed trajectory, it is also
important to see if the UAV is following the correct path when it is not seen on the ground.
Since it is important to visually see the path of the UAV, the CSOIS(Center for Self Organing and
Intelligent Systems) department at Utah State University, and having the data of the trajectory when it is
out of range is valuable to the department. An easy cost effective simulation program was the idea, and
the use of MATLAB and Simulink with VRML (Virtual Reality Model Language) as the programming
applications was the mission of the project. These applications provide a cost effective solution for the
development of the UAV simulator because they are already available to the university, and experienced
personnel working with these applications will be able to build the simulator accurately and quickly.

Table of Contents
I.

INTRODUCTION............................................................................................................... 4

II.

Research......................................................................................................................... 6
a.

Literary Reviews.......................................................................................................... 6

b.

Simulator Capabilities................................................................................................. 7

III.

What was Accomplished.............................................................................................. 8

a.

Application Capabilities............................................................................................... 8

b.

The Graphical Interface (GUI)\..................................................................................... 8

c.

MATLAB Created Functions........................................................................................ 13

d.

Simulink Model.......................................................................................................... 13

e.

VRML (Virtual Reality Model Language) Model File....................................................14

IV.

Other research.......................................................................................................... 18

V.

RESULTS....................................................................................................................... 19

VI.

Conclusion................................................................................................................. 20

Appendix A......................................................................................................................... 22
References.......................................................................................................................... 77
VII.

References................................................................................................................ 77

http://www.defense.gov/specials/uav2002/........................................................................77
http://aggieair.usu.edu/....................................................................................................... 77
Editor, author, or compiler name (if available). Name of Site. Version number. Name of
institution/organization affiliated with the site (sponsor or publisher), date of resource
creation (if available). Medium of publication. Date of access.Lastname, Firstname. Title of
Book. Place of Publication: Publisher, Year of Publication. Medium of Publication...............77
Gillespie, Paula, and Neal Lerner. The Allyn and Bacon Guide to Peer Tutoring. Boston:
Allyn, 2000. Print................................................................................................................ 77

I.

INTRODUCTION

UAVs (Unmanned Aerial Vehicle) play an important role with military and civilian applications
which provide research and intelligence data to the organizations using the UAVs. Today, most of the
popular UAVs seen in the media are military applications which provide intelligence, target location,
and hostile troop movements. Using a UAV for these scenarios, the ground crews of the UAV are able to
accurately determine exactly the location of the enemy movement or target. Being able to pin point an
exact location of a target reduces civilian casualties, and other damage that may be cause if there was an
airstrike on a particular target. With previous intelligent gathering, aircraft piloted by pilots used to
gather this information.

Even though they have the technology to accurately retrieve the same

information as the UAV, the human factor still plays a role with intelligence being incorrect. If an
aircraft had to go into hostile territories they still had the chance of losing a pilot if the aircraft were to
get gunned down. With UAVs, this problem is non-existent, and even though UAVs have monetary
value, the value of human life outweighs the cost of a UAV, and for this purpose alone it is the major
reason why UAV technology is so important.
Applications for the use of UAVs also exist outside the military, and an example is the
application of UAVs used with AggieAir flying circus. The main purpose for the use of these UAVs is to
monitor agriculture. According to their website [9] they use UAVs to monitor soil moisture, which is
helpful in agriculture because it is able to mange irrigation more effectively for farmers.
UAV (Unmanned Aerial Vehicles) Simulators have been around since the idea of unmanned
flight. An example is the United States Air force, they have been building simulators to design their
aircrafts, and there is no difference building a UAV. Since the building of any aircraft is costly,
4

organizations have built aircraft simulators to test aircraft flight dynamics using up to date technology.
This is helpful because many conditions may occur if an aircraft was built without certain weather or
aerodynamic conditions in mind. With the use of computer technology organizations can reduce the cost
to build an aircraft.
Most simulators have been built with the intention of large aircraft with an endless selection of
dynamics used by these aircraft. Organizations can use current technology to help a pilot navigate the
sky, but unfortunately there is still error that cannot be for seen. This can lead to loss of aircraft, but
most importantly loss of life. Simulators are very important for this reason alone. Having the ability to
build and teach a pilot to fly a specific aircraft, will lead to a lot less preventable accidents.
Even though UAV flight does not have a human, poor designs are a costly mistake that can be
avoided. Most companies do not want to fly an aircraft without it being tested because of the major cost
involved. For the aerospace industry, developing UAVs, it is important for them to have the ability to
test these aircraft according to FAA regulations, and world conditions that would be detrimental if an
untested aircraft were to come across one of these obstacles.
There are few public UAV simulation applications offered to the public, but the ones that are available
are mostly designed for aircraft developed by the aerospace industry company. Most simulators that are
researched on the web are built for military applications, and are unable to be obtained for public use.
There are commercially owned simulators like Microsoft Flight Simulator, but in order to build on their
platform would require knowledge of the flight dynamics of the aircraft.
The building of a simulation software designed using the applications MATLAB, Simulink, and the
Virtual Reality Model Language (VRML). The simulator is specifically designed to show the trajectory
of UAV flight to determine the angles of rotation, initial point to target evaluation, and the ability to
control multiple UAVs to different waypoints.

II.

RESEARCH

a. Literary Reviews
There are many references that can explain the use of a simulation, how it was designed, and the
different uses for it, but the purpose of these papers is to inform the reader that the technology exists.
Few actually tell the public about the way to design a custom simulator designed for their own use.
Some papers like An Actor-Based Simulation for Studying UAV Coordination by Myeong-Wuk et al.
have been able to simulate a UAV aircraft, but do not state how to build the simulation. They only state
the aircraft object model and the fact the advantages to low cost UAV aircraft. This is very important to
associations wanting to build their aircraft at low costs, but to be able to come up with a design
specifically targeting the Actor model, which is the UAV model used by their simulator, is time
consuming and impractical for low cost aircraft. Being able to design a UAV simulator with the idea
that it can be done easily, effectively, and menial cost is very important to organizations. This is
especially true because UAVs are an aircraft technology that is still not as main stream as other aircraft
models. It takes some convincing for a company to decide on whether to start designing the aircraft
because it involves a lot of research development, and sometimes costly designing. If software
simulators can be designed easily and effectively using technology available to the public it makes a
convincing argument to organizations pursuing this technology to actually invest in the design of a
simulator for UAV research within their company.
The differences between others simulators references and this one is that this paper describes in
detail the development of a simulator with a well known computer programming technology, and the
combination of a low cost virtual reality language. The development of the simulator also used an easy
to use mathematical model builder to run the calculations necessary for a small UAV aircraft. It is
correct to say that a large scale simulator can be developed by these three technologies, but
unfortunately, low cost simulators cannot provide the safety parameters necessary to be able to assist
6

with the designing of a large scale aircraft when human aircraft is involved. However, since UAVs are
unmanned, safety issues do not really plaque the development of the aircraft. There are other conditions
that do involve safety with UAVs, but these factors do not affect the flight dynamics of the aircraft.
b. Simulator Capabilities
The specifications of the UAV Simulator and the topic of this paper were to build a simulator
using only two types of technologies. These two types were MATLAB GUIDE, and Simulink. VRML
was added because the 3D model used by MATLAB and Simulink is VRML. This simulator
accomplished being able to determine the rotation from an initial point to a target point, and the
trajectory of that point. This is different from other simulators because most of them are trying to
calculate other aspects of an aircraft in flight like wind and gravity. These factors are important to
understand when an aircraft is in flight, but for the purpose of this project, the calculation of the
trajectory and rotation was needed. Other aspects like gravity and wind can be included with other
versions of this simulator, but the most important aspect of an aircraft is the ability to get from one
destination to another. With the Simulator and a Simulink model, the trajectory was calculated which
provided all points in the trajectory from the initial point to the target point. The Simulink model also
calculates the angle of rotation, velocity, and angular velocity. The Graphical User Interface (GUI)
provides an easy to understand input application. The GUI provides information like all points in the
trajectory, plotted points of initial and target points. The GUI also has an embedded 3D application
which was developed using the Simulink 3D animation block set and VRML.

III.

WHAT WAS ACCOMPLISHED

a. Application Capabilities
The UAV simulator was designed for the sole purpose of easy development. It was not designed
for the expert aircraft designer or pilot. Its purpose was to create simulation of a UAV developed by the
USU CSOIS department. The main goals were to make a 3D representation of the UAV, and to include
all rotations in its trajectory. What was accomplished was a 3D model in a 2D coordinate system. The
input of the simulator can only take in 2D coordinates and show the x, y trajectory, but the view of the
aircraft can be viewed in 3D. The most important aspect of the simulator was that it is easy to use.
Basic plot calculations are accomplished by the simulator, and not by the user. The calculations are
calculated using Simulink, and the results are plotted on the embedded 3D simulation canvas using
MATLAB.

b. The Graphical Interface (GUI)\


The GUI was designed using GUIDE which is the MATLAB GUI design module. It consists of
basic GUIDE toolbox components. Most of the controls on the form were easily placed using the drag
and drop functionality of the GUIDE. No advanced Active X components were used because ease of
development was important to the development of the application. Active X components are additional
tools used to develop GUIs that include program libraries outside the scope of the parent application. In
figure 1 the GUI shows how user friendly the application is for the novice user. There are no advanced
terms like inertia or the forces involved in flying an aircraft.

Figure 1- Shows the Graphical Interface of the USU Simulator

Figure 2- The first selection the user must make to run the application.

The selections of Dynamic and Static allow the user to determine what mode to run the simulator
in. Dynamic mode allows the simulator to run a trajectory which calculates all points in between the
initial and target points. The Static mode just moves the UAV simulator object to the target point.
Rotation is calculated from the initial and target points by the application.
The two radio buttons that were used for this selection was from the GUIDE toolbox, grouped
together by the button group component. Figure 3 shows the location of the two components in the
GUIDE toolbox.

Figure 3-Shows the radio and button group controls

These two radio button were programmed to run a simple function method that creates the UAV
in the embedded 3D model section of the graphical user interface, and in this callback function, it has
method to calculate each UAVs trajectory.
The next part of the graphical user interface is where the user plots their points, and creates the
UAVs. Each UAV must be created separately when in Static mode because static mode was designed to
run with single to multiple UAVs. In figure 4, it shows the design feature of the users input, and the
way the check boxes to create the UAV.

Figure 4- User input

With the user input section of the graphical user interface, if the user inputs a non integer value
or a value out of range, and tries to create a UAV, the user is presented with an error telling them which
values need correcting.
The design of the input values used an edit box from the GUIDE toolbox, and the Create UAV
check boxes used the check box control. Figure 5 shows those controls on the GUIDE.

10

Figure 5-Check box and edit box controls

For the individual edit box controls there was no programming involved in the development of
the application. The Checkbox controls involved some source code to be developed which was for
creating the UAV and running an error check for correct values in the inputs.
The last section of the user input is the Start Simulator button. The button is located at the
bottom of the trajectory table. Once the button is pressed, the simulation runs and the user are able to see
the simulation on the embedded canvas 3D model. Figure 6 is an image of the trajectory table and Start
Simulator button.

Figure 6

The most important part of the GUI is the 3D embedded model of the UAVs. This was created
using a vrcanvas object, and was created for easy access to visually view the 3D world. Figure 7 shows
the three UAVs set at their initial points.

11

Figure 7-3D Canvas

This figure is the only component that is not located on the GUIDE toolbox. In order to
incorporate the 3D canvas, the developer must include the following programming code into the start of
the application. The reason why it is included at startup is because the 3D Canvas must have 3D world
object in memory in order to view a 3D world. If the following source code was not implemented, at
startup the 3D canvas would not load, and the user would not be able to see the 3D world.
%gets the global variable for the vrworld object
global USUUAVVRMLWorld;
% sets the 3D canvas on the GUI interface.
USUUAVCanvas = vr.canvas(USUUAVVRMLWorld, gcf, [660 60 500 500]);
set(USUUAVCanvas,'Units','normalized');
% c1.Viewpoint='Left_View';

There is not a lot of source code involved in getting this image to embed into the graphical user
interface. Other than having a 3D world object in memory, it is important to know the exact position of
where you want to place the canvas on your graphical user interface. This is important because the
canvas would appear in a location not suitable for the simulator.

12

c. MATLAB Created Functions


All custom made MATLAB functions are listed in Appendix A. They are listed with a brief
description which includes the parameters of the function. Each function has a particular reason for
their creation. All source code is also listed for the application, and can be found in appendix B.
d. Simulink Model
The Simulink model used for the Dynamic mode of the simulator is called co_seeker.mdl. This
Simulink model was designed by Yaojin Xu, a Ph.D student from the Utah State University Center for
Self Organizing and Intelligent Systems department. This model retrieves an external value for initial
and target for each UAV. The following figure is an image of that model. It is important to know that
the model receives to external target values in the form of a 1x3 matrix which are stored in a global
variable in the base workspace of MATLAB when the application is run. The two variables are Xt and
Yt. The vehicle block in the Simulink model also must have its initial value changed to run. In order to
change the values in these blocks the following code must be incorporated into the application.
%Sets the parameters of the Simulink model
set_param('co_seeking/vehicle3', 'Xc_0', num2str(XiUAV(1)));
set_param('co_seeking/vehicle3', 'Yc_0', num2str(YiUAV(1)));
set_param('co_seeking/vehicle1', 'Xc_0', num2str(XiUAV(2)));
set_param('co_seeking/vehicle1', 'Yc_0', num2str(YiUAV(2)));
set_param('co_seeking/vehicle2', 'Xc_0', num2str(XiUAV(3)));
set_param('co_seeking/vehicle2', 'Yc_0', num2str(YiUAV(3)));

The set_param commands set the values in the vehicle blocks, and are located in the
setAllCoordsForSimController function of the application.

13

Figure 8-co_seeking Simulink model diagram

The output of the model is a matrix of all x y theta values from the initial point to the final target
point. This model is what maps the trajectory of the UAV. Each value row of the matrix contains values
for the three trajectories.
e. VRML (Virtual Reality Model Language) Model File
VRML(Virtual Reality Model Language) is like HTML because it can have a text editor to create
a VRML file or a VRML designer can be used. The nodes of the language are easy to understand, but
even though it is easy to understand the syntax, knowledge about angles, positioning, and scaling is
necessary in developing VRML objects with this model language. VRML was decided on to build the
simulator because it is the easiest choice to learn, and incorporates well with Simulink and MATLAB.
Other applications like FlightGear can be used in conjunction with Simulink and MATLAB, but with
applications like flight gear, the knowledge of flight dynamics for the aircraft must already be known.
Another problem with using this application is that the UAV Simulator project is designed for Windows.
FlightGear newest version has Windows compiled software, but if you do not correctly create an aircraft
with all the dynamics involved FlightGear will fail to run. As of this writing, FlightGear has been made
aware of these problems, but no patches for the current version have come out to fix the issue. They do

14

plan on publishing a newer version sometime in August of 2011, and most of these Windows issues will
be resolved and addressed.
The main VRML file format for the simulator is the .wrl file USUUAVSimVRML2011.wrl. This
contains the scene of the 3D simulator, and is the world the UAV objects are created on. Changing
values in this file will create different affects on the 3D model. A suggestion when working with this
file would be to understand transformation nodes. Transformation nodes are created to affect the world
surrounding an object. This is important to know because to accurately set rotation or position for each
object in the vrworld understanding this concept will allow the developer to create 3D worlds and
objects with ease.
The VRML world axis is different than what is taught in school. The following image is the axis
used by VRML by default.

Figure 9-VRML Default Axis

With transformations nodes the developer can change the axis to one better understood by the
user. Also, if developers decide to conquer more advanced 3D techniques such as advanced camera
views, it is important to understand the techniques involved with using transformation nodes.
VRML is a markup language which means that it can be created using something as simple as a
text editor. However, there are a couple of graphical interfaces that can be used to create these files.
The one that was used for this simulation application is called V-Realm Builder. It has simple to
advanced VRML controls. Some examples of these controls are geometric shapes like cubes and
cylinders which can be easily created with this application. The reason why this application was used, is
because it actually comes preinstalled with a copy of Simulink and the 3D Animation toolbox. There are
other advanced VRML editors out there, but since V-Realm builder comes preinstalled with Simulink
15

3D Animation Toolbox. It is easy to use, and cost effective for departments with access to MATLAB and
Simulink. The following figure is an image of the graphical interface of V-Realm.

Figure 10

Shapes are easy to build from the default geometric shapes located in V-Realm builder, but for
the sake of time and because we were able to use the application Solid Works, the project developers
created the VRML file using this application. The following two figures show an example of the
SolidWorks image, and an image exported to VRML.

Figure 11- SolidWorks

SolidWorks was used instead of V-Realm builder because it provided a higher quality 3D image.
Unfortunately, the quality of VRML 3D image is not a very good quality in todays standards, but it is
effective and easy to use when designing a simulator.
16

Figure 12-V-Realm Builder

Developers can create a 3D image in any 3D image designer, but the 3D image designer must be
able to make have the option to export or save as a VRML file (.wrl) within the capabilities of the
application. Once the 3D model was completed, SolidWorks was no longer needed. SolidWorks was
used to save time with the creation of the 3D image. It was not listed as an application used to develop
the simulator, but the 3D image could have been created using V-Realm. For the source code of the
VRML file please see Appendix B.

17

IV.

OTHER RESEARCH

Since the simulator has the capability of monitoring the trajectory of three UAVs, research was
done on the Voronoi tessellation. The Voronoi tessellation is a method to be able to cover an area Even
though there was no implementation of a Voronoi Tessellation in the simulator, it was a topic that was
researched because eventually, the application will simulate the trajectory of multiple UAVs flying in
different areas of a region, and it is important to understand this concept because it involves the ability to
cover a region using an algorithm to solve the issue of covering different spaces and adjusting to the
other UAVs trajectories so there is no conflicting paths taken by the UAVS.
Another topic that was researched was contour mapping techniques. These techniques use
sensors to develop a contour map of regions. This is important because UAVs fly above all types of
terrain. It is important to understand the terrain you are flying in because of high altitude obstacles such
as mountains. The ability to know the locations of these obstacles is vital to a UAV flight path. Whether
the obstacles are located using sensors on the UAV or the ground, it is important to pass the information
on to the UAV flight controller so the UAV mission can be successful.

18

V.

RESULTS

The application was created with full 3D rotation, and x, y, z positioning in mind, but not all was
completed. 3D rotation was not implemented in the application. 3D rotation includes rotation for yaw,
pitch, and roll. The simulator only tackles the yaw rotation, but unfortunately the accuracy of the
rotation is not correct. The UAV does rotate, but the once at the target point the UAV does not point in
the correct direction. Another feature that was not accomplished by the project was the x, y, z
positioning. We were only able to develop a simulator that positions in the x, y plane. Even though
these features were not added to the simulator, they were thought of in the development of the
application. For future releases and updates, adding these design qualities can easily be accomplished.

19

VI.

CONCLUSION

A simulator that is easy to manipulate, easy to use with the ability to map the trajectory of an
aircraft was developed. The research to complete the UAV was first finding a development platform. It
was decided to use MATLAB, Simulink, and VRML. Once that was completed, the next step was to
learn the technologies involved. The first step was to learn VRML. It is easy to learn, but unfortunately,
since most references do not go into detail about the world coordinate system and ways to change it to
fit the system that MATLAB and Simulink used, we had to understand the topic of transformations.
Once, the understanding of transformation is completed the development of a 3D world is not
complicated. Developers can build their objects in the space provided, and can create a 3D world.
Another topic that was hard to understand was the use of viewpoints in VRML. Viewpoints
allow the user to view a VRML object in different camera aspects. With the viewpoints you need to
know rotation and position of the world coordinate system where your object is located. This is another
reason why transformations are so important to understand. You can have a viewpoint in a
transformation and adjust the camera to the transformation and position the camera were it is needed.
Another accomplishment was the ability to calculate the trajectory of an initial and target point.
It is not hard to calculate these positions, but having so many points in the trajectory of a aircraft flight,
it is a lot of work to get all the points between the initial and target positions. It is easier to provide this
information through a program of a predefined process.
The application has an easy to use GUI. Designed with this in mind, the user needs little training
on how to actually run the simulation. All controls are labeled so novice users can use, and the ability to
visually represent the trajectory of the UAV is very important to the user.
Another feature about the application is that it is easy to update. Link a Simulink model to
update the embedded 3D world only takes the manipulation of a variable located in the global
workspace of the application, and running one of the functions listed in Appendix A.
20

When the simulator project time frame was completed, the main question that was asked was
what we would do to make the simulator more accurate if we had more time on the project? The ability
to add roll and pitch is very important to the design of an aircraft. This is important because the aircraft
is not fixed in one plane. It rotates in many directions. The ability to show this feature allows the user
to understand the different possible conditions necessary to run fly the aircraft. Also, flying the aircraft
in a xyz coordinate system is very important. It was decided to create the simulator without the z
coordinate because of the time to research, and develop the simulator was limited If more time was
given for the project it would not be difficult to program the z coordinate into the simulator.
Another feature that could add to the simulator is the calculation of forces on the UAV. Adding
these calculations makes it easy to develop an aircraft with the proper conditions in mind. Using
Simulink, these forces can be calculated and applied to the simulation. Research of the Simulink
Aerospace block set includes such calculations such as wind speed.

21

APPENDIX A
CreateUAV

This function is to create each UAV object in the VRML file. The arguments for this function are
UAVNum and VRMLWorldObj. The UAVNum is the number that is associated with the UAV to be
created. This value can be 1, 2, and 3. The VRMLWorldObj is used to retrieve the value of the vrworld
object located in memory.

DeleteUAV

To delete a UAV from the vrworld object you need to run this function. The argument list of this
function is UAVNum and VRMLWorldObj. The UAVNum is the number that is associated with the
UAV to be created. This value can be 1, 2, and 3. The VRMLWorldObj is used to retrieve the value of
the vrworld object located in memory.

SetScaleDownCoordinates

This function sets the values of the initial and target points, and scales them down to the
appropriate scale for the embedded VRML world. The parameter for this function is SetScaleUAVNum.
This value is the values of the selected UAV to be created. Values can be 1, 2, and 3.

SetScaleDownDynamicCoordinates

22

This function is used to scale down all coordinates created by the Simulink model co_seeking.
There are not parameters for this function, but the global variable DynamicTrajectoryPoints must exist
in the MATLAB workspace base for the function to run correctly.

SetWorldCoordinates

This function retrieves the max and min values of the x and y axis. A variable name
WorldCoordinate must be in the MATLAB workspace for this function to work.

UAVErrorCheckOK

This function is used to make sure that all values the user inputs are correct. If a value is
incorrect or not in the edit box to create a UAV this function will trigger and return true or false. The
parameters for this function are isStatic and UAVNumber. The isstatic must be false or true. It
determines if the mode is static or not. UAVNumber is the number of the UAV to be created.

calculateTheta

This value calculates the angle between two points. It is actually not longer used in the
application, but was kept because it could help solve the rotation with the simulator. The parameters for
the function are y, x. y is the value of dy and x is the value of dx.

Controller

23

The controller function is used by the co_seeking Simulink model. It calculates the velocity for
the UAVs. Its parameter is x which is a matrix of points for all targets within a trajectory.

deleteProtoUAV

This function is used to delete the VRML protocol in the VRML World file. This is run when the
application closes. This is important because the protocol is created in the VRML file, and saved as an
external proto. Some VRML designers like V-Realm builder do not support external protocols, and need
to be deleted. The parameter for this function is VRMLWorldObj which is the VRML World object
located in the system. This value is a global variable and the world VRML object must be in memory
for it to work.

enableDynamicMode

This function was created to set the application for dynamic mode. It sets the Create/Delete
UAVs to delete or create a UAV when the button is pressed. The button also hides the create UAV
checkboxes because they are not needed in dynamic mode.

enableStaticMode

This function puts the application in static mode. The purpose of this function is to hide the
Create/Delete UAVs button when the function is ran because this button does not work in static mode.
No parameters are required for this function.

24

getCoordsFromUAVForm

This function retrieves all input entered by the user, and creates three matrices called
UAV1CoordMatrixFromForm, UAV2CoordMatrixFromForm, and UAV3CoordMatrixFromForm. This
function has one parameter called AllCoordUAVNum. This variable is used to determine the correct
UAV. Values for this parameter can be 1, 2, and 3.

getScaleDownCoordinates

This function retrieves the scaled down coordinates for static mode. It has one parameter called
USUUAVNum. This parameter indicates which UAVs coordinate needs to be retrieved. The value for
this parameter can be 1, 2, and 3.

getTargetPoints

This function retrieves the scaled down target points for the indicated UAV. It has one parameter
UAVNum1. This parameter determines which UAVs coordinates is being retrieved. The value for this
parameter can be 1, 2, and 3.

getWorldCoordinates

This function retrieves the values for the world coordinate system to be used by calling function
for calculating coordinates that need to be scaled down. No parameters exist for this function.

globals
25

The globals.m file is a MATLAB script file. It creates global variables that need to be setup
when the application first starts. It also adds the external prototype VRML block to the main VRML
world file.

moveToDynamicTarget

This function moves the UAVs to their target point in dynamic mode. It sets the translation
nodes in the VRML file for each object and moves the object. There are no parameters in the function.

StaticMovetoTargets

This function moves the UAV to its target point from its initial point. This is used when the
application is in static mode. The parameters for this function are UAVNum1 and VRMLWorldObj.
The value for the UAVNum1 parameter is 1, 2, or 2. The value for VRMLWorldObj is a VRML world
object located in memory.

runcontrollerSimulator

This function runs the Simulink model co_seeking. The models output is a matrix of all
trajectory coordinates for all three UAVs.

setAllCoordsForSimController

26

This function sets all variables, and Simulink block parameters needed to run the Simulink
model co_seeking. No parameters are required for this

SetCoordsFromUAVForm

This function sets all values from the user input into three matrices called
UAV1CoordMatrixFromForm, UAV2CoordMatrixFromForm, and UAV3CoordMatrixFromForm. It
contains one parameter called UAVNum. UAVNum refers to a UAV to be created, and the value can be
1, 2, or 3.

setTrajectoryGrid

This function sets the TrajectoryGrid global variable for the uitable on the GUI. This grid is
available in the Dynamic mode. No parameter is needed for the function.

27

Appendix B
Source Code:
CreateUAV
%**************************************************************************
%Creates a UAV in the VRML World.
%**************************************************************************
function CreateUAV(UAVNum, VRMLWorldObj)
%Stores and gets VRML Node into memory
UAVvrNodeObj = vrnode(VRMLWorldObj, strcat('trUAV',num2str(UAVNum),'Parent'));
%Using the UAVvrNodeObj it adds the Proto to the VRML World. This Prototype
%is the object of the UAV.
UAVParentNodeObj = vrnode(UAVvrNodeObj,'children', strcat('UAV',
num2str(UAVNum),'Model'),strcat('UAV',num2str(UAVNum),'Model'));
%Function calls to set Rotation and position.
setStaticRotation(UAVNum,VRMLWorldObj) ;
setTranslation(UAVNum, VRMLWorldObj);
setInitialRotation(UAVNum, VRMLWorldObj);

function setTranslation(UAVNum,VRMLWorldObj )
%Sets translation
USUUAVInitialPoint = USUUAVCreateInitialPoint(UAVNum);
UAVTranslationMatrix = [USUUAVInitialPoint(1) USUUAVInitialPoint(2)
USUUAVInitialPoint(3)];
%UAVTranslationMatrix = [100 100 -100];
UAVTransObj = vrnode(VRMLWorldObj, strcat('trUAV',num2str(UAVNum),'Parent'));
UAVTransObj.translation = UAVTranslationMatrix;
function setStaticRotation(UAVNum, VRMLWorldObj)
%Sets the startup rotation
RotMatrix = [ 1 0 0 90];
USUUAVStaticRotationPoint = vrnode(VRMLWorldObj, strcat('UAV',
num2str(UAVNum),'Model'));
USUUAVStaticRotationPoint.rot = RotMatrix;
USUUAVStaticRotationPoint.ImageSize = [10 10 10];
function setInitialRotation(UAVNum,VRMLWorldObj)
%Sets the initial rotaion
AllScaledCoordinates = getScaleDownCoordinates(UAVNum);
USUUAVdXValue = AllScaledCoordinates(3) - AllScaledCoordinates(1);
USUUAVdYValue = AllScaledCoordinates(4) - AllScaledCoordinates(2);
USUUAVRotaionRadians = 90;% calculateTheta(USUUAVdYValue, USUUAVdXValue);
USUUAVStaticRotationPoint = vrnode(VRMLWorldObj,
strcat('trUAV',num2str(UAVNum),'Parent'));
USUUAVStaticRotationPoint.rotation = [0 0 1 USUUAVRotaionRadians];
UAVThetaObj = findobj(gcf,'-depth',inf,'Tag',strcat('UAV',
num2str(UAVNum),'Theta'));
set(UAVThetaObj,'String', num2str(USUUAVRotaionRadians));

28

DeleteUAV
%*************************************************************************
%Deletes the UAV object from memory
%*************************************************************************
function DeleteUAV(UAVNum,VRMLWorldObj )
%Retrieves the VRML nodel with the name of the parent UAV node
getUSUUAVNode = vrnode(VRMLWorldObj, strcat('UAV', num2str(UAVNum),'Model'));
%Command to delete the selected UAV
delete(getUSUUAVNode);
SetScaleDownCoordinates
%**************************************************************************
%Scale down coordinates from user input
%**************************************************************************
function SetScaleDownCoordinates(SetScaleUAVNum)
%Retrieves the world Coordinate
WorldCoordinate = double(getWorldCoordinates());
%Retrieves the coordinates from the GUI
AllUAVCoordMatrixFromForm = getCoordsFromUAVForm(SetScaleUAVNum);
%Is ran if SetScaleUAVNum = 1
%Scales the coordinate down to the worldcoordinate system.
if SetScaleUAVNum ==1
UAV1XInit = (AllUAVCoordMatrixFromForm(1)./double(WorldCoordinate(1))) * 100;
UAV1YInit = (AllUAVCoordMatrixFromForm(2)./double(WorldCoordinate(1))) * 100;
UAV1XTar = (AllUAVCoordMatrixFromForm(3)./double(WorldCoordinate(1))) * 100;
UAV1YTar = (AllUAVCoordMatrixFromForm(4)./double(WorldCoordinate(1))) * 100;
UAV1ScaledUAVCoordinates = [UAV1XInit UAV1YInit UAV1XTar UAV1YTar];
assignin('base', 'UAV1ScaledUAVCoordinates', UAV1ScaledUAVCoordinates)
%Is ran if SetScaleUAVNum = 2
elseif SetScaleUAVNum ==2
UAV2XInit = (AllUAVCoordMatrixFromForm(1)/double(WorldCoordinate(1))) * 100;
UAV2YInit = (AllUAVCoordMatrixFromForm(2)/double(WorldCoordinate(1))) * 100;
UAV2XTar = (AllUAVCoordMatrixFromForm(3)/double(WorldCoordinate(1))) * 100;
UAV2YTar = (AllUAVCoordMatrixFromForm(4)/double(WorldCoordinate(1))) * 100;
UAV2ScaledUAVCoordinates = [ UAV2XInit UAV2YInit UAV2XTar UAV2YTar];
assignin('base', 'UAV2ScaledUAVCoordinates', UAV2ScaledUAVCoordinates)
%Is ran if SetScaleUAVNum = 3
elseif SetScaleUAVNum ==3
UAV3XInit = (AllUAVCoordMatrixFromForm(1)/WorldCoordinate(1)) * 100;
UAV3YInit = (AllUAVCoordMatrixFromForm(2)/WorldCoordinate(1)) * 100;
UAV3XTar = (AllUAVCoordMatrixFromForm(3)/WorldCoordinate(1)) * 100;
UAV3YTar = (AllUAVCoordMatrixFromForm(4)/WorldCoordinate(1)) * 100;
UAV3ScaledUAVCoordinates = [UAV3XInit UAV3YInit UAV3XTar UAV3YTar];
assignin('base', 'UAV3ScaledUAVCoordinates', UAV3ScaledUAVCoordinates)
end

29

SetScaleDownDynamicCoordinates
%**************************************************************************
%Scales down the Dynamic values to world coordinates
%**************************************************************************
function SetScaleDownDynamicCoordinates()
%Retrieves World Coordinates
WorldCoordinate = double(getWorldCoordinates());
%Retrieves all points to create a Dynamic Trajectory
AllUAVDynamicCoordFromFile = evalin('base','DynamicTrajectoryPoints');
USUUAVScaledCoordinatesLocal=[];
%Loop creates a matrice of all scaled dynamic coordinates for all three
%UAVs.
for i = 1 : size(AllUAVDynamicCoordFromFile)
USUUAVScaledCoordinatesLocal(i,1) =
(AllUAVDynamicCoordFromFile(i,1)./double(WorldCoordinate(1))) * 100;
USUUAVScaledCoordinatesLocal(i,2) =
(AllUAVDynamicCoordFromFile(i,2)./double(WorldCoordinate(1))) * 100;
USUUAVScaledCoordinatesLocal(i,3) = AllUAVDynamicCoordFromFile(i,3);
USUUAVScaledCoordinatesLocal(i,4) =
(AllUAVDynamicCoordFromFile(i,4)./double(WorldCoordinate(1))) * 100;
USUUAVScaledCoordinatesLocal(i,5) =
(AllUAVDynamicCoordFromFile(i,5)./double(WorldCoordinate(1))) * 100;
USUUAVScaledCoordinatesLocal(i,6) = AllUAVDynamicCoordFromFile(i,6);
USUUAVScaledCoordinatesLocal(i,7) = AllUAVDynamicCoordFromFile(i,7);
USUUAVScaledCoordinatesLocal(i,8) = AllUAVDynamicCoordFromFile(i, 8);
USUUAVScaledCoordinatesLocal(i,9) = AllUAVDynamicCoordFromFile(i,9);

end

%assigns a global variable to the base workspace.


assignin('base','USUUAVScaledCoordinates', double(USUUAVScaledCoordinatesLocal));

SetWorldCoordinates
%**************************************************************************
%Saves the world settings to file for use when the application startsup
%**************************************************************************
function SetWorldCoordinates(WorldMax,ToSave)
%Calculates WorldCoords for all directions
WorldCoords = [WorldMax WorldMax (-1 * WorldMax) (-1 * WorldMax)];
%Saves to file if ToSave = true
if ToSave == true
csvwrite('SimulatorSettings/DefaultWorldCoordinates.dat', WorldCoords);
end
%Creates global variable for world cordinates
assignin('base','WorldCoordinate', WorldCoords);

30

UAVErrorCheckOK
%While createing UAV function or with multiple UAVs
%object or a group.
% isStatic = true if running in static mode
%isStatic = False if Running in dynamic
%
function UAVCreateUAVCheckForErrorsOk = UAVErrorCheckOK(isStatic, UAVNumber)
global AllUAVErrorMatrix;
%Gets world coordinates
WorldCoordinate = getWorldCoordinates();
%Retrieves user input
AllUSUUAVCoordinates = getCoordsFromUAVForm(UAVNumber);
UAVCreateUAVCheckForErrorsOk = true;
%creates a string array for a list of errors reported when creating a UAV
UAVError = [];
err = [];
%Gets the value of the globally created matrix
AllUAVCoordMat = [AllUSUUAVCoordinates(1) AllUSUUAVCoordinates(2)
AllUSUUAVCoordinates(3) AllUSUUAVCoordinates(4)];
%gets Number of Rows and Columns for the UAV
[AllUAVCoordMatNumOfRows, AllUAVCoordMatNumOfColumns] = size(AllUAVCoordMat);
%Builds and retrieves Form objects
%------------------Build-------------------------------------xinitUAVObj = findobj(gcf,'-depth',inf,'Tag',strcat('UAV',num2str(UAVNumber),
'ArrowXInit'));
yinitUAVObj = findobj(gcf,'-depth',inf,'Tag',strcat('UAV',num2str(UAVNumber),
'ArrowYInit'));
xtarUAVObj = findobj(gcf,'-depth',inf,'Tag',strcat('UAV',num2str(UAVNumber),
'ArrowXTar'));
ytarUAVObj = findobj(gcf,'-depth',inf,'Tag',strcat('UAV',num2str(UAVNumber),
'ArrowYTar'));
UAVObjects = [xinitUAVObj yinitUAVObj xtarUAVObj ytarUAVObj];
xinitUAVTagObj = findobj(gcf,'-depth',inf,'Tag',strcat('UAV',num2str(UAVNumber),
'TagXInit'));
yinitUAVTagObj = findobj(gcf,'-depth',inf,'Tag',strcat('UAV',num2str(UAVNumber),
'TagYInit'));
xtarUAVTagObj = findobj(gcf,'-depth',inf,'Tag',strcat('UAV',num2str(UAVNumber),
'TagXTar'));
ytarUAVTagObj = findobj(gcf,'-depth',inf,'Tag',strcat('UAV',num2str(UAVNumber),
'TagYTar'));
UAVTagMatrix = [xinitUAVTagObj yinitUAVTagObj xtarUAVTagObj ytarUAVTagObj];
%Determines if the Value stored in the AllUAVCoordMatrix global matrix is a
%NaN or checks to see if it is a valid input
for i = 1 : AllUAVCoordMatNumOfColumns
31

if AllUAVCoordMat(1,i) < 0 && isnan(AllUAVCoordMat(1,i)) == false


AllUAVCoordMatPositive = AllUAVCoordMat(1,i) * -1;
isnegative = 1;
elseif AllUAVCoordMat(1,i) >= 0 && isnan(AllUAVCoordMat(1,i)) == false
AllUAVCoordMatPositive = AllUAVCoordMat(1,i);
isnegative = 0;
else
end

AllUAVCoordMatPositive = 0/0;

%Determines if Values are greater than 100


if isnan(AllUAVCoordMatPositive) || AllUAVCoordMatPositive > WorldCoordinate(1)

%Determines if UAV1CoordMat element is nan


if isnan(AllUAVCoordMatPositive)
%turns Arrow next to obj On
set(UAVObjects(i),'Visible', 'on');
%Gets obj label
UAVPanelStringValue = get(UAVTagMatrix(i), 'String');
%Creates Error string
err = strcat('UAV',num2str(UAVNumber),':Input a Value for ' ,
UAVPanelStringValue);
if isempty(UAVError)
UAVError = err;
else
UAVError = strvcat(UAVError,err);
end
elseif AllUAVCoordMatPositive > WorldCoordinate(1) && isnegative == 0 &&
isnan(AllUAVCoordMatPositive) == false
%turns Arrow next to obj On
set(UAVObjects(i),'Visible', 'on');
%Gets obj label
UAVPanelStringValue = get(UAVTagMatrix(i), 'String');
%Creates Error string
err = strcat('UAV',num2str(UAVNumber),': Value in
',UAVPanelStringValue,' cannot be > ',num2str(WorldCoordinate(1)));
if isempty(UAVError)
UAVError = err;
else
UAVError = strvcat(UAVError,err);
end
elseif AllUAVCoordMatPositive > 100 && isnegative == 1 &&
isnan(AllUAVCoordMatPositive) == false
%turns Arrow next to obj On
set(UAVObjects(i),'Visible', 'on');
32

%Gets obj label


UAVPanelStringValue = get(UAVTagMatrix(i), 'String');
%Creates Error string
err= strcat('UAV',num2str(UAVNumber),':Value in ',
UAVPanelStringValue,'cannot be < ',num2str(WorldCoordinate(3)));
UAVError = strvcat(UAVError,err);
else
%sets the Arrow object of the input to hidden
set(UAVObjects(i),'Visible', 'off');
end
%sets the value of the function to false
UAVCreateUAVCheckForErrorsOk = false;
end
end
if isStatic == false
%if dynamic mode stores the all errors created in a global variable
AllUAVErrorMatrix = strvcat(AllUAVErrorMatrix,UAVError);
end
if UAVCreateUAVCheckForErrorsOk == false && isStatic == true
%Creates a meesage box with all errors
msgbox(UAVError, 'Static Mode Error Messages','error');
elseif UAVCreateUAVCheckForErrorsOk == false && isStatic == false && UAVNumber == 3
%Runs in dynmic mode if errors appear when submitting values to create a
%uav.
msgbox(AllUAVErrorMatrix,'Dynamic Error Messages', 'error');
end

calculateTheta
%**************************************************************************
%Sets the angle theta of the target and initial points
%**************************************************************************
function thetaCalc = calculateTheta(y,x)
%Calculates an angle from dx,dy and returns the value in degrees
thetaCalc = rad2deg(atan2(y,x));
%If angle falls between a value the following occurs
if thetaCalc <= 90 && thetaCalc >= -90
thetaCalc = -(90-thetaCalc);
else
if thetaCalc > 0
thetaCalc = thetaCalc - 90;
else
thetaCalc = 270 + thetaCalc;
end
end
Controller
33

%**************************************************************************
%Calculates the velocity
%**************************************************************************
function v=controller(x)
%uses the following global variables to run the model
global Xt Yt k
%Calculates velocity
for i=1:3
v(i)=k*sqrt( (Xt(i)-x(3*i-2))^2+(Yt(i)-x(3*i-1))^2 );
v(3+i)=atan2(Yt(i)-x(3*i-1),Xt(i)-x(3*i-2)) - x(3*i);
end
deleteProtoUAV
%**************************************************************************
%Deletes the proto created in the VRML file after the application is closed
%**************************************************************************
function deleteProtoUAV(VRMLWorldObj)
%Get protoUAV node
for i = 1:3
getUSUUAVNode = vrnode(VRMLWorldObj, strcat('protoUAV',num2str(i)));
end
%Deletes the protoUAV
delete(getUSUUAVNode);
%saves the External ProtoUAV file
save(VRMLWorldObj, 'USUUAVSim_VRMLFiles/UAVExternProto.wrl')
enableDynamicMode
%*************************************************************************
%Sets teh application for dynamic mode
%**************************************************************************
function enableDynamicMode(VRMLWorldObj)
%Setts the createUAVsDynamic button to visible
createUAVBtnObj = findobj(gcf,'-depth',inf,'Tag','createUAVsDynamic');
set(createUAVBtnObj, 'Visible','on')
for i=1:3
% hides all create UAV check boxes on GUI
createUAVBtnCheckObj = findobj(gcf,'depth',inf,'Tag',strcat('createUAV',num2str(i)));
set(createUAVBtnCheckObj, 'Visible','off')
end
enableStaticMode
%**************************************************************************
%Puts application in to static mode
%**************************************************************************
function enableStaticMode()
%sets the create uavs button to off
34

createUAVBtnObj = findobj(gcf,'-depth',inf,'Tag','createUAVsDynamic');
set(createUAVBtnObj, 'Visible','off')
%unhides all three create uavs check boxes
for i=1:3
createUAVBtnCheckObj = findobj(gcf,'depth',inf,'Tag',strcat('createUAV',num2str(i)));
set(createUAVBtnCheckObj, 'Visible','on')
end
getCoordsFromUAVForm
%***********************************************************************
%----Retrives Values for X initial Y Initial x target y target----%***********************************************************************
function setCoordsFromUAVForm(UAVNum)
%Creates a matrix of coordinates for each EAV depending on the UAV selected
if UAVNum ==1
UAV1 = getUAV1Coords();
assignin('base', 'UAV1CoordMatrixFromForm', UAV1);
elseif UAVNum ==2
UAV2 = getUAV2Coords();
assignin('base', 'UAV2CoordMatrixFromForm', UAV2);
elseif UAVNum ==3
UAV3 = getUAV3Coords();
assignin('base', 'UAV3CoordMatrixFromForm', UAV3);
end

function USUUAV1Coords = getUAV1Coords()


%------UAV1-----xinitUAV1Obj = findobj(gcf,'-depth',inf,'Tag','UAV1XInit');
yinitUAV1Obj = findobj(gcf,'-depth',inf,'Tag','UAV1YInit');
xtarUAV1Obj = findobj(gcf,'-depth',inf,'Tag','UAV1XTar');
ytarUAV1Obj = findobj(gcf,'-depth',inf,'Tag','UAV1YTar');
%----------------Edit Text Box Values(Initial and Target Variables) -----------xinitUAV1Value = str2double(get(xinitUAV1Obj, 'String'));
yinitUAV1Value = str2double(get(yinitUAV1Obj, 'String'));
xtarUAV1Value = str2double(get(xtarUAV1Obj, 'String'));
ytarUAV1Value = str2double(get(ytarUAV1Obj, 'String'));
USUUAV1Coords = [xinitUAV1Value yinitUAV1Value xtarUAV1Value ytarUAV1Value];

function USUUAV2Coords = getUAV2Coords()


%------UAV2-----xinitUAV2Obj = findobj(gcf,'-depth',inf,'Tag','UAV2XInit');
yinitUAV2Obj = findobj(gcf,'-depth',inf,'Tag','UAV2YInit');
xtarUAV2Obj = findobj(gcf,'-depth',inf,'Tag','UAV2XTar');
ytarUAV2Obj = findobj(gcf,'-depth',inf,'Tag','UAV2YTar');
35

%----------------Edit Text Box Values(Initial and Target Variables) -----------xinitUAV2Value = str2double(get(xinitUAV2Obj, 'String'));
yinitUAV2Value = str2double(get(yinitUAV2Obj, 'String'));
xtarUAV2Value = str2double(get(xtarUAV2Obj, 'String'));
ytarUAV2Value = str2double(get(ytarUAV2Obj, 'String'));
USUUAV2Coords = [xinitUAV2Value yinitUAV2Value xtarUAV2Value ytarUAV2Value];
function USUUAV3Coords = getUAV3Coords()
%------UAV3-----xinitUAV3Obj = findobj(gcf,'-depth',inf,'Tag','UAV3XInit');
yinitUAV3Obj = findobj(gcf,'-depth',inf,'Tag','UAV3YInit');
xtarUAV3Obj = findobj(gcf,'-depth',inf,'Tag','UAV3XTar');
ytarUAV3Obj = findobj(gcf,'-depth',inf,'Tag','UAV3YTar');
%----------------Get edit Text Box Values(Initial and Target Variables) -----------xinitUAV3Value = str2double(get(xinitUAV3Obj, 'String'));
yinitUAV3Value = str2double(get(yinitUAV3Obj, 'String'));
xtarUAV3Value = str2double(get(xtarUAV3Obj, 'String'));
ytarUAV3Value = str2double(get(ytarUAV3Obj, 'String'));
USUUAV3Coords = [xinitUAV3Value yinitUAV3Value xtarUAV3Value ytarUAV3Value];
getScaleDownCoordinates
%**************************************************************************
%Gets the scaled down coordinates of the UAV selected
%**************************************************************************
function USUUAVScaledDownCoords = getScaleDownCoordinates(USUUAVNum)
USUUAVScaledDownCoords = evalin('base',
strcat('UAV',num2str(USUUAVNum),'ScaledUAVCoordinates'));
getTargetPoints
%*************************************************************************
%Retrieves the target points of the selected UAV
%*************************************************************************
function USUUAVGetTargetPoint = getTargetPoints(UAVNum1)
XUAVTarMatrix =
evalin('base',strcat('UAV',num2str(UAVNum1),'ScaledUAVCoordinates'));
USUUAVGetTargetPoint = XUAVTarMatrix;
getWorldCoordinates
%*************************************************************************
%Retrieves the world coordinates
%*************************************************************************
function UAVUSUWorldCordinates = getWorldCoordinates()
UAVUSUWorldCordinates = evalin('base','WorldCoordinate');

globals
%Setup Global Variables

36

global USUUAVVRMLWorld;
USUUAVVRMLWorld = vrworld('USUUAVSim_VRMLFiles\USUUAVSimVRML2011');
open (USUUAVVRMLWorld);
addexternproto(USUUAVVRMLWorld, 'USUUAVSim_VRMLFiles/UAVExternProto.wrl',
'protoUAV1', 'UAV1Model');
addexternproto(USUUAVVRMLWorld, 'USUUAVSim_VRMLFiles/UAVExternProto.wrl',
'protoUAV2', 'UAV2Model');
addexternproto(USUUAVVRMLWorld, 'USUUAVSim_VRMLFiles/UAVExternProto.wrl',
'protoUAV3', 'UAV3Model');
global USUUAVNum;
USUUAVNum = [0 0 0];
moveToDynamicTarget
%**************************************************************************
%Moves teh targets to their target point. (Dynamic mode)
%**************************************************************************
function moveToDynamicTarget()
global USUUAVVRMLWorld
%Gets the dynamic coords
TrajectoryMatrix = evalin('base','USUUAVScaledCoordinates');
%Gets size of the dynamic matrix
[row col] = size(TrajectoryMatrix);
%Creates MAtrix to store the Dynamic coords for eadch UAV
UAV1TranslationMatrix = zeros(row,3);
UAV2TranslationMatrix = zeros(row,3);
UAV3TranslationMatrix = zeros(row,3);
%Creates Matrix to
UAV1RotationMatrix
UAV2RotationMatrix
UAV3RotationMatrix

store the rotation coords for eadch UAV


= zeros(row,1);
= zeros(row,1);
= zeros(row,1);

%Retrieves parent nodes of UAVS


UAV1TransObj = vrnode(USUUAVVRMLWorld, 'trUAV1Parent');
UAV2TransObj = vrnode(USUUAVVRMLWorld, 'trUAV2Parent');
UAV3TransObj = vrnode(USUUAVVRMLWorld, 'trUAV3Parent');
%These values need
%dynamically
sync(UAV1TransObj,
sync(UAV2TransObj,
sync(UAV3TransObj,

to be added to the VRML world so that all changes happen


'translation', 'on')
'translation', 'on')
'translation', 'on')

sync(UAV1TransObj, 'rotation', 'on')


sync(UAV2TransObj, 'rotation', 'on')
sync(UAV3TransObj, 'rotation', 'on')
%Creates a matrix for each point in the dynamic matrix
for i = 1:row
UAV1TranslationMatrix(i,1) = TrajectoryMatrix(i,1);
UAV1TranslationMatrix(i,2) = TrajectoryMatrix(i,2);
UAV1TranslationMatrix(i,3) = -100;
UAV1RotationMatrix(i) = TrajectoryMatrix(i,3);
UAV2TranslationMatrix(i,1) = TrajectoryMatrix(i,4);
UAV2TranslationMatrix(i,2) = TrajectoryMatrix(i,5);
UAV2TranslationMatrix(i,3) = -100;
37

UAV2RotationMatrix(i) = TrajectoryMatrix(i,6);
UAV3TranslationMatrix(i,1) = TrajectoryMatrix(i,7);
UAV3TranslationMatrix(i,2) = TrajectoryMatrix(i,8);
UAV3TranslationMatrix(i,3) = -100;
UAV3RotationMatrix(i) = TrajectoryMatrix(i,9);
end
%Creates global variables in the base workspace
assignin('base','UAV1coords',UAV1TranslationMatrix);
assignin('base','UAV2coords',UAV2TranslationMatrix);
assignin('base','UAV3coords',UAV3TranslationMatrix);
assignin('base','UAV1Rot',UAV1RotationMatrix);
assignin('base','UAV2Rot',UAV2RotationMatrix);
assignin('base','UAV3Rot',UAV3RotationMatrix);
%assigns the values to the position and rotation of each UAV
for k =1:row
UAV1TransObj.translation = [UAV1TranslationMatrix(k,1) UAV1TranslationMatrix(k,2)
UAV1TranslationMatrix(k,3)];
UAV2TransObj.translation = [UAV2TranslationMatrix(k,1) UAV2TranslationMatrix(k,2)
UAV2TranslationMatrix(k,3)];
UAV3TransObj.translation = [UAV3TranslationMatrix(k,1) UAV3TranslationMatrix(k,2)
UAV3TranslationMatrix(k,3)];
UAV1TransObj.rotation = [0 0 1 (UAV1RotationMatrix(k))];
UAV2TransObj.rotation = [0 0 1 (UAV2RotationMatrix(k))];
UAV3TransObj.rotation = [0 0 1 (UAV3RotationMatrix(k))];
%Controls the speed of the dynamic movement of each UAV
pause(1/8);
end
StaticMovetoTargets
%**************************************************************************
%Moves UAVs to target points-(Static Mode)
%**************************************************************************
function StaticMovetoTargets(UAVNum1, VRMLWorldObj)
%Sets the values for the position and the rotation of the uav selectd
USUUAVTargetPoint = getTargetPoints(UAVNum1);
UAVTranslationMatrix = [USUUAVTargetPoint(3) USUUAVTargetPoint(4) -100];
UAVTransObj = vrnode(VRMLWorldObj, strcat('trUAV',num2str(UAVNum1),'Parent'));
UAVTransObj.translation = UAVTranslationMatrix;
rotationAngle = getRotation(UAVNum1,USUUAVTargetPoint) + 90
UAVTransObj.rotation = [0 0 1 rotationAngle];
%Creates a rotation for the select uav
function USUUAVGetRotation = getRotation(UAVNum1, targetCoords)
XUAVInitMatrix =
evalin('base',strcat('UAV',num2str(UAVNum1),'ScaledUAVCoordinates'));
dx = targetCoords(3) - XUAVInitMatrix(1);
dy = targetCoords(4) - XUAVInitMatrix(2);
38

USUUAVGetRotation = calculateTheta(dy, dx);


runcontrollerSimulator
%**************************************************************************
%Runs the Simulink model-co_seeker
%**************************************************************************
function runcontrollerSimulator()
global Xt Yt k simout
Xt = evalin('base','Xt1');
Yt = evalin('base','Yt1');
k = evalin('base','k1');
load_system('co_seeking');
sim('co_seeking',8);
assignin('base','DynamicTrajectoryPoints',simout);
return;
setAllCoordsForSimController
.
%**************************************************************************
%Moves teh targets to their target point. (Dynamic mode)
%**************************************************************************
function AllCoordsSimisSet =setAllCoordsForSimController()
%Retrieves coordinates for each uav
for i = 1:3
CoordsInFile=evalin('base',strcat('UAV',num2str(i),'CoordMatrixFromForm'));
XtUAV(i) = CoordsInFile(3);
YtUAV(i) = CoordsInFile(4);
XiUAV(i) = CoordsInFile(1);
YiUAV(i) = CoordsInFile(2);
end
%Creates global variables in MATLAB Workspace
assignin('base','Xt1', double(XtUAV));
assignin('base','Yt1', double(YtUAV));
assignin('base','k1', double(.5));
%Loads the Simulink Model
load_system('co_seeking');
%Sets the parameters of the Simulink model
set_param('co_seeking/vehicle3', 'Xc_0', num2str(XiUAV(1)));
set_param('co_seeking/vehicle3', 'Yc_0', num2str(YiUAV(1)));
set_param('co_seeking/vehicle1', 'Xc_0', num2str(XiUAV(2)));
set_param('co_seeking/vehicle1', 'Yc_0', num2str(YiUAV(2)));
set_param('co_seeking/vehicle2', 'Xc_0', num2str(XiUAV(3)));
set_param('co_seeking/vehicle2', 'Yc_0', num2str(YiUAV(3)));
%Saves the Simulink Model
save_system('co_seeking');
39

%Closes the Simulink Model


close_system('co_seeking');

SetCoordsFromUAVForm
%***********************************************************************
%----Retrives Values for X initial Y Initial x target y target----%***********************************************************************
function setCoordsFromUAVForm(UAVNum)
%Creates a matrix of coordinates for each EAV depending on the UAV selected
if UAVNum ==1
UAV1 = getUAV1Coords();
assignin('base', 'UAV1CoordMatrixFromForm', UAV1);
elseif UAVNum ==2
UAV2 = getUAV2Coords();
assignin('base', 'UAV2CoordMatrixFromForm', UAV2);
elseif UAVNum ==3
UAV3 = getUAV3Coords();
assignin('base', 'UAV3CoordMatrixFromForm', UAV3);
end

function USUUAV1Coords = getUAV1Coords()


%------UAV1-----xinitUAV1Obj = findobj(gcf,'-depth',inf,'Tag','UAV1XInit');
yinitUAV1Obj = findobj(gcf,'-depth',inf,'Tag','UAV1YInit');
xtarUAV1Obj = findobj(gcf,'-depth',inf,'Tag','UAV1XTar');
ytarUAV1Obj = findobj(gcf,'-depth',inf,'Tag','UAV1YTar');
%----------------Edit Text Box Values(Initial and Target Variables) -----------xinitUAV1Value = str2double(get(xinitUAV1Obj, 'String'));
yinitUAV1Value = str2double(get(yinitUAV1Obj, 'String'));
xtarUAV1Value = str2double(get(xtarUAV1Obj, 'String'));
ytarUAV1Value = str2double(get(ytarUAV1Obj, 'String'));
USUUAV1Coords = [xinitUAV1Value yinitUAV1Value xtarUAV1Value ytarUAV1Value];

function USUUAV2Coords = getUAV2Coords()


%------UAV2-----xinitUAV2Obj = findobj(gcf,'-depth',inf,'Tag','UAV2XInit');
yinitUAV2Obj = findobj(gcf,'-depth',inf,'Tag','UAV2YInit');
xtarUAV2Obj = findobj(gcf,'-depth',inf,'Tag','UAV2XTar');
ytarUAV2Obj = findobj(gcf,'-depth',inf,'Tag','UAV2YTar');
%----------------Edit Text Box Values(Initial and Target Variables) -----------xinitUAV2Value = str2double(get(xinitUAV2Obj, 'String'));
yinitUAV2Value = str2double(get(yinitUAV2Obj, 'String'));
40

xtarUAV2Value = str2double(get(xtarUAV2Obj, 'String'));


ytarUAV2Value = str2double(get(ytarUAV2Obj, 'String'));
USUUAV2Coords = [xinitUAV2Value yinitUAV2Value xtarUAV2Value ytarUAV2Value];
function USUUAV3Coords = getUAV3Coords()
%------UAV3-----xinitUAV3Obj = findobj(gcf,'-depth',inf,'Tag','UAV3XInit');
yinitUAV3Obj = findobj(gcf,'-depth',inf,'Tag','UAV3YInit');
xtarUAV3Obj = findobj(gcf,'-depth',inf,'Tag','UAV3XTar');
ytarUAV3Obj = findobj(gcf,'-depth',inf,'Tag','UAV3YTar');
%----------------Get edit Text Box Values(Initial and Target Variables) -----------xinitUAV3Value = str2double(get(xinitUAV3Obj, 'String'));
yinitUAV3Value = str2double(get(yinitUAV3Obj, 'String'));
xtarUAV3Value = str2double(get(xtarUAV3Obj, 'String'));
ytarUAV3Value = str2double(get(ytarUAV3Obj, 'String'));
USUUAV3Coords = [xinitUAV3Value yinitUAV3Value xtarUAV3Value ytarUAV3Value];
setTrajectoryGrid
%*************************************************************************
%Creates the variable used to populate teh uitable grid on the
%gui-(dynamioc mode)
%**************************************************************************
function setTrajectoryGrid()
TrajectoryGrid = evalin('base', 'DynamicTrajectoryPoints');
assignin('base','TrajectoryGrid',TrajectoryGrid);
xinitUAV1Obj = findobj(gcf,'-depth',inf,'Tag','TrajofUAV');
set(xinitUAV1Obj, 'Data', TrajectoryGrid)
USUUAVSimMainGUI
function varargout = USUUAVSimMainGUI(varargin)
% USUUAVSIMMAINGUI MATLAB code for USUUAVSimMainGUI.fig
%
USUUAVSIMMAINGUI, by itself, creates a new USUUAVSIMMAINGUI or raises the
existing
%
singleton*.
%
%
H = USUUAVSIMMAINGUI returns the handle to a new USUUAVSIMMAINGUI or the
handle to
%
the existing singleton*.
%
%
USUUAVSIMMAINGUI('CALLBACK',hObject,eventData,handles,...) calls the local
%
function named CALLBACK in USUUAVSIMMAINGUI.M with the given input arguments.
%
%
USUUAVSIMMAINGUI('Property','Value',...) creates a new USUUAVSIMMAINGUI or
raises the
%
existing singleton*. Starting from the left, property value pairs are
%
applied to the GUI before USUUAVSimMainGUI_OpeningFcn gets called. An
%
unrecognized property name or invalid value makes property application
%
stop. All inputs are passed to USUUAVSimMainGUI_OpeningFcn via varargin.
%
%
*See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
%
instance to run (singleton)".
%
41

% See also: GUIDE, GUIDATA, GUIHANDLES


% Edit the above text to modify the response to help USUUAVSimMainGUI
% Last Modified by GUIDE v2.5 10-Aug-2011 15:12:13
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',
mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @USUUAVSimMainGUI_OpeningFcn, ...
'gui_OutputFcn', @USUUAVSimMainGUI_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback',
[]);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before USUUAVSimMainGUI is made visible.
function USUUAVSimMainGUI_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject
handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% varargin
command line arguments to USUUAVSimMainGUI (see VARARGIN)
% Choose default command line output for USUUAVSimMainGUI
handles.output = hObject;

% Update handles structure


guidata(hObject, handles);
% UIWAIT makes USUUAVSimMainGUI wait for user response (see UIRESUME)
% uiwait(handles.USUUAVSimMainGUI);
getWorldCoordinatesFromFile();
% Set the viewer preference
vrsetpref('DefaultViewer', 'internalv5');
%% Obtain vrworld and construct canvas
%
%
%
%
%

USUUAVVRMLWorld = vrworld('USUUAVSim_VRMLFiles\USUUAVSimVRML2011');
open(USUUAVVRMLWorld);
set(USUUAVVRMLWorld, 'Description', 'USU UAV');
assignin('base', 'USUUAVVRMLWorld', USUUAVVRMLWorld);

%CreateVirtualVRMLWorld()
42

%UAVWorld = GetVirtualVRMLWorld();
%Create the MATLAB GUI with two views of the robot
run globals;
global USUUAVVRMLWorld;
USUUAVCanvas = vr.canvas(USUUAVVRMLWorld, gcf, [660 60 500 500]);
set(USUUAVCanvas,'Units','normalized');
% c1.Viewpoint='Left_View';
function USUUAVSimMainGUI_CreateFcn(hObject, eventdata, handles)
% hObject
handle to USUUAVSimMainGUI (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called

% --- Outputs from this function are returned to the command line.
function varargout = USUUAVSimMainGUI_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject
handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in StartSim.
function StartSim_Callback(hObject, eventdata, handles)
% hObject
handle to StartSim (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
%Global Variable for VRML World Object
global USUUAVVRMLWorld
global USUUAVNum
global SimTypeValue

%----Staitc Option -------if strcmp(SimTypeValue,'Static')


for i = 1:3
setCoordsFromUAVForm(i);
SetScaleDownCoordinates(i);
if USUUAVNum(i) == 1
if UAVErrorCheckOK(true,i) == true
StaticMovetoTargets(i, USUUAVVRMLWorld);
end
end

end
USUUAVNum(1) = 0;
USUUAVNum(2) = 0;
USUUAVNum(3) = 0;

43

elseif strcmp(SimTypeValue,'Dynamic')
for i = 1:3
setCoordsFromUAVForm(i);
SetScaleDownCoordinates(i);
USUUAVNum(i) = UAVErrorCheckOK(true,i);
end
if USUUAVNum == true

SetScaleDownDynamicCoordinates();
xinitUAV1Obj = findobj(gcf,'-depth',inf,'Tag','TrajofUAV');
TrajGrid = evalin('base','DynamicTrajectoryPoints');
set(xinitUAV1Obj, 'Data', TrajGrid)
moveToDynamicTarget();
end

USUUAVNum(1) = 0;
USUUAVNum(2) = 0;
USUUAVNum(3) = 0;
else
%Display a message stating that the user needs to slect from static or
%dynamic
msgbox('Please select Static or Dynamic','Static or Dynamic', 'error');
end

% --- Executes on button press in Dynamic.


function Dynamic_Callback(hObject, eventdata, handles)
% hObject
handle to Dynamic (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of Dynamic
%Retrieve Static Radio button value
DynamicOnjValue = get(hObject, 'Value');
%Switch other figure object files of an on
if DynamicOnjValue == 1
%*************************************************************************
44

%---------------------Enable Dynamic Objects------------%************************************************************************


UAVSimLoadCoordBtn = findobj(gcf,'-depth',inf,'Tag','LoadCoordinates')
set(UAVSimLoadCoordBtn, 'Enable', 'on');
%Set static radio button to 0
UAVSimStaticRad = findobj(gcf,'-depth',inf,'Tag','Static')
set(UAVSimStaticRad, 'Value', 0);
%*************************************************************************
%---------------------Disable UAV1 Objects ------------------------------%*************************************************************************
UAV1XInitObj = findobj(gcf,'-depth',inf,'Tag','UAV1XInit');
set(UAV1XInitObj, 'Enable', 'off');
UAV1YInitObj = findobj(gcf,'-depth',inf,'Tag','UAV1YInit');
set(UAV1YInitObj, 'Enable', 'off');
UAV1XTarObj = findobj(gcf,'-depth',inf,'Tag','UAV1XTar');
set(UAV1XTarObj, 'Enable', 'off');
UAV1YTarObj = findobj(gcf,'-depth',inf,'Tag','UAV1YTar');
set(UAV1YTarObj, 'Enable', 'off');
UAV1XInitObj = findobj(gcf,'-depth',inf,'Tag','UAV1Theta');
set(UAV1XInitObj, 'Enable', 'off');
UAV1AngularObj = findobj(gcf,'-depth',inf,'Tag','UAV1Angular');
set(UAV1AngularObj, 'Enable', 'off');
UAV1VelocityObj = findobj(gcf,'-depth',inf,'Tag','UAV1Velocity');
set(UAV1VelocityObj, 'Enable', 'off');
%*************************************************************************
%---------------------Disable UAV2 Objects ------------------------------%*************************************************************************
UAV2XInitObj = findobj(gcf,'-depth',inf,'Tag','UAV2XInit');
set(UAV2XInitObj, 'Enable', 'off');
UAV2YInitObj = findobj(gcf,'-depth',inf,'Tag','UAV2YInit');
set(UAV2YInitObj, 'Enable', 'off');
UAV2XTarObj = findobj(gcf,'-depth',inf,'Tag','UAV2XTar');
set(UAV2XTarObj, 'Enable', 'off');
UAV2YTarObj = findobj(gcf,'-depth',inf,'Tag','UAV2YTar');
set(UAV2YTarObj, 'Enable', 'off');
UAV2XInitObj = findobj(gcf,'-depth',inf,'Tag','UAV2Theta');
set(UAV2XInitObj, 'Enable', 'off');
UAV2AngularObj = findobj(gcf,'-depth',inf,'Tag','UAV2Angular');
set(UAV2AngularObj, 'Enable', 'off');
UAV2VelocityObj = findobj(gcf,'-depth',inf,'Tag','UAV2Velocity');
set(UAV2VelocityObj, 'Enable', 'off');
%*************************************************************************
%---------------------Disable UAV3 Objects ------------------------------%*************************************************************************
45

UAV3XInitObj = findobj(gcf,'-depth',inf,'Tag','UAV3XInit');
set(UAV3XInitObj, 'Enable', 'off');
UAV3YInitObj = findobj(gcf,'-depth',inf,'Tag','UAV3YInit');
set(UAV3YInitObj, 'Enable', 'off');
UAV3XTarObj = findobj(gcf,'-depth',inf,'Tag','UAV3XTar');
set(UAV3XTarObj, 'Enable', 'off');
UAV3YTarObj = findobj(gcf,'-depth',inf,'Tag','UAV3YTar');
set(UAV3YTarObj, 'Enable', 'off');
UAV3XInitObj = findobj(gcf,'-depth',inf,'Tag','UAV3Theta');
set(UAV3XInitObj, 'Enable', 'off');
UAV3AngularObj = findobj(gcf,'-depth',inf,'Tag','UAV3Angular');
set(UAV3AngularObj, 'Enable', 'off');
UAV3VelocityObj = findobj(gcf,'-depth',inf,'Tag','UAV3Velocity');
set(UAV3VelocityObj, 'Enable', 'off');
end
% --- Executes on button press in Static.
function Static_Callback(hObject, eventdata, handles)
% hObject
handle to Static (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of Static
%Retrieve Static Radio button value
StaticObjVal = get(hObject, 'Value');
%Switch other figure object files of an on
if StaticObjVal == 1
%*************************************************************************
%---------------------Enable UAV1 Objects ------------------------------%*************************************************************************
UAV1XInitObj = findobj(gcf,'-depth',inf,'Tag','UAV1XInit');
set(UAV1XInitObj, 'Enable', 'on');
UAV1YInitObj = findobj(gcf,'-depth',inf,'Tag','UAV1YInit');
set(UAV1YInitObj, 'Enable', 'on');
UAV1XTarObj = findobj(gcf,'-depth',inf,'Tag','UAV1XTar');
set(UAV1XTarObj, 'Enable', 'on');
UAV1YTarObj = findobj(gcf,'-depth',inf,'Tag','UAV1YTar');
set(UAV1YTarObj, 'Enable', 'on');
UAV1XInitObj = findobj(gcf,'-depth',inf,'Tag','UAV1Theta');
set(UAV1XInitObj, 'Enable', 'on');
UAV1AngularObj = findobj(gcf,'-depth',inf,'Tag','UAV1Angular');
set(UAV1AngularObj, 'Enable', 'on');
UAV1VelocityObj = findobj(gcf,'-depth',inf,'Tag','UAV1Velocity');
set(UAV1VelocityObj, 'Enable', 'on');
46

%*************************************************************************
%---------------------Enable UAV2 Objects ------------------------------%*************************************************************************
UAV2XInitObj = findobj(gcf,'-depth',inf,'Tag','UAV2XInit');
set(UAV2XInitObj, 'Enable', 'on');
UAV2YInitObj = findobj(gcf,'-depth',inf,'Tag','UAV2YInit');
set(UAV2YInitObj, 'Enable', 'on');
UAV2XTarObj = findobj(gcf,'-depth',inf,'Tag','UAV2XTar');
set(UAV2XTarObj, 'Enable', 'on');
UAV2YTarObj = findobj(gcf,'-depth',inf,'Tag','UAV2YTar');
set(UAV2YTarObj, 'Enable', 'on');
UAV2XInitObj = findobj(gcf,'-depth',inf,'Tag','UAV2Theta');
set(UAV2XInitObj, 'Enable', 'on');
UAV2AngularObj = findobj(gcf,'-depth',inf,'Tag','UAV2Angular');
set(UAV2AngularObj, 'Enable', 'on');
UAV2VelocityObj = findobj(gcf,'-depth',inf,'Tag','UAV2Velocity');
set(UAV2VelocityObj, 'Enable', 'on');
%*************************************************************************
%---------------------Enable UAV3 Objects ------------------------------%*************************************************************************
UAV3XInitObj = findobj(gcf,'-depth',inf,'Tag','UAV3XInit');
set(UAV3XInitObj, 'Enable', 'on');
UAV3YInitObj = findobj(gcf,'-depth',inf,'Tag','UAV3YInit');
set(UAV3YInitObj, 'Enable', 'on');
UAV3XTarObj = findobj(gcf,'-depth',inf,'Tag','UAV3XTar');
set(UAV3XTarObj, 'Enable', 'on');
UAV3YTarObj = findobj(gcf,'-depth',inf,'Tag','UAV3YTar');
set(UAV3YTarObj, 'Enable', 'on');
UAV3XInitObj = findobj(gcf,'-depth',inf,'Tag','UAV3Theta');
set(UAV3XInitObj, 'Enable', 'on');
UAV3AngularObj = findobj(gcf,'-depth',inf,'Tag','UAV3Angular');
set(UAV3AngularObj, 'Enable', 'on');
UAV3VelocityObj = findobj(gcf,'-depth',inf,'Tag','UAV3Velocity');
set(UAV3VelocityObj, 'Enable', 'on');
%*************************************************************************
%---------------------Disable Dynamic Objects------------%*************************************************************************
UAVSimDynamicRad = findobj(gcf,'-depth',inf,'Tag','Dynamic')
set(UAVSimDynamicRad, 'Value', 0);
UAVSimLoadCoordBtn = findobj(gcf,'-depth',inf,'Tag','LoadCoordinates')
set(UAVSimLoadCoordBtn, 'Enable', 'off');
end

47

function UAV3XInitial_Callback(hObject, eventdata, handles)


% hObject
handle to UAV3XInitial (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV3XInitial as text
%
str2double(get(hObject,'String')) returns contents of UAV3XInitial as a
double
% --- Executes during object creation, after setting all properties.
function UAV3XInitial_CreateFcn(hObject, eventdata, handles)
% hObject
handle to UAV3XInitial (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function UAV3YInit_Callback(hObject, eventdata, handles)


% hObject
handle to UAV3YInit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV3YInit as text
%
str2double(get(hObject,'String')) returns contents of UAV3YInit as a double
% --- Executes during object creation, after setting all properties.
function UAV3YInit_CreateFcn(hObject, eventdata, handles)
% hObject
handle to UAV3YInit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function UAV3XTar_Callback(hObject, eventdata, handles)


% hObject
handle to UAV3XTar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV3XTar as text
%
str2double(get(hObject,'String')) returns contents of UAV3XTar as a double
% --- Executes during object creation, after setting all properties.
48

function UAV3XTar_CreateFcn(hObject, eventdata, handles)


% hObject
handle to UAV3XTar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function UAV3YTar_Callback(hObject, eventdata, handles)


% hObject
handle to UAV3YTar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV3YTar as text
%
str2double(get(hObject,'String')) returns contents of UAV3YTar as a double
% --- Executes during object creation, after setting all properties.
function UAV3YTar_CreateFcn(hObject, eventdata, handles)
% hObject
handle to UAV3YTar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function UAV3Velocity_Callback(hObject, eventdata, handles)


% hObject
handle to UAV3Velocity (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV3Velocity as text
%
str2double(get(hObject,'String')) returns contents of UAV3Velocity as a
double
% --- Executes during object creation, after setting all properties.
function UAV3Velocity_CreateFcn(hObject, eventdata, handles)
% hObject
handle to UAV3Velocity (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
49

function UAV3Angular_Callback(hObject, eventdata, handles)


% hObject
handle to UAV3Angular (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV3Angular as text
%
str2double(get(hObject,'String')) returns contents of UAV3Angular as a
double
% --- Executes during object creation, after setting all properties.
function UAV3Angular_CreateFcn(hObject, eventdata, handles)
% hObject
handle to UAV3Angular (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function UAV3Theta_Callback(hObject, eventdata, handles)


% hObject
handle to UAV3Theta (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV3Theta as text
%
str2double(get(hObject,'String')) returns contents of UAV3Theta as a double
% --- Executes during object creation, after setting all properties.
function UAV3Theta_CreateFcn(hObject, eventdata, handles)
% hObject
handle to UAV3Theta (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function UAV2XInit_Callback(hObject, eventdata, handles)


% hObject
handle to uav2xinit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of uav2xinit as text
%
str2double(get(hObject,'String')) returns contents of uav2xinit as a double
50

% --- Executes during object creation, after setting all properties.


function UAV2XInit_CreateFcn(hObject, eventdata, handles)
% hObject
handle to uav2xinit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function UAV2YInit_Callback(hObject, eventdata, handles)


% hObject
handle to uav2yinit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of uav2yinit as text
%
str2double(get(hObject,'String')) returns contents of uav2yinit as a double
% --- Executes during object creation, after setting all properties.
function UAV2YInit_CreateFcn(hObject, eventdata, handles)
% hObject
handle to uav2yinit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function UAV2XTar_Callback(hObject, eventdata, handles)


% hObject
handle to UAV2XTar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV2XTar as text
%
str2double(get(hObject,'String')) returns contents of UAV2XTar as a double
% --- Executes during object creation, after setting all properties.
function UAV2XTar_CreateFcn(hObject, eventdata, handles)
% hObject
handle to UAV2XTar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
51

end

function UAV2YTar_Callback(hObject, eventdata, handles)


% hObject
handle to UAV2YTar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV2YTar as text
%
str2double(get(hObject,'String')) returns contents of UAV2YTar as a double
% --- Executes during object creation, after setting all properties.
function UAV2YTar_CreateFcn(hObject, eventdata, handles)
% hObject
handle to UAV2YTar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function UAV2Velocity_Callback(hObject, eventdata, handles)


% hObject
handle to UAV2Velocity (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV2Velocity as text
%
str2double(get(hObject,'String')) returns contents of UAV2Velocity as a
double
% --- Executes during object creation, after setting all properties.
function UAV2Velocity_CreateFcn(hObject, eventdata, handles)
% hObject
handle to UAV2Velocity (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function UAV2Angular_Callback(hObject, eventdata, handles)


% hObject
handle to UAV2Angular (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV2Angular as text
52

%
double

str2double(get(hObject,'String')) returns contents of UAV2Angular as a

% --- Executes during object creation, after setting all properties.


function UAV2Angular_CreateFcn(hObject, eventdata, handles)
% hObject
handle to UAV2Angular (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function UAV2Theta_Callback(hObject, eventdata, handles)


% hObject
handle to UAV2Theta (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV2Theta as text
%
str2double(get(hObject,'String')) returns contents of UAV2Theta as a double
% --- Executes during object creation, after setting all properties.
function UAV2Theta_CreateFcn(hObject, eventdata, handles)
% hObject
handle to UAV2Theta (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in LoadCoordinates.
function LoadCoordinates_Callback(hObject, eventdata, handles)
% hObject
handle to LoadCoordinates (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

function UAV1XInit_Callback(hObject, eventdata, handles)


% hObject
handle to UAV1XInit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV1XInit as text
%
str2double(get(hObject,'String')) returns contents of UAV1XInit as a double
% --- Executes during object creation, after setting all properties.
53

function UAV1XInit_CreateFcn(hObject, eventdata, handles)


% hObject
handle to UAV1XInit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function UAV1YInit_Callback(hObject, eventdata, handles)


% hObject
handle to UAV1YInit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV1YInit as text
%
str2double(get(hObject,'String')) returns contents of UAV1YInit as a double
% --- Executes during object creation, after setting all properties.
function UAV1YInit_CreateFcn(hObject, eventdata, handles)
% hObject
handle to UAV1YInit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function UAV1XTar_Callback(hObject, eventdata, handles)


% hObject
handle to UAV1XTar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV1XTar as text
%
str2double(get(hObject,'String')) returns contents of UAV1XTar as a double
% --- Executes during object creation, after setting all properties.
function UAV1XTar_CreateFcn(hObject, eventdata, handles)
% hObject
handle to UAV1XTar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
54

function UAV1YTar_Callback(hObject, eventdata, handles)


% hObject
handle to UAV1YTar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV1YTar as text
%
str2double(get(hObject,'String')) returns contents of UAV1YTar as a double
% --- Executes during object creation, after setting all properties.
function UAV1YTar_CreateFcn(hObject, eventdata, handles)
% hObject
handle to UAV1YTar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function UAV1Velocity_Callback(hObject, eventdata, handles)


% hObject
handle to UAV1Velocity (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV1Velocity as text
%
str2double(get(hObject,'String')) returns contents of UAV1Velocity as a
double
% --- Executes during object creation, after setting all properties.
function UAV1Velocity_CreateFcn(hObject, eventdata, handles)
% hObject
handle to UAV1Velocity (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function UAV1Angular_Callback(hObject, eventdata, handles)


% hObject
handle to UAV1Angular (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV1Angular as text
%
str2double(get(hObject,'String')) returns contents of UAV1Angular as a
double
55

% --- Executes during object creation, after setting all properties.


function UAV1Angular_CreateFcn(hObject, eventdata, handles)
% hObject
handle to UAV1Angular (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function UAV1Theta_Callback(hObject, eventdata, handles)


% hObject
handle to UAV1Theta (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV1Theta as text
%
str2double(get(hObject,'String')) returns contents of UAV1Theta as a double
% --- Executes during object creation, after setting all properties.
function UAV1Theta_CreateFcn(hObject, eventdata, handles)
% hObject
handle to UAV1Theta (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function UAV2Xinit_Callback(hObject, eventdata, handles)


% hObject
handle to UAV2XInit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV2XInit as text
%
str2double(get(hObject,'String')) returns contents of UAV2XInit as a double
% --- Executes during object creation, after setting all properties.
function UAV2Xinit_CreateFcn(hObject, eventdata, handles)
% hObject
handle to UAV2XInit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
56

end

function UAV2Yinit_Callback(hObject, eventdata, handles)


% hObject
handle to UAV1YInit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV1YInit as text
%
str2double(get(hObject,'String')) returns contents of UAV1YInit as a double
% --- Executes during object creation, after setting all properties.
function UAV2Yinit_CreateFcn(hObject, eventdata, handles)
% hObject
handle to UAV1YInit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit31_Callback(hObject, eventdata, handles)


% hObject
handle to UAV2XTar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV2XTar as text
%
str2double(get(hObject,'String')) returns contents of UAV2XTar as a double
% --- Executes during object creation, after setting all properties.
function edit31_CreateFcn(hObject, eventdata, handles)
% hObject
handle to UAV2XTar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit32_Callback(hObject, eventdata, handles)


% hObject
handle to UAV1YTar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV1YTar as text
%
str2double(get(hObject,'String')) returns contents of UAV1YTar as a double
57

% --- Executes during object creation, after setting all properties.


function edit32_CreateFcn(hObject, eventdata, handles)
% hObject
handle to UAV1YTar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit33_Callback(hObject, eventdata, handles)


% hObject
handle to UAV2Velocity (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV2Velocity as text
%
str2double(get(hObject,'String')) returns contents of UAV2Velocity as a
double
% --- Executes during object creation, after setting all properties.
function edit33_CreateFcn(hObject, eventdata, handles)
% hObject
handle to UAV2Velocity (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function UAVAngular_Callback(hObject, eventdata, handles)


% hObject
handle to UAV2Angular (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV2Angular as text
%
str2double(get(hObject,'String')) returns contents of UAV2Angular as a
double
% --- Executes during object creation, after setting all properties.
function UAVAngular_CreateFcn(hObject, eventdata, handles)
% hObject
handle to UAV2Angular (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
58

if ispc && isequal(get(hObject,'BackgroundColor'),


get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function UAV2YTheta_Callback(hObject, eventdata, handles)


% hObject
handle to UAV1Theta (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV1Theta as text
%
str2double(get(hObject,'String')) returns contents of UAV1Theta as a double
% --- Executes during object creation, after setting all properties.
function UAV2YTheta_CreateFcn(hObject, eventdata, handles)
% hObject
handle to UAV1Theta (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function UAV3Xinit_Callback(hObject, eventdata, handles)


% hObject
handle to UAV3Xinit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV3Xinit as text
%
str2double(get(hObject,'String')) returns contents of UAV3Xinit as a double
% --- Executes during object creation, after setting all properties.

% --- Executes during object creation, after setting all properties.


function UAV3Yinit_CreateFcn(hObject, eventdata, handles)
% hObject
handle to UAV3Yinit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
59

function edit38_Callback(hObject, eventdata, handles)


% hObject
handle to UAV3XTar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV3XTar as text
%
str2double(get(hObject,'String')) returns contents of UAV3XTar as a double
% --- Executes during object creation, after setting all properties.
function edit38_CreateFcn(hObject, eventdata, handles)
% hObject
handle to UAV3XTar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit39_Callback(hObject, eventdata, handles)


% hObject
handle to UAV3YTar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV3YTar as text
%
str2double(get(hObject,'String')) returns contents of UAV3YTar as a double
% --- Executes during object creation, after setting all properties.
function edit39_CreateFcn(hObject, eventdata, handles)
% hObject
handle to UAV3YTar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit40_Callback(hObject, eventdata, handles)


% hObject
handle to UAV3Velocity (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV3Velocity as text
%
str2double(get(hObject,'String')) returns contents of UAV3Velocity as a
double

60

% --- Executes during object creation, after setting all properties.


function edit40_CreateFcn(hObject, eventdata, handles)
% hObject
handle to UAV3Velocity (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function UAV3XAngular_Callback(hObject, eventdata, handles)


% hObject
handle to UAV3XAngular (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV3XAngular as text
%
str2double(get(hObject,'String')) returns contents of UAV3XAngular as a
double
% --- Executes during object creation, after setting all properties.
function UAV3XAngular_CreateFcn(hObject, eventdata, handles)
% hObject
handle to UAV3XAngular (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit42_Callback(hObject, eventdata, handles)


% hObject
handle to UAV3Theta (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV3Theta as text
%
str2double(get(hObject,'String')) returns contents of UAV3Theta as a double
% --- Executes during object creation, after setting all properties.
function edit42_CreateFcn(hObject, eventdata, handles)
% hObject
handle to UAV3Theta (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
61

end
% --- Executes on selection change in UAVCameraView.
function UAVCameraView_Callback(hObject, eventdata, handles)
% hObject
handle to UAVCameraView (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns UAVCameraView contents as
cell array
%
contents{get(hObject,'Value')} returns selected item from UAVCameraView
% --- Executes during object creation, after setting all properties.
function UAVCameraView_CreateFcn(hObject, eventdata, handles)
% hObject
handle to UAVCameraView (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: listbox controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in ZoomIn.
function ZoomIn_Callback(hObject, eventdata, handles)
% hObject
handle to ZoomIn (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% --- Executes on button press in ZoomOut.
function ZoomOut_Callback(hObject, eventdata, handles)
% hObject
handle to ZoomOut (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% --- Executes on button press in CameraView.

% --- Executes during object creation, after setting all properties.


% --- Executes on button press in StopSim.
function StopSim_Callback(hObject, eventdata, handles)
% hObject
handle to StopSim (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
%Hide Stop Simulator Button
set(hObject, 'Visible', 'off');
save_system('StaticUSUUAVSim');
close_system('MainSimulinkModels/StaticUSUUAVSim');
62

save_system('co_seeking');
close_system('co_seeking');

%Unhides Start Simulator Button


StartButtonVisible = findobj(gcf,'-depth',inf,'Tag','StartSim');
set(StartButtonVisible,'Visible', 'on');
function thetaCalc = calculateTheta(y,x)
thetaCalc = rad2deg(atan2(y,x))
if thetaCalc <= 90 && thetaCalc >= -90
thetaCalc = -(90-thetaCalc);
else
if thetaCalc > 0
thetaCalc = thetaCalc - 90;
else
thetaCalc = 270 + thetaCalc;
end
end

function translation = calctranslation( xt, zt, yt)


translation = [ xt zt yt ];
function
makeXYThetaVarsInWS(XVarName,XVarValue,YVarName,YVarValue,ThetaVarName,ThetaVarValue
)
assignin('base',XVarName,XVarValue)
assignin('base',YVarName,YVarValue)
assignin('base',ThetaVarName,ThetaVarValue)
function USUUAVMakeVRWorldObjInWorkSpace(VRWorldName, VRWorldValue)
assignin('base',VRWorldName,VRWorldValue)
% --- Executes on button press in ResetButton.
function ResetButton_Callback(hObject, eventdata, handles)
% hObject
handle to ResetButton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
clear all;
% --- Executes on button press in FullScreen.
function FullScreen_Callback(hObject, eventdata, handles)
% hObject
handle to FullScreen (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnFile_Callback(hObject, eventdata, handles)
% hObject
handle to mnFile (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
63

% -------------------------------------------------------------------function mnCameraViews_Callback(hObject, eventdata, handles)


% hObject
handle to mnCameraViews (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnZoom_Callback(hObject, eventdata, handles)
% hObject
handle to mnZoom (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnFullScreen_Callback(hObject, eventdata, handles)
% hObject
handle to mnFullScreen (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnTools_Callback(hObject, eventdata, handles)
% hObject
handle to mnTools (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnResetSimulator_Callback(hObject, eventdata, handles)
% hObject
handle to mnResetSimulator (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnZoomOut_Callback(hObject, eventdata, handles)
% hObject
handle to mnZoomOut (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnZoomIn_Callback(hObject, eventdata, handles)
% hObject
handle to mnZoomIn (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnAll_Callback(hObject, eventdata, handles)
% hObject
handle to mnAll (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnUAV1_Callback(hObject, eventdata, handles)
% hObject
handle to mnUAV1 (see GCBO)
64

% eventdata
% handles

reserved - to be defined in a future version of MATLAB


structure with handles and user data (see GUIDATA)

% -------------------------------------------------------------------function mnUAV2_Callback(hObject, eventdata, handles)


% hObject
handle to mnUAV2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnUAV3_Callback(hObject, eventdata, handles)
% hObject
handle to mnUAV3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnNew_Callback(hObject, eventdata, handles)
% hObject
handle to mnNew (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% -------------------------------------------------------------------function mnOpen_Callback(hObject, eventdata, handles)


% hObject
handle to mnOpen (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnClose_Callback(hObject, eventdata, handles)
% hObject
handle to mnClose (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
delete(hObject);
global USUUAVVRMLWorld
deleteProtoUAV(USUUAVVRMLWorld);
clear('USUUAVVRMLWorld')
% -------------------------------------------------------------------function mnSave_Callback(hObject, eventdata, handles)
% hObject
handle to mnSave (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnSaveAs_Callback(hObject, eventdata, handles)
% hObject
handle to mnSaveAs (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnUAV3Top_Callback(hObject, eventdata, handles)
65

% hObject
% eventdata
% handles

handle to mnUAV3Top (see GCBO)


reserved - to be defined in a future version of MATLAB
structure with handles and user data (see GUIDATA)

% -------------------------------------------------------------------function mnUAV3Bottom_Callback(hObject, eventdata, handles)


% hObject
handle to mnUAV3Bottom (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnUAV3Left_Callback(hObject, eventdata, handles)
% hObject
handle to mnUAV3Left (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnUAV3Right_Callback(hObject, eventdata, handles)
% hObject
handle to mnUAV3Right (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnUAV3Front_Callback(hObject, eventdata, handles)
% hObject
handle to mnUAV3Front (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnUAV3Back_Callback(hObject, eventdata, handles)
% hObject
handle to mnUAV3Back (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnUAV2Top_Callback(hObject, eventdata, handles)
% hObject
handle to mnUAV2Top (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnUAV2Bottom_Callback(hObject, eventdata, handles)
% hObject
handle to mnUAV2Bottom (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnUAV2Left_Callback(hObject, eventdata, handles)
% hObject
handle to mnUAV2Left (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
66

% -------------------------------------------------------------------function mnUAV2Right_Callback(hObject, eventdata, handles)


% hObject
handle to mnUAV2Right (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnUAV2Front_Callback(hObject, eventdata, handles)
% hObject
handle to mnUAV2Front (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnUAV2Back_Callback(hObject, eventdata, handles)
% hObject
handle to mnUAV2Back (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnUAV1Top_Callback(hObject, eventdata, handles)
% hObject
handle to mnUAV1Top (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnUAV1Bottom_Callback(hObject, eventdata, handles)
% hObject
handle to mnUAV1Bottom (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnUAV1Left_Callback(hObject, eventdata, handles)
% hObject
handle to mnUAV1Left (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnUAV1Right_Callback(hObject, eventdata, handles)
% hObject
handle to mnUAV1Right (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnUAV1Front_Callback(hObject, eventdata, handles)
% hObject
handle to mnUAV1Front (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnUAV1Back_Callback(hObject, eventdata, handles)
% hObject
handle to mnUAV1Back (see GCBO)
67

% eventdata
% handles

reserved - to be defined in a future version of MATLAB


structure with handles and user data (see GUIDATA)

% -------------------------------------------------------------------function mnAllTop_Callback(hObject, eventdata, handles)


% hObject
handle to mnAllTop (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnAllBottom_Callback(hObject, eventdata, handles)
% hObject
handle to mnAllBottom (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnAllLeft_Callback(hObject, eventdata, handles)
% hObject
handle to mnAllLeft (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnAllRight_Callback(hObject, eventdata, handles)
% hObject
handle to mnAllRight (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnAllFront_Callback(hObject, eventdata, handles)
% hObject
handle to mnAllFront (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function mnAllBack_Callback(hObject, eventdata, handles)
% hObject
handle to mnAllBack (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% --- Executes on button press in createUAV3.
function createUAV3_Callback(hObject, eventdata, handles)
% hObject
handle to createUAV3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of createUAV3
global USUUAVVRMLWorld;
global USUUAVNum
setCoordsFromUAVForm(3)
SetScaleDownCoordinates(3)
createUAVValue = get(hObject,'Value');
68

if UAVErrorCheckOK(true,3) == true && createUAVValue == 1


CreateUAV(3,USUUAVVRMLWorld );
USUUAVNum(3) = 1;
elseif UAVErrorCheckOK(true,1) == true && createUAVValue == 1
set(hObject, 'Value', 0);
USUUAVNum(3) = 0;
else
DeleteUAV(3, USUUAVVRMLWorld);
set(hObject, 'Value', 0);
USUUAVNum(3) = 0;
end

% --- Executes on button press in createUAV2.


function createUAV2_Callback(hObject, eventdata, handles)
% hObject
handle to createUAV2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of createUAV2
global USUUAVVRMLWorld
global USUUAVNum
setCoordsFromUAVForm(2)
SetScaleDownCoordinates(2)
createUAVValue = get(hObject,'Value');
if UAVErrorCheckOK(true,2) == true && createUAVValue == 1
CreateUAV(2,USUUAVVRMLWorld );
USUUAVNum(2) = 1;
elseif UAVErrorCheckOK(true,2) == true && createUAVValue == 1
set(hObject, 'Value', 0);
USUUAVNum(2) = 0;
else
DeleteUAV(2, USUUAVVRMLWorld);
set(hObject, 'Value', 0);
USUUAVNum(2) = 0;
end
% --- Executes on button press in createUAV1.
function createUAV1_Callback(hObject, eventdata, handles)
% hObject
handle to createUAV1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of createUAV1
%Global variables
global USUUAVVRMLWorld
global USUUAVNum
%sets the values in the edit box control
69

setCoordsFromUAVForm(1)
SetScaleDownCoordinates(1)
%get the current value of the check box control
createUAVValue = get(hObject,'Value');
%Runs an error check on the inputs of the GUI and if all is ok creates a
%UAV
if UAVErrorCheckOK(true,1) == true && createUAVValue == 1
CreateUAV(1,USUUAVVRMLWorld );
USUUAVNum(1) = 1;
elseif UAVErrorCheckOK(true,1) == true && createUAVValue == 1
set(hObject, 'Value', 0);
USUUAVNum(1) = 0;
else
%Deletes a UAV if a check box is un checked.
DeleteUAV(1, USUUAVVRMLWorld);
set(hObject, 'Value', 0);
end
% --- Executes when selected object is changed in SimType.
function SimType_SelectionChangeFcn(hObject, eventdata, handles)
% hObject
handle to the selected object in SimType
% eventdata structure with the following fields (see UIBUTTONGROUP)
%
EventName: string 'SelectionChanged' (read only)
%
OldValue: handle of the previously selected object or empty if none was selected
%
NewValue: handle of the currently selected object
% handles
structure with handles and user data (see GUIDATA)
%Global Variables
global SimTypeValue
global USUUAVVRMLWorld
%Gets the value of the button group
SimTypeValue = get(eventdata.NewValue, 'Tag')
%Determines which model to run
switch SimTypeValue % Get Tag of selected object.
case 'Static'
enableStaticMode()
case 'Dynamic'
enableDynamicMode(USUUAVVRMLWorld)
otherwise
msgbox('Restart Program','Restart Program', 'error');
end

% -------------------------------------------------------------------% -------------------------------------------------------------------function mnSettings_Callback(hObject, eventdata, handles)


% hObject
handle to mnSettings (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
70

% -------------------------------------------------------------------function mnSimWorldCoordinates_Callback(hObject, eventdata, handles)


% hObject
handle to mnSimWorldCoordinates (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
openfig('SimWorldCoord.fig','new','visible');

function UAV3XInit_Callback(hObject, eventdata, handles)


% hObject
handle to UAV3XInit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of UAV3XInit as text
%
str2double(get(hObject,'String')) returns contents of UAV3XInit as a double
% --- Executes during object creation, after setting all properties.
function UAV3XInit_CreateFcn(hObject, eventdata, handles)
% hObject
handle to UAV3XInit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes during object creation, after setting all properties.
% --- Executes when user attempts to close USUUAVSimMainGUI.
function USUUAVSimMainGUI_CloseRequestFcn(hObject, eventdata, handles)
% hObject
handle to USUUAVSimMainGUI (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hint: delete(hObject) closes the figure
global USUUAVVRMLWorld
vrclear('-force')
delete(hObject);

% --- Executes during object creation, after setting all properties.


function createUAV1_CreateFcn(hObject, eventdata, handles)
% hObject
handle to createUAV1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% --- Executes on button press in createUAVsDynamic.
function createUAVsDynamic_Callback(hObject, eventdata, handles)
% hObject
handle to createUAVsDynamic (see GCBO)
71

% eventdata reserved - to be defined in a future version of MATLAB


% handles
structure with handles and user data (see GUIDATA)
global USUUAVVRMLWorld
buttonname = get(hObject,'String')
if strcmp(buttonname,'Create UAVs')
for i = 1:3
setCoordsFromUAVForm(i);
SetScaleDownCoordinates(i);
errorCheckMatrix(i) = UAVErrorCheckOK(false, i);
end
if errorCheckMatrix == true
for j = 1: 3
CreateUAV(j,USUUAVVRMLWorld);
end
setAllCoordsForSimController();
runcontrollerSimulator();
set(hObject, 'String','Delete UAVs')
end
elseif strcmp(buttonname,'Delete UAVs')
for i = 1:3
DeleteUAV(i, USUUAVVRMLWorld);
end
set(hObject, 'String','Create UAVs')
end
USUUAVSimVRML2011
#VRML V2.0 utf8
#Created with V-Realm Builder v2.0
#Integrated Data Systems Inc.
#www.ids-net.com
NavigationInfo {
speed 15
}
DEF trXRot90Deg Transform {
rotation -1 0 0 1.5708
children DEF trParent Transform {
children [
DEF trBackGround Transform {
rotation
1 0 0 1.5708
children Background {
groundAngle [ 0.9, 1.5, 1.57 ]
groundColor [ 0 0.8 0,
0.174249 0.82 0.187362,
0.467223 0.82 0.445801,
0.621997 0.67 0.600279 ]
bottomUrl
"texture/CenterLoganUt.jpg"
skyAngle
[ 0.1, 1.2, 1.57 ]
72

skyColor

[ 0.76238 0.8 0.1427,


0.277798 0.219779 0.7,
0.222549 0.390234 0.7,
0.60094 0.662637 0.69 ]

}
}
DEF vwTop Viewpoint {
fieldOfView 1.69
position
0 0 -3
description
""
}
DEF trUAV1Parent Transform {
translation
-1.0188e-007 0.0282074 -44.9991
rotation
0 0 1 1.57178
children []
}
DEF trUAV2Parent Transform {
translation
-1.0188e-007 0.0282074 -44.9991
rotation
0.0313126 -0.0313125 0.999019 1.57178
children []
}
DEF trUAV3Parent Transform {
translation
-1.0188e-007 0.0282074 -44.9991
rotation
0.0313126 -0.0313125 0.999019 1.57178
children []
}
]
}
}

73

REFERENCES
Wallgrun, Jan. Hierarchical Voronoi Graphs Spatial Representation and Reasoning for Mobile
Robots. New York: Springer, 1998, Print.
Drezner, Zvi. Facility Location Asurvey of Applications and Methods,.New York: Springer, 1995.
Print.
Okabe, Atsuyuki et al. Spatial Tesselations Concepts and Applications of Voronoi Diagrams.
England: Wiley, 2000. Print
Ramires-Fernandes, Antonio. Light house 3D. Web. July 11, 2011.
http://www.lighthouse3d.com/vrml/tutorial/index.shtml
Nadeau, David. SIGGRAPH 98: In troduction to VRML 97.Web. July 11, 2011.
http://www.sdsc.edu/~moreland/courses/Siggraph98/vrml97/notes/bios.htm
Vapour Technology. FloppysVRML Guide. Web. July 5, 2011.
http://rvirtual.free.fr/programmation/VRML/tuto_eng/.
The MathWorks Family of Sites. MathWorks, Inc. 1994. Web. July5, 2011.
http://www.mathworks.com/products/matlab/
Jang, Myeong-Wuk. An Actor-Based Simulation For Studying UAV Coordination. Illinois:
Utah State University. AggieAir. 2011. Web. August 12, 2011. http://aggieair.usu.edu/

74

Você também pode gostar