# PROJECT FILES - Simulink

*
The following files are included to help students with the project outlined in the book. We have found that if students start with these files, that they can generally do the project in about 3 hours per chapter. Full solutions to the project are available to instructors upon request. We respectfully ask that students and instructors do not post full solutions to the project anywhere on the web. The project creates an excellent learning experience and we believe that anyone who works the project for themselves will be much better equipped to make contributions to the state of the art in small unmanned air vehicles. - RWB & TWM*

### Chapter 2 - Coordinate Frames

- updated 9/10/2014. Animation of zagi-like vehicle. Vertices are inside draw function.

### Chapter 3 - Kinematics and Dynamics

chap3_kinematics.zip: Contains the following files:

*airdata.m*- simulates computation of airdata - will be replaced*tv.jpg*- graphic file of TV*plotmavstatevariables.m*- file that produces plots of all state variables*mavsim_chap3.slx*- Simulink file for chapter 3 assignment*mav_dynamics.m*- template file for mav_dynamics.m*param_chap3.m*- template file for param.m

Updated 9/10/2014 to Simulink 2014a. A few improvements.

### Chapter 4 - Forces and Moments

chap4_forces.zip: Contains the following files:

*mavsim_chap4.slx*- Simulink file for chapter 4 assignment.*forces_moments.m*- template file for forces and moments.

Updated 9/17/2014 to Simulink 2014a. A few improvements.

There are some issues with the Zagi coefficients given in the book. We recommend that you use the following (slightly modified from the book) coefficients for the aerosonde aircraft.
*aerosonde.m*

### Chapter 5 - Linear Design Models

chap5_linear.zip: Contains the following files:

*mavsim_trim.slx*- Simulink file that sets up the input and output structure suitable for*trim*and*linmod*.*mavsim_chap5.slx*- Simulink file for chapter 5 assignment showing how to put inpulses and doublets on the control surfaces.*param_chap5.m*- template file for param.m that calls*compute_trim*,*compute_tf_model*, and*compute_ss_model*.*compute_trim.m*- template file for computing trim values given V_a, gamma, and R.*compute_tf_model.m*- template file for computing the transfer function models described in Chapter 5.*compute_ss_model.m*- template file for computing the state space models described in Chapter 5.

For the Aerosonde model use an initial speed of Va = 35 m/s, and and radius of 250 meters.

Updated 9/23/2014 to Simulink 2014a.

### Chapter 6 - Autopilot Design

chap6_autopilot.zip: Contains the following files:

*batcam.png, kestrel.jpg*- graphics of the BATCAM airframe and the Kestrel autopilot.*mavsim_chap6.slx*- Simulink file for chapter 6 including the autopilot.*autopilot.m*- Template file for autopilot.*param_chap6.m*- Template for parameter file.*true_states.m*- Temporary file that returns the true states of the system. In the Chapter 8 assignment, this will be replaced with a state estimation block.- Updated 10/2/2014 to Simulink 2014a.

Additional information: The Aerosonde weight is actually 25kg. Also, the cruise speed is approximately Va=35 m/s.

YouTube video showing solution for Chapter 6.

- Note that in the YouTube video, I am using the propeller model described in propeller_model.pdf

### Chapter 7 - Sensors

chap7_sensors.zip: Contains the following files:

*mavsim_chap7.slx*- Simulink file for chapter 7 including the sensors.*sensors.m*- Template file for acceleromters, rate gyros, and pressure sensors.*gps.m*- Template file for GPS.- Updated 10/15/2014 to Simulink 2014a.

### Chapter 8 - State Estimation

chap8_estimation.zip: Contains the following files:

*mavsim_chap8.slx*- Simulink file for chapter 8: includes Kalman filter*estimate_states.m*- Template file for state estimation routine.*plotextramavstatevariables.m*- File for graphing ground speed, heading, and wind speeds.- Updated 10/21/2014 to Simulink 2014a.

### Chapter 9 - Nonlinear Design Models

chap9_nonlinear.zip: Contains the following files:

*mavsim_chap9.slx*- Simulink file for chapter 9.*guidance_model.m*- Template file for guidance model.- Updated 11/6/2014 to Simulink 2014a.

### Chapter 10 - Waypoint and Orbit Following

chap10_follow.zip: Contains the following files:

*mavsim_chap10_model.slx*- Simulink file for chapter 10 using the guidance model developed in chapter 9.*mavsim_chap10.slx*- Simulink file for chapter 10 using full simulation model.*path_manager_chap10.m*- Template for path manager that will be replaced in the next chapter.*path_follow.m*- Template for path following block.*drawPathError.m*- Drawing function that includes straight line and orbit paths.

### Chapter 11 - Path Manager

chap11_manager.zip: Contains the following files:

*mavsim_chap11_model.slx*- Simulink file for chapter 11 using the guidance model developed in chapter 9.*mavsim_chap11.slx*- Simulink file for chapter 11 using full simulation model.*path_planner_chap11.m*- Temporary path planner that will be replaced in the next chapter.*path_manager.m*- Path manager that calls either path_manager_line.m, path_manager_fillet.m, or path_manager_dubins.m*path_manager_line.m*- Template for path manager that follows waypoints with hard turns between line segments.*path_manager_fillet.m*- Template for path manager that follows waypoints smoothing between line segments with fillets.*path_manager_dubins.m*- Template for path manager that follows Dubins path.*dubinsParameters.m*- Template file for computing Dubins parameters given start and end configurations.*drawEnvironment.m*- Draws map of environment with buildings. Also plots waypoint paths and straight-line or orbit being followed.*createWorld.m*- Creates a world with buildings.*param_chap11.m*- additional parameter values for city creation.*drawPathError.m*- Drawing function that includes straight line and orbit paths.

### Chapter 12 - Path Planning

chap12_plan.zip: Contains the following files

*mavsim_chap12_model.slx*- Simulink file for chapter 12 using the guidance model developed in chapter 9.*mavsim_chap12.slx*- Simulink file for chapter 12 using full simulation model.*path_planner.m*- Master file that calls different path planners.*planRRT.m*- Point to point path planner using RRT algorithm to plan straight-line paths*planCover.m*- Covering path planner using simple look ahead planning

plan_voronoi_optimal.zip - Voronoi path planning code (note: sometimes hangs)

plan_voronoi_rectangular_make.zip - Voronoi path planning around obstacles (note: sometimes hangs)

### Chapter 13 - Cameras

*mavsim_chap13_gimbal_model.mdl* - Simulink file for problem 13.1 using the guidance model developed in chapter 9.

*mavsim_chap13_gimbal.mdl* - Simulink file for problem 13.1 using full simulation model.

*mavsim_chap13_geolocation_model.mdl* - Simulink file for problem 13.2 using the guidance model developed in chapter 9.

*mavsim_chap13_geolocation.mdl* - Simulink file for problem 13.2 using full simulation model.

*point_gimbal.m* - Template for gimbal command.

*geolocation.m* - Template for geolocation routine.

*camera.m* - Simulates camera.

*target_motion.m* - Simulates motion of target.

*gimbal.m* - Simulates the gimbal.

*drawEnvironmentCamera.m* - Drawing routine that includes field of view and target location.

*gimbal.jpg* - Image of gimbal.

*monstertruck.jpb* - Image of monster truck.