Escolar Documentos
Profissional Documentos
Cultura Documentos
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
Table of Contents
I.
INTRODUCTION............................................................................................................... 4
II.
Research......................................................................................................................... 6
a.
Literary Reviews.......................................................................................................... 6
b.
Simulator Capabilities................................................................................................. 7
III.
a.
Application Capabilities............................................................................................... 8
b.
c.
d.
Simulink Model.......................................................................................................... 13
e.
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.
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.
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.
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.
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
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
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
The set_param commands set the values in the vehicle blocks, and are located in the
setAllCoordsForSimController function of the application.
13
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.
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.
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
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
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
AllUAVCoordMatPositive = 0/0;
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
%----------------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
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
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
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
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
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
end
%
double
end
60
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.
save_system('co_seeking');
close_system('co_seeking');
% eventdata
% handles
% hObject
% eventdata
% handles
% eventdata
% handles
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
skyColor
}
}
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