Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# CMake generated files
CMakeFiles/
CMakeCache.txt
cmake_install.cmake

# Visual studio files
.vs/
*.vc*proj*
*.sln
Release/
Debug/

# Freeglut generated files
config.h
freeglut.*
2 changes: 2 additions & 0 deletions 3rdparty/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ignore all inside this folder
*
87 changes: 87 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
cmake_minimum_required(VERSION 3.0)

project(HelicopterSimulation)

################################################################################
# Configuration section #
################################################################################

# Compile library only (WITH_SIM = 0) or the simulator also (WITH_SIM = 1)
set(WITH_SIM 1)

# Compile the required dependencies "glut" (COMPILE_GLUT = 1) or use a system one (COMPILE_GLUT = 0)
# If using a system one the line
# target_link_libraries(HelicopterSimulationSim glut)
# must be updated accordingly (if the glut.lib name is different from "glut")
# Further, a copying a glut.dll file to the binary folder *may* be needed (if not installed in system path)
set(COMPILE_GLUT 1)

# glut folder if COMPILE_GLUT is set to 1
set(GLUT_FOLDER ${CMAKE_SOURCE_DIR}/3rdparty/freeglut/)

################################################################################
# Do NOT edit below this line (unless you know what you're doing) #
################################################################################

# Project output:
# * HelicopterSimulationLib: simulation static library
# * HelicopterSimulationSim: included test simulator executable
# The HelicopterSimulationSim is available only if WITH_SIM is set to 1

# Set the library source files
set(LIB_SRC
src/matlib.c
src/model.c
src/simlib.c
)

# Create the static library
add_library(HelicopterSimulationLib STATIC ${LIB_SRC})

# If simulator is required
if(WITH_SIM)

# Set the simulator source files
set(SIM_SRC
src/graphics.c
src/helisim.c
src/instruments.c
)

# If glut compilation is required
if(COMPILE_GLUT)
# Check glut folder exists, since the user should manually download it
if(NOT EXISTS ${GLUT_FOLDER})
message(FATAL_ERROR
"Missing glut library."
"Please download glut (http://freeglut.sourceforge.net/) and extract it in '${GLUT_FOLDER}' without any intermediate folder (the '${GLUT_FOLDER}' folder must contain a CMakeLists.txt file)")
endif()

# Add glut project
add_subdirectory(${GLUT_FOLDER})

# Add glut to include directories
include_directories(${GLUT_FOLDER}/include)
endif(COMPILE_GLUT)

# Create the simulator executable...
add_executable(HelicopterSimulationSim ${SIM_SRC})
# ... and link it:
# 1) with the simulation library
target_link_libraries(HelicopterSimulationSim HelicopterSimulationLib)

if(COMPILE_GLUT)
# 2a) with compiled glut
target_link_libraries(HelicopterSimulationSim freeglut)

# Deploy glut dll file to bin directory
add_custom_command(TARGET HelicopterSimulationSim POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"$<TARGET_FILE:freeglut>"
"$<TARGET_FILE_DIR:HelicopterSimulationSim>")
else(COMPILE_GLUT)
# 2b) with system glut
target_link_libraries(HelicopterSimulationSim glut)
endif(COMPILE_GLUT)

endif(WITH_SIM)
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Helicopter-Simulation
# Helicopter-Simulation #

[![Codacy Badge](https://api.codacy.com/project/badge/Grade/dd8d6dd64aee43eda773c641c96de2d1)](https://www.codacy.com/app/DanIsraelMalta/Helicopter-Simulation?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=DanIsraelMalta/Helicopter-Simulation&amp;utm_campaign=Badge_Grade)

## Description ##

A complete rigid body six degrees of freedom helicopter simulation (ANSI-C) including:
* Main rotor model (including a linear rotor flapping model accounting for coupled servo
rotor dynamics and mechanical feedback by the gyroscopic effect of the
Expand All @@ -20,3 +22,24 @@ A complete rigid body six degrees of freedom helicopter simulation (ANSI-C) incl
* A place to write the flight control code...

![Alt text](https://cloud.githubusercontent.com/assets/5231886/6562224/f2eb1b14-c69f-11e4-8234-10785c2cbba2.png)

## Project setup ##

To compile the simulator *CMake* (https://www.cmake.org/) is required.
*CMake* is a tool to create a compiler-dependant project file and it is cross platform.

Basic usage:
1. Open *CMakeLists.txt* file in the project folder with a text editor and tune the "Configuration section" based on your specific needing and configuration.
2. Download and install *CMake*.
3. Open a command prompt or a terminal and go to the project source directory.
4. Run "cmake ." without quotes. The *period* is important!
5. Check for any error message.
6. If no errors, a compiler-dependant project file will be available on project folder (e.g. .sln file for Visual Studio or Makefile for linux).
7. *Visual studio only*: Open HelicopterSimulation.sln and set "HelicopterSimulationSim" as startup project. If you disabled the "HelicopterSimulationSim" project from the CMakeLists.txt file skip this step.

Alternatively you can use [CMake GUI](https://www.google.com/search?q=cmake+gui) to avoid using command prompt or the terminal.

**Note:** Even if *CMake* is cross platform and can create a Makefile on linux, the source code for this project has not been tested on platforms different than Windows. Compilation errors may (and probably will) occurs.

## Running the simulator ##
*Empty section*
20 changes: 0 additions & 20 deletions VC/HelicopterSimulation.sln

This file was deleted.

Loading