1
0
Fork 0

Merge branch 'next' into comm-subsystem

Conflicts:
	src/Instrumentation/Makefile.am
This commit is contained in:
adrian 2011-11-23 14:02:43 +02:00
commit 9ab41ea158
183 changed files with 2245 additions and 4938 deletions

13
.gitignore vendored
View file

@ -1,17 +1,4 @@
.deps
Makefile
Makefile.in
config.sub
config.guess
config.log
config.status
configure
aclocal.m4
autom4te.cache
depcomp
install-sh
missing
INSTALL
Debug/
*.o
lib*.a

View file

@ -37,8 +37,12 @@ include (CPack)
# We have some custom .cmake scripts not in the official distribution.
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}")
# autoconf compatibility
set(PKGLIBDIR "foo")
if (FG_DATA_DIR)
message(STATUS "Using explicit data-dir: ${FG_DATA_DIR}")
else()
set(FG_DATA_DIR "${CMAKE_INSTALL_PREFIX}/lib/FlightGear" CACHE PATH "Default location where data files are located")
message(STATUS "Using default data-dir: ${FG_DATA_DIR}")
endif()
# Change the default build type to something fast
if(NOT CMAKE_BUILD_TYPE)
@ -80,8 +84,8 @@ endif()
option(LOGGING "Set to OFF to build FlightGear without logging" ON)
option(SP_FDMS "Set to ON to build FlightGear with special-purpose FDMs" OFF)
option(ENABLE_UIUC_MODEL "Set to ON to build FlightGear with UIUCModel FDM" ON)
option(ENABLE_LARCSIM "Set to ON to build FlightGear with LaRCsim FDM" ON)
option(ENABLE_UIUC_MODEL "Set to ON to build FlightGear with UIUCModel FDM" OFF)
option(ENABLE_LARCSIM "Set to ON to build FlightGear with LaRCsim FDM" OFF)
option(ENABLE_YASIM "Set to ON to build FlightGear with YASIM FDM" ON)
option(ENABLE_JSBSIM "Set to ON to build FlightGear with JSBSim FDM" ON)
option(ENABLE_FGADMIN "Set to ON to build FlightGear with FGADMIN" ON)
@ -89,7 +93,7 @@ option(EVENT_INPUT "Set to ON to build FlightGear with event-based Input support
option(ENABLE_LIBSVN "Set to ON to build FlightGear/terrasync with libsvnclient support" ON)
option(ENABLE_RTI "Set to ON to build SimGear with RTI support" OFF)
option(WITH_FGPANEL "Set to ON to build the fgpanel application" ON)
option(JPEG_FACTORY "Enable JPEG-factory support" OFF)
if (MSVC)
GET_FILENAME_COMPONENT(PARENT_DIR ${PROJECT_SOURCE_DIR} PATH)
@ -186,6 +190,26 @@ endif(ENABLE_LIBSVN)
find_package(PLIB REQUIRED puaux pu js fnt)
find_package(SimGear 2.5.0 REQUIRED)
if (JPEG_FACTORY)
# check simgear was built with JPEG-factory support
find_package(JPEG REQUIRED)
include_directories(${JPEG_INCLUDE_DIR})
set(CMAKE_REQUIRED_INCLUDES
${SIMGEAR_INCLUDE_DIR}
${JPEG_INCLUDE_DIR}
${OPENSCENEGRAPH_INCLUDE_DIRS})
check_cxx_source_compiles(
"#include <simgear/screen/jpgfactory.hxx>
int main() { return 0; } "
FG_JPEG_SERVER)
if (NOT FG_JPEG_SERVER)
message(STATUS "JPEG server support requested, but SimGear was built without JPEG support")
endif()
endif()
check_include_file(unistd.h HAVE_UNISTD_H)
check_include_file(sys/time.h HAVE_SYS_TIME_H)
check_include_file(windows.h HAVE_WINDOWS_H)
@ -269,6 +293,7 @@ configure_file (
add_subdirectory(src)
add_subdirectory(utils)
add_subdirectory(man)
set (INSTALL_DOCS
README

View file

@ -0,0 +1,182 @@
# - Define GNU standard installation directories
# Provides install directory variables as defined for GNU software:
# http://www.gnu.org/prep/standards/html_node/Directory-Variables.html
# Inclusion of this module defines the following variables:
# CMAKE_INSTALL_<dir> - destination for files of a given type
# CMAKE_INSTALL_FULL_<dir> - corresponding absolute path
# where <dir> is one of:
# BINDIR - user executables (bin)
# SBINDIR - system admin executables (sbin)
# LIBEXECDIR - program executables (libexec)
# SYSCONFDIR - read-only single-machine data (etc)
# SHAREDSTATEDIR - modifiable architecture-independent data (com)
# LOCALSTATEDIR - modifiable single-machine data (var)
# LIBDIR - object code libraries (lib or lib64)
# INCLUDEDIR - C header files (include)
# OLDINCLUDEDIR - C header files for non-gcc (/usr/include)
# DATAROOTDIR - read-only architecture-independent data root (share)
# DATADIR - read-only architecture-independent data (DATAROOTDIR)
# INFODIR - info documentation (DATAROOTDIR/info)
# LOCALEDIR - locale-dependent data (DATAROOTDIR/locale)
# MANDIR - man documentation (DATAROOTDIR/man)
# DOCDIR - documentation root (DATAROOTDIR/doc/PROJECT_NAME)
# Each CMAKE_INSTALL_<dir> value may be passed to the DESTINATION options of
# install() commands for the corresponding file type. If the includer does
# not define a value the above-shown default will be used and the value will
# appear in the cache for editing by the user.
# Each CMAKE_INSTALL_FULL_<dir> value contains an absolute path constructed
# from the corresponding destination by prepending (if necessary) the value
# of CMAKE_INSTALL_PREFIX.
#=============================================================================
# Copyright 2011 Nikita Krupen'ko <krnekit@gmail.com>
# Copyright 2011 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
# Installation directories
#
if(NOT DEFINED CMAKE_INSTALL_BINDIR)
set(CMAKE_INSTALL_BINDIR "bin" CACHE PATH "user executables (bin)")
endif()
if(NOT DEFINED CMAKE_INSTALL_SBINDIR)
set(CMAKE_INSTALL_SBINDIR "sbin" CACHE PATH "system admin executables (sbin)")
endif()
if(NOT DEFINED CMAKE_INSTALL_LIBEXECDIR)
set(CMAKE_INSTALL_LIBEXECDIR "libexec" CACHE PATH "program executables (libexec)")
endif()
if(NOT DEFINED CMAKE_INSTALL_SYSCONFDIR)
set(CMAKE_INSTALL_SYSCONFDIR "etc" CACHE PATH "read-only single-machine data (etc)")
endif()
if(NOT DEFINED CMAKE_INSTALL_SHAREDSTATEDIR)
set(CMAKE_INSTALL_SHAREDSTATEDIR "com" CACHE PATH "modifiable architecture-independent data (com)")
endif()
if(NOT DEFINED CMAKE_INSTALL_LOCALSTATEDIR)
set(CMAKE_INSTALL_LOCALSTATEDIR "var" CACHE PATH "modifiable single-machine data (var)")
endif()
if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
set(_LIBDIR_DEFAULT "lib")
# Override this default 'lib' with 'lib64' iff:
# - we are on Linux system but NOT cross-compiling
# - we are NOT on debian
# - we are on a 64 bits system
# reason is: amd64 ABI: http://www.x86-64.org/documentation/abi.pdf
# Note that the future of multi-arch handling may be even
# more complicated than that: http://wiki.debian.org/Multiarch
if(CMAKE_SYSTEM_NAME MATCHES "Linux"
AND NOT CMAKE_CROSSCOMPILING
AND NOT EXISTS "/etc/debian_version")
if(NOT DEFINED CMAKE_SIZEOF_VOID_P)
message(AUTHOR_WARNING
"Unable to determine default CMAKE_INSTALL_LIBDIR directory because no target architecture is known. "
"Please enable at least one language before including GNUInstallDirs.")
else()
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
set(_LIBDIR_DEFAULT "lib64")
endif()
endif()
endif()
set(CMAKE_INSTALL_LIBDIR "${_LIBDIR_DEFAULT}" CACHE PATH "object code libraries (${_LIBDIR_DEFAULT})")
endif()
if(NOT DEFINED CMAKE_INSTALL_INCLUDEDIR)
set(CMAKE_INSTALL_INCLUDEDIR "include" CACHE PATH "C header files (include)")
endif()
if(NOT DEFINED CMAKE_INSTALL_OLDINCLUDEDIR)
set(CMAKE_INSTALL_OLDINCLUDEDIR "/usr/include" CACHE PATH "C header files for non-gcc (/usr/include)")
endif()
if(NOT DEFINED CMAKE_INSTALL_DATAROOTDIR)
set(CMAKE_INSTALL_DATAROOTDIR "share" CACHE PATH "read-only architecture-independent data root (share)")
endif()
#-----------------------------------------------------------------------------
# Values whose defaults are relative to DATAROOTDIR. Store empty values in
# the cache and store the defaults in local variables if the cache values are
# not set explicitly. This auto-updates the defaults as DATAROOTDIR changes.
if(NOT CMAKE_INSTALL_DATADIR)
set(CMAKE_INSTALL_DATADIR "" CACHE PATH "read-only architecture-independent data (DATAROOTDIR)")
set(CMAKE_INSTALL_DATADIR "${CMAKE_INSTALL_DATAROOTDIR}")
endif()
if(NOT CMAKE_INSTALL_INFODIR)
set(CMAKE_INSTALL_INFODIR "" CACHE PATH "info documentation (DATAROOTDIR/info)")
set(CMAKE_INSTALL_INFODIR "${CMAKE_INSTALL_DATAROOTDIR}/info")
endif()
if(NOT CMAKE_INSTALL_LOCALEDIR)
set(CMAKE_INSTALL_LOCALEDIR "" CACHE PATH "locale-dependent data (DATAROOTDIR/locale)")
set(CMAKE_INSTALL_LOCALEDIR "${CMAKE_INSTALL_DATAROOTDIR}/locale")
endif()
if(NOT CMAKE_INSTALL_MANDIR)
set(CMAKE_INSTALL_MANDIR "" CACHE PATH "man documentation (DATAROOTDIR/man)")
set(CMAKE_INSTALL_MANDIR "${CMAKE_INSTALL_DATAROOTDIR}/man")
endif()
if(NOT CMAKE_INSTALL_DOCDIR)
set(CMAKE_INSTALL_DOCDIR "" CACHE PATH "documentation root (DATAROOTDIR/doc/PROJECT_NAME)")
set(CMAKE_INSTALL_DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME}")
endif()
#-----------------------------------------------------------------------------
mark_as_advanced(
CMAKE_INSTALL_BINDIR
CMAKE_INSTALL_SBINDIR
CMAKE_INSTALL_LIBEXECDIR
CMAKE_INSTALL_SYSCONFDIR
CMAKE_INSTALL_SHAREDSTATEDIR
CMAKE_INSTALL_LOCALSTATEDIR
CMAKE_INSTALL_LIBDIR
CMAKE_INSTALL_INCLUDEDIR
CMAKE_INSTALL_OLDINCLUDEDIR
CMAKE_INSTALL_DATAROOTDIR
CMAKE_INSTALL_DATADIR
CMAKE_INSTALL_INFODIR
CMAKE_INSTALL_LOCALEDIR
CMAKE_INSTALL_MANDIR
CMAKE_INSTALL_DOCDIR
)
# Result directories
#
foreach(dir
BINDIR
SBINDIR
LIBEXECDIR
SYSCONFDIR
SHAREDSTATEDIR
LOCALSTATEDIR
LIBDIR
INCLUDEDIR
OLDINCLUDEDIR
DATAROOTDIR
DATADIR
INFODIR
LOCALEDIR
MANDIR
DOCDIR
)
if(NOT IS_ABSOLUTE ${CMAKE_INSTALL_${dir}})
set(CMAKE_INSTALL_FULL_${dir} "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_${dir}}")
else()
set(CMAKE_INSTALL_FULL_${dir} "${CMAKE_INSTALL_${dir}}")
endif()
endforeach()

View file

@ -1,184 +0,0 @@
SUBDIRS = \
tests \
man \
scripts \
src \
utils
EXTRA_DIST = \
acinclude.m4 \
autogen.sh \
projects \
README \
README.OpenAL \
README.plib \
README.OSG \
README.SimGear \
Thanks
dist-hook:
(cd $(top_srcdir); tar --exclude docs-mini/CVS --exclude hints/CVS \
-cf - docs-mini ) | (cd $(distdir); tar xvf -)
rm -rf `find $(distdir)/projects -name CVS`
##########################################################################
# extra targets to do various things ...
#
# Use "make <target>"
##########################################################################
# make the base distribution with textures, sounds and a bit of
# scenery, and all the other associated files
# note, fedora core tar does case insensitive wildcard matching for
# directories, but apparently not files ... some stupid reason. :-(
data-tar:
(cd ..; \
tar \
--exclude=CVS \
--exclude='*~' \
--exclude='*.bak' \
--exclude='*.tex' \
--exclude='*.xcf' \
--exclude='*/c172/Instruments.high' \
--exclude='*/Textures/Unused' \
--exclude='*/Textures/*.orig' \
--exclude='*/Textures.high/*.new' \
--exclude='*/Textures.high/*.orig' \
--exclude='*/Textures.high/*.save' \
--exclude='*/data/Data' \
--exclude='*/Docs/source' \
--exclude='*/Models/MNUAV' \
--exclude='*/Models/Airspace' \
-cjvf FlightGear-data-$(VERSION).tar.bz2 \
data/AI \
data/Aircraft/Generic \
data/Aircraft/Instruments \
data/Aircraft/Instruments-3d \
data/Aircraft/UIUC \
data/Aircraft/777-200 \
data/Aircraft/A6M2 \
data/Aircraft/ASK13 \
data/Aircraft/b1900d \
data/Aircraft/bo105 \
data/Aircraft/c172p \
data/Aircraft/CitationX \
data/Aircraft/Dragonfly \
data/Aircraft/dhc2 \
data/Aircraft/f-14b \
data/Aircraft/Cub \
data/Aircraft/SenecaII \
data/Aircraft/sopwithCamel \
data/Aircraft/ufo \
data/Aircraft/ZLT-NT \
data/Airports \
data/Astro \
data/ATC \
data/AUTHORS \
data/ChangeLog \
data/COPYING \
data/D* \
data/Effects \
data/Environment \
data/Fonts \
data/gui \
data/HLA \
data/Huds \
data/Input \
data/joysticks.xml \
data/keyboard.xml \
data/Lighting \
data/materials.dtd \
data/materials.xml \
data/mice.xml \
data/Models \
data/MP \
data/N* \
data/options.xml \
data/preferences.xml \
data/Protocol \
data/README \
data/Scenery/Airports \
data/Scenery/Objects \
data/Scenery/Terrain \
data/Shaders \
data/Sounds \
data/T* \
data/version \
)
fgfs-textures-high:
(cd $(HOME); \
tar -czvf fgfs-textures-high-$(VERSION)b.tar.gz \
FlightGear/Textures.high)
# make the mini JSBsim data distribution
jsbsim-data:
(cd $(HOME); \
tar czvf jsbsim-data-$(VERSION).tar.gz \
FlightGear/Aircraft \
FlightGear/Engine)
# make the documentation distribution
fgfs-docs: fgfs-docs-tar fgfs-manual-zip
fgfs-docs-tar:
( cd $(HOME); \
tar czvf fgfs-docs-$(VERSION).tar.gz FlightGear/Docs )
# fgfs-docs-zip:
# ( cd $(HOME)/Projects ; \
# zip -r fgfs-docs-$(VERSION).zip FlightGear-0.7/docs )
fgfs-manual-zip:
( cd $(HOME) ; \
zip -r fgfs-manual-$(VERSION).zip FlightGear/Docs/InstallGuide )
# make the win32-bin distribution
fgfs-win32-bin:
(cd $(HOME); \
zip -r fgfs-win32-bin-$(VERSION).zip FlightGear/runfgfs.bat \
FlightGear/bin/Win32 )
# make the win32-libs distribution (depricated)
win32-libs:
( zip -r ../win32-libs-$(VERSION).zip Win32/Makefile \
Win32/README.glut Win32/cygwinb1.dll Win32/def \
Win32/*.exp Win32/gen-def-from-errors.pl \
Win32/glut.dll Win32/glut32.dll Win32/impdef.cpp \
Win32/impdef.exe Win32/include \
Win32/install.exe \
Win32/lib Win32/zlib.lib )
# make the MacOS (MWCWP3) devel support archive
macos-devel:
( cd ..; zip -r MWCWP3_Support.zip FlightGear/MWCWP3_Support )
# clean up dependencies
clean-deps:
rm -rf .deps \
src/.deps tests/.deps \
src/*/.deps \
src/*/*/.deps \
tests/.deps
# clean up after libtool
clean-libs:
rm -rf .libs src/.libs \
src/*/.libs \
src/*/*/.libs
rm -f src/*/so_locations \
src/*/*/so_locations
# clean up after winbloze spews random case for file names :-(
clean-winbloze: clean-deps clean-libs
rm -f makefile src/Include/makefile src/makefile \
src/*/makefile \
src/*/*/makefile \
tests/makefile
rm -f src/Main/fg.exe

View file

@ -3,11 +3,7 @@
You *must* have OpenSceneGraph (OSG) installed to build this version of
FlightGear.
Notice that from FlightGear version 1.9.0, OSG version 2.7.8 or later
is required. Using earlier versions of OSG will yield serious
rendering bugs. If you are using an 'older' distribution, this may mean
a suitable version of OSG may not be availble through the usual package
repositories.
Notice that FlightGear 2.6.0 requires at least version 3.0.0.
You can get the latest version of OSG from:

View file

@ -1,5 +1,7 @@
Getting started with CMake
[Windows instructions at the end of this document]
(These instructions apply to Unix-like systems, including Cygwin and Mac. To
build using Visual Studio or some other IDE supported by CMake, most of the
information below still applies)
@ -8,7 +10,7 @@ Always compile in a separate directory to the code. For example, if the
code (eg, from Git) is at /home/curt/projects/flightgear, you might create
/home/curt/projects/fgbuild. Change into the new directory, and run
cmake ../flightger
cmake ../flightgear
To generate standard Unix Makefiles in fgbuild.
@ -153,3 +155,71 @@ If you add an additional line
Then running 'make test' will run your executable as a unit test. The
executable should return either a success or failure result code.
SPECIAL INSTRUCTIONS TO BUILD UNDER WINDOWS WITH VISUAL STUDIO
==============================================================
On Windows, assumptions on the directory structure are made to automate the discovery of dependencies.
This recommended directory structure is described below:
${MSVC_3RDPARTY_ROOT} /
3rdParty / ( includes plib, fltk, zlib, libpng, libjpeg, libtiff, freetype, libsvn, gdal, ...
bin /
include /
lib /
3rdParty.x64 / ( 64 bit version )
...
boost_1_44_0 /
boost /
install /
msvc100 / ( for VS2010 32 bits, or msvc90, msvc90-64 or msvc100-64 for VS2008 32, VS2008 64 and VS2010 64 )
OpenSceneGraph / ( OSG CMake install
bin /
include /
lib /
SimGear /
include /
lib /
If you do not use the recommended structure you will need to enter paths by hand. Source and build directories can be located anywhere.
The suggested inputs to cmake are :
MSVC_3RDPARTY_ROOT : location of the above directory structure
CMAKE_INSTALL_PREFIX : ${MSVC_3RDPARTY_ROOT}/install/msvc100/FlightGear (or any variation for the compiler version described above )
1. Set up a work directory as described above.
2. Open the Cmake gui.
3. Set "Where is the source code" to wherever you put the FlightGear sources (from the released tarball or the git repository).
4. Set "Where to build the binaries" to an empty directory.
5. Press the "Configure" button. The first time that the project is configured, Cmake will bring up a window asking which compiler you wish to use. Normally just accept Cmakes suggestion, and press Finish. Cmake will now do a check on your system and will produce a preliminary build configuration.
6. Cmake adds new configuration variables in red. Some have a value ending with -NOTFOUND. These variables should receive your attention. Some errors will prevent FlightGear to build and others will simply invalidate some options without provoking build errors. First check the MSVC_3RDPARTY_ROOT variable. If it is not set, chances are that there will be a lot of -NOTFOUND errors. Instead of trying to fix every error individually, set that variable and press the "Configure" button again.
7. Also check the lines with a checkbox. These are build options and may impact the feature set of the built program.
8. Change the CMAKE_INSTALL_PREFIX to ${MSVC_3RDPARTY_ROOT}/install/msvc100/FlightGear because C:\Program Files is likely unwritable to ordinary Windows users and will integrate better with the above directory structure (this is mandatory for SimGear if you don't want to solve errors by hand).
10. Repeat the process until the "Generate" button is enabled.
11. Press the "Generate" button.
12. Start Visual Studio 2010 and load the FlightGear solution (FlightGear.sln) located in "Where to build the binaries" (point 4.)
13. Choose the "Release" build in the VS2010 "Generation" toolbar
14. Generate the solution.
15. If there are build errors, return to Cmake, clear remaining errors, "Configure" and "Generate"
16. When Visual Studio is able to build everything without errors, build the INSTALL project to put the product files in ${CMAKE_INSTALL_PREFIX}
17. Enjoy!
PS: When updating the source from git, it is usually unnecessary to restart Cmake as the solution is able to reconfigure itself when Cmake files are changed. Simply rebuild the solution from Visual Studio and accept the reload of updated projects. It also possible to edit CMakeList.txt files directly in Visual Studio as they also appear in the solution, and projects will be reconfigured on the next generation. To change build options or directory path, it is mandatory to use the Cmake Gui. In case of problems, locate the CMakeCache.txt in "Where to build the binaries directory and delete it to reconfigure from scratch or use the menu item File->Delete Cache.

View file

@ -1,821 +0,0 @@
dnl
dnl originally from ncftp 2.3.0
dnl added wi_EXTRA_PDIR and wi_ANSI_C
dnl $Id$
dnl
AC_DEFUN([wi_EXTRA_IDIR], [
incdir="$1"
if test -r $incdir ; then
case "$CPPFLAGS" in
*-I${incdir}*)
# echo " + already had $incdir" 1>&6
;;
*)
if test "$CPPFLAGS" = "" ; then
CPPFLAGS="-I$incdir"
else
CPPFLAGS="$CPPFLAGS -I$incdir"
fi
echo " + found $incdir" 1>&6
;;
esac
fi
])
dnl
dnl
dnl
dnl
AC_DEFUN([wi_EXTRA_LDIR], [
mylibdir="$1"
if test -r $mylibdir ; then
case "$LDFLAGS" in
*-L${mylibdir}*)
# echo " + already had $mylibdir" 1>&6
;;
*)
if test "$LDFLAGS" = "" ; then
LDFLAGS="-L$mylibdir"
else
LDFLAGS="$LDFLAGS -L$mylibdir"
fi
echo " + found $mylibdir" 1>&6
;;
esac
fi
])
dnl
dnl __FP__
dnl
dnl
AC_DEFUN([wi_EXTRA_PDIR], [
progdir="$1"
if test -r $progdir ; then
case "$PATH" in
*:${progdir}*)
# echo " + already had $progdir" 1>&6
;;
*${progdir}:*)
# echo " + already had $progdir" 1>&6
;;
*)
if test "$PATH" = "" ; then
PATH="$progdir"
else
PATH="$PATH:$progdir"
fi
echo " + found $progdir" 1>&6
;;
esac
fi
])
dnl
dnl
dnl If you want to also look for include and lib subdirectories in the
dnl $HOME tree, you supply "yes" as the first argument to this macro.
dnl
dnl If you want to look for subdirectories in include/lib directories,
dnl you pass the names in argument 3, otherwise pass a dash.
dnl
AC_DEFUN([wi_EXTRA_DIRS], [echo "checking for extra include and lib directories..." 1>&6
ifelse([$1], yes, [dnl
b1=`cd .. ; pwd`
b2=`cd ../.. ; pwd`
exdirs="$HOME $j $b1 $b2 $prefix $2"
],[dnl
exdirs="$prefix $2"
])
subexdirs="$3"
if test "$subexdirs" = "" ; then
subexdirs="-"
fi
for subexdir in $subexdirs ; do
if test "$subexdir" = "-" ; then
subexdir=""
else
subexdir="/$subexdir"
fi
for exdir in $exdirs ; do
if test "$exdir" != "/usr" || test "$subexdir" != ""; then
incdir="${exdir}/include${subexdir}"
wi_EXTRA_IDIR($incdir)
mylibdir="${exdir}/lib${subexdir}"
wi_EXTRA_LDIR($mylibdir)
progdir="${exdir}/bin${subexdir}"
wi_EXTRA_PDIR($progdir)
fi
done
done
])
dnl
dnl
dnl
AC_DEFUN([wi_HPUX_CFLAGS],
[AC_MSG_CHECKING(if HP-UX ansi C compiler flags are needed)
AC_REQUIRE([AC_PROG_CC])
os=`uname -s | tr '[A-Z]' '[a-z]'`
ac_cv_hpux_flags=no
if test "$os" = hp-ux ; then
if test "$ac_cv_prog_gcc" = yes ; then
if test "$CFLAGS" != "" ; then
# Shouldn't be in there.
CFLAGS=`echo "$CFLAGS" | sed 's/-Aa//g'`
fi
else
# If you're not using gcc, then you better have a cc/c89
# that is usable. If you have the barebones compiler, it
# won't work. The good compiler uses -Aa for the ANSI
# compatible stuff.
x=`echo $CFLAGS | grep 'Aa' 2>/dev/null`
if test "$x" = "" ; then
CFLAGS="$CFLAGS -Aa"
fi
ac_cv_hpux_flags=yes
fi
# Also add _HPUX_SOURCE to get the extended namespace.
x=`echo $CFLAGS | grep '_HPUX_SOURCE' 2>/dev/null`
if test "$x" = "" ; then
CFLAGS="$CFLAGS -D_HPUX_SOURCE"
fi
fi
AC_MSG_RESULT($ac_cv_hpux_flags)
])
dnl
dnl
dnl
AC_DEFUN([wi_CFLAGS], [AC_REQUIRE([AC_PROG_CC])
wi_HPUX_CFLAGS
if test "$CFLAGS" = "" ; then
CFLAGS="-O"
elif test "$ac_cv_prog_gcc" = "yes" ; then
case "$CFLAGS" in
*"-g -O"*)
#echo "using -g as default gcc CFLAGS" 1>&6
CFLAGS=`echo $CFLAGS | sed 's/-g\ -O/-O/'`
;;
*"-O -g"*)
# Leave the -g, but remove all -O options.
#echo "using -g as default gcc CFLAGS" 1>&6
CFLAGS=`echo $CFLAGS | sed 's/-O\ -g/-O/'`
;;
esac
fi
])
dnl
dnl
dnl
AC_DEFUN([wi_PROTOTYPES], [
AC_MSG_CHECKING(if the compiler supports function prototypes)
AC_TRY_COMPILE(,[extern void exit(int status);],[wi_cv_prototypes=yes
AC_DEFINE(PROTOTYPES)],wi_cv_prototypes=no)
AC_MSG_RESULT($wi_cv_prototypes)
])
dnl
dnl
dnl
AC_DEFUN([wi_ANSI_C], [
AC_MSG_CHECKING(ANSI-style function definitions)
AC_TRY_COMPILE(,[int blubb(int x) { return 0; }],[wi_cv_ansi_funcs=yes
AC_DEFINE(ANSI_FUNCS)],wi_cv_ansi_funcs=no)
AC_MSG_RESULT($wi_cv_ansi_funcs)
])
dnl
dnl
dnl
AC_DEFUN([wi_HEADER_SYS_SELECT_H], [
# See if <sys/select.h> is includable after <sys/time.h>
if test "$ac_cv_header_sys_time_h" = no ; then
AC_CHECK_HEADERS(sys/time.h sys/select.h)
else
AC_CHECK_HEADERS(sys/select.h)
fi
if test "$ac_cv_header_sys_select_h" = yes ; then
AC_MSG_CHECKING([if <sys/select.h> is compatible with <sys/time.h>])
selecth=yes
if test "$ac_cv_header_sys_time_h" = yes ; then
AC_TRY_COMPILE([#include <sys/time.h>
#include <sys/select.h>],[
fd_set a;
struct timeval tmval;
tmval.tv_sec = 0;],selecth=yes,selecth=no)
if test "$selecth" = yes ; then
AC_DEFINE(CAN_USE_SYS_SELECT_H)
fi
fi
AC_MSG_RESULT($selecth)
fi
])
dnl
dnl
dnl
AC_DEFUN([wi_LIB_RESOLV], [
# See if we could access two well-known sites without help of any special
# libraries, like resolv.
AC_TRY_RUN([
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
main()
{
struct hostent *hp1, *hp2;
int result;
hp1 = gethostbyname("gatekeeper.dec.com");
hp2 = gethostbyname("ftp.ncsa.uiuc.edu");
result = ((hp1 != (struct hostent *) 0) && (hp2 != (struct hostent *) 0));
exit(! result);
}],look_for_resolv=no,look_for_resolv=yes,look_for_resolv=yes)
AC_MSG_CHECKING([if we need to look for -lresolv])
AC_MSG_RESULT($look_for_resolv)
if test "$look_for_resolv" = yes ; then
AC_CHECK_LIB(resolv,main)
else
ac_cv_lib_resolv=no
fi
])
dnl
dnl
dnl
AC_DEFUN([wi_LIB_NSL], [
AC_MSG_CHECKING(if we can use -lnsl)
ac_save_LIBS="$LIBS";
LIBS="$LIBS -lnsl";
AC_CACHE_VAL(r_cv_use_libnsl, [
AC_TRY_RUN(
main() { if (getpwuid(getuid())) exit(0); exit(-1); },
nc_cv_use_libnsl=yes, nc_cv_use_libnsl=no, nc_cv_use_libnsl=no)
])
if test "$nc_cv_use_libnsl" = "no"; then LIBS="$ac_save_LIBS"; fi
AC_MSG_RESULT($nc_cv_use_libnsl)
])dnl
dnl
dnl
dnl
AC_DEFUN([nc_PATH_PROG_ZCAT], [
AC_PATH_PROG(GZCAT,gzcat)
AC_PATH_PROG(ZCAT,zcat)
if test "x$GZCAT" = x ; then
if test "x$ZCAT" != x ; then
# See if zcat is really gzcat. gzcat has a --version option, regular
# zcat does not.
AC_MSG_CHECKING(if zcat is really gzcat in disguise)
if $ZCAT --version 2> /dev/null ; then
AC_DEFINE_UNQUOTED(GZCAT, "$ZCAT")
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
fi
else
AC_DEFINE_UNQUOTED(GZCAT, "$GZCAT")
fi
if test "x$ZCAT" != x ; then
AC_DEFINE_UNQUOTED(ZCAT, "$ZCAT")
fi
])
dnl
dnl
dnl
AC_DEFUN([wi_SYSV_EXTRA_DIRS], [
# Use System V because their curses extensions are required. This must
# be done early so we use the -I and -L in the library checks also.
# This is mostly a Solaris/SunOS hack. Note that doing this will also
# use all of the other System V libraries and headers.
AC_MSG_CHECKING(for alternative System V libraries)
if test -f /usr/5include/curses.h ; then
CPPFLAGS="$CPPFLAGS -I/usr/5include"
LDFLAGS="$LDFLAGS -L/usr/5lib"
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
])
dnl
dnl
dnl
AC_DEFUN([wi_DEFINE_UNAME], [
# Get first 127 chars of all uname information. Some folks have
# way too much stuff there, so grab only the first 127.
unam=`uname -a 2>/dev/null | cut -c1-127`
if test "$unam" != "" ; then
AC_DEFINE_UNQUOTED(UNAME, "$unam")
fi
])
dnl
dnl
dnl
AC_DEFUN([wi_READLINE_WITH_NCURSES], [
# Readline and Ncurses could both define "backspace".
# Warn about this if we have both things in our definitions list.
if test "$ac_cv_lib_readline" = yes && test "$ac_cv_lib_ncurses" = yes ; then
AC_MSG_CHECKING(if readline and ncurses will link together)
j="$LIBS"
LIBS="-lreadline -lncurses"
AC_TRY_LINK(,[
readline("prompt");
endwin();
],k=yes,k=no)
if test "$k" = no ; then
AC_MSG_RESULT(no)
# Remove '-lreadline' from LIBS.
LIBS=`echo $j | sed s/-lreadline//g`
ac_cv_lib_readline=no
AC_WARN([The versions of GNU readline and ncurses you have installed on this system
can't be used together, because they use the same symbol, backspace. If
possible, recompile one of the libraries with -Dbackspace=back_space, then
re-run configure.])
else
AC_MSG_RESULT(yes)
LIBS="$j"
fi
fi
])
dnl
dnl
dnl
dnl AC_EXT_DAYLIGHT
dnl Check for an external variable daylight. Stolen from w3c-libwww.
AC_DEFUN([AC_EXT_DAYLIGHT],
[ AC_MSG_CHECKING(int daylight variable)
AC_TRY_COMPILE([#include <time.h>], [return daylight;],
have_daylight=yes,
have_daylight=no)
AC_MSG_RESULT($have_daylight)
])dnl
dnl AC_EXT_TIMEZONE
dnl Check for an external variable timezone. Stolen from tcl-8.0.
AC_DEFUN([AC_EXT_TIMEZONE],
[
#
# Its important to include time.h in this check, as some systems (like convex)
# have timezone functions, etc.
#
have_timezone=no
AC_MSG_CHECKING([long timezone variable])
AC_TRY_COMPILE([#include <time.h>],
[extern long timezone;
timezone += 1;
exit (0);],
[have_timezone=yes
AC_MSG_RESULT(yes)],
AC_MSG_RESULT(no))
#
# On some systems (eg IRIX 6.2), timezone is a time_t and not a long.
#
if test "$have_timezone" = no; then
AC_MSG_CHECKING([time_t timezone variable])
AC_TRY_COMPILE([#include <time.h>],
[extern time_t timezone;
timezone += 1;
exit (0);],
[have_timezone=yes
AC_MSG_RESULT(yes)],
AC_MSG_RESULT(no))
fi
])dnl
pushdef([AC_PROG_INSTALL],
[
dnl our own version, testing for a -p flag
popdef([AC_PROG_INSTALL])
dnl as AC_PROG_INSTALL works as it works we first have
dnl to save if the user didn't specify INSTALL, as the
dnl autoconf one overwrites INSTALL and we have no chance to find
dnl out afterwards
AC_PROG_INSTALL
# OK, user hasn't given any INSTALL, autoconf found one for us
# now we test, if it supports the -p flag
AC_MSG_CHECKING(for -p flag to install)
rm -f confinst.$$.* > /dev/null 2>&1
echo "Testtest" > confinst.$$.orig
ac_res=no
if ${INSTALL} -p confinst.$$.orig confinst.$$.new > /dev/null 2>&1 ; then
if test -f confinst.$$.new ; then
# OK, -p seems to do no harm to install
INSTALL="${INSTALL} -p"
ac_res=yes
fi
fi
rm -f confinst.$$.*
AC_MSG_RESULT($ac_res)
dnl the following tries to resolve some signs and wonders coming up
dnl with different autoconf/automake versions
dnl e.g.:
dnl *automake 1.4 install-strip sets A_M_INSTALL_PROGRAM_FLAGS to -s
dnl and has INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(A_M_INSTALL_PROGRAM_FLAGS)
dnl it header-vars.am, so there the actual INSTALL_PROGRAM gets the -s
dnl *automake 1.4a (and above) use INSTALL_STRIP_FLAG and only has
dnl INSTALL_PROGRAM = @INSTALL_PROGRAM@ there, but changes the
dnl install-@DIR@PROGRAMS targets to explicitly use that flag
dnl *autoconf 2.13 is dumb, and thinks it can use INSTALL_PROGRAM as
dnl INSTALL_SCRIPT, which breaks with automake <= 1.4
dnl *autoconf >2.13 (since 10.Apr 1999) has not that failure
dnl to clean up that mess we:
dnl +set INSTALL_PROGRAM to use INSTALL_STRIP_FLAG
dnl which cleans KDE's program with automake > 1.4;
dnl +set INSTALL_SCRIPT to only use INSTALL, to clean up autoconf's problems
dnl with automake<=1.4
dnl note that dues to this sometimes two '-s' flags are used
INSTALL_PROGRAM='${INSTALL} $(INSTALL_STRIP_FLAG)'
INSTALL_SCRIPT='${INSTALL}'
])dnl
# ===========================================================================
# http://autoconf-archive.cryp.to/ax_boost_base.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_BOOST_BASE([MINIMUM-VERSION])
#
# DESCRIPTION
#
# Test for the Boost C++ libraries of a particular version (or newer)
#
# If no path to the installed boost library is given the macro searchs
# under /usr, /usr/local, /opt and /opt/local and evaluates the
# $BOOST_ROOT environment variable. Further documentation is available at
# <http://randspringer.de/boost/index.html>.
#
# This macro calls:
#
# AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS)
#
# And sets:
#
# HAVE_BOOST
#
# LAST MODIFICATION
#
# 2008-04-12
#
# COPYLEFT
#
# Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved.
AC_DEFUN([AX_BOOST_BASE],
[
AC_ARG_WITH([boost],
AS_HELP_STRING([--with-boost@<:@=DIR@:>@], [use boost (default is yes) - it is possible to specify the root directory for boost (optional)]),
[
if test "$withval" = "no"; then
want_boost="no"
elif test "$withval" = "yes"; then
want_boost="yes"
ac_boost_path=""
else
want_boost="yes"
ac_boost_path="$withval"
fi
],
[want_boost="yes"])
AC_ARG_WITH([boost-libdir],
AS_HELP_STRING([--with-boost-libdir=LIB_DIR],
[Force given directory for boost libraries. Note that this will overwrite library path detection, so use this parameter only if default library detection fails and you know exactly where your boost libraries are located.]),
[
if test -d $withval
then
ac_boost_lib_path="$withval"
else
AC_MSG_ERROR(--with-boost-libdir expected directory name)
fi
],
[ac_boost_lib_path=""]
)
if test "x$want_boost" = "xyes"; then
boost_lib_version_req=ifelse([$1], ,1.20.0,$1)
boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'`
boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'`
boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
if test "x$boost_lib_version_req_sub_minor" = "x" ; then
boost_lib_version_req_sub_minor="0"
fi
WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+ $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor`
AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req)
succeeded=no
dnl first we check the system location for boost libraries
dnl this location ist chosen if boost libraries are installed with the --layout=system option
dnl or if you install boost with RPM
if test "$ac_boost_path" != ""; then
BOOST_LDFLAGS="-L$ac_boost_path/lib"
BOOST_CPPFLAGS="-I$ac_boost_path/include"
else
for ac_boost_path_tmp in /usr /usr/local /opt /opt/local ; do
if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then
BOOST_LDFLAGS="-L$ac_boost_path_tmp/lib"
BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include"
break;
fi
done
fi
dnl overwrite ld flags if we have required special directory with
dnl --with-boost-libdir parameter
if test "$ac_boost_lib_path" != ""; then
BOOST_LDFLAGS="-L$ac_boost_lib_path"
fi
CPPFLAGS_SAVED="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
export CPPFLAGS
LDFLAGS_SAVED="$LDFLAGS"
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
export LDFLAGS
AC_LANG_PUSH(C++)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
@%:@include <boost/version.hpp>
]], [[
#if BOOST_VERSION >= $WANT_BOOST_VERSION
// Everything is okay
#else
# error Boost version is too old
#endif
]])],[
AC_MSG_RESULT(yes)
succeeded=yes
found_system=yes
],[
])
AC_LANG_POP([C++])
dnl if we found no boost with system layout we search for boost libraries
dnl built and installed without the --layout=system option or for a staged(not installed) version
if test "x$succeeded" != "xyes"; then
_version=0
if test "$ac_boost_path" != ""; then
if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
V_CHECK=`expr $_version_tmp \> $_version`
if test "$V_CHECK" = "1" ; then
_version=$_version_tmp
fi
VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE"
done
fi
else
for ac_boost_path in /usr /usr/local /opt /opt/local ; do
if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
V_CHECK=`expr $_version_tmp \> $_version`
if test "$V_CHECK" = "1" ; then
_version=$_version_tmp
best_path=$ac_boost_path
fi
done
fi
done
VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE"
if test "$ac_boost_lib_path" = ""
then
BOOST_LDFLAGS="-L$best_path/lib"
fi
if test "x$BOOST_ROOT" != "x"; then
if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/lib" && test -r "$BOOST_ROOT/stage/lib"; then
version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'`
stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'`
stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'`
V_CHECK=`expr $stage_version_shorten \>\= $_version`
if test "$V_CHECK" = "1" -a "$ac_boost_lib_path" = "" ; then
AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT)
BOOST_CPPFLAGS="-I$BOOST_ROOT"
BOOST_LDFLAGS="-L$BOOST_ROOT/stage/lib"
fi
fi
fi
fi
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
export CPPFLAGS
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
export LDFLAGS
AC_LANG_PUSH(C++)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
@%:@include <boost/version.hpp>
]], [[
#if BOOST_VERSION >= $WANT_BOOST_VERSION
// Everything is okay
#else
# error Boost version is too old
#endif
]])],[
AC_MSG_RESULT(yes)
succeeded=yes
found_system=yes
],[
])
AC_LANG_POP([C++])
fi
if test "$succeeded" != "yes" ; then
if test "$_version" = "0" ; then
AC_MSG_ERROR([[We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option. If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>. See http://randspringer.de/boost for more documentation.]])
else
AC_MSG_ERROR([Your boost libraries seems to old (version $_version).])
fi
else
AC_SUBST(BOOST_CPPFLAGS)
AC_SUBST(BOOST_LDFLAGS)
AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available])
fi
CPPFLAGS="$CPPFLAGS_SAVED"
LDFLAGS="$LDFLAGS_SAVED"
fi
])
# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
#
# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# PKG_PROG_PKG_CONFIG([MIN-VERSION])
# ----------------------------------
AC_DEFUN([PKG_PROG_PKG_CONFIG],
[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
fi
if test -n "$PKG_CONFIG"; then
_pkg_min_version=m4_default([$1], [0.9.0])
AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
PKG_CONFIG=""
fi
fi[]dnl
])# PKG_PROG_PKG_CONFIG
# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
#
# Check to see whether a particular set of modules exists. Similar
# to PKG_CHECK_MODULES(), but does not set variables or print errors.
#
#
# Similar to PKG_CHECK_MODULES, make sure that the first instance of
# this or PKG_CHECK_MODULES is called, or make sure to call
# PKG_CHECK_EXISTS manually
# --------------------------------------------------------------
AC_DEFUN([PKG_CHECK_EXISTS],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
if test -n "$PKG_CONFIG" && \
AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
m4_ifval([$2], [$2], [:])
m4_ifvaln([$3], [else
$3])dnl
fi])
# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
# ---------------------------------------------
m4_define([_PKG_CONFIG],
[if test -n "$$1"; then
pkg_cv_[]$1="$$1"
elif test -n "$PKG_CONFIG"; then
PKG_CHECK_EXISTS([$3],
[pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
[pkg_failed=yes])
else
pkg_failed=untried
fi[]dnl
])# _PKG_CONFIG
# _PKG_SHORT_ERRORS_SUPPORTED
# -----------------------------
AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
else
_pkg_short_errors_supported=no
fi[]dnl
])# _PKG_SHORT_ERRORS_SUPPORTED
# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
# [ACTION-IF-NOT-FOUND])
#
#
# Note that if there is a possibility the first call to
# PKG_CHECK_MODULES might not happen, you should be sure to include an
# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
#
#
# --------------------------------------------------------------
AC_DEFUN([PKG_CHECK_MODULES],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
pkg_failed=no
AC_MSG_CHECKING([for $1])
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
and $1[]_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.])
if test $pkg_failed = yes; then
_PKG_SHORT_ERRORS_SUPPORTED
if test $_pkg_short_errors_supported = yes; then
$1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1`
else
$1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
ifelse([$4], , [AC_MSG_ERROR(dnl
[Package requirements ($2) were not met:
$$1_PKG_ERRORS
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
_PKG_TEXT
])],
[AC_MSG_RESULT([no])
$4])
elif test $pkg_failed = untried; then
ifelse([$4], , [AC_MSG_FAILURE(dnl
[The pkg-config script could not be found or is too old. Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
path to pkg-config.
_PKG_TEXT
To get pkg-config, see <http://pkg-config.freedesktop.org/>.])],
[$4])
else
$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
AC_MSG_RESULT([yes])
ifelse([$3], , :, [$3])
fi[]dnl
])# PKG_CHECK_MODULES

View file

@ -1,72 +0,0 @@
type = ConsoleApplication,Multithreaded,Debug
exclude_dir = NetworkOLK
exclude_dir = Weather
exclude_file = src\GUI\net_dlg.cxx
exclude_file = src\GUI\net_dlg.hxx
include_path = ..
include_path = src
include_path = src\include
include_path = src\FDM\JSBsim
include_path = ..\SimGear
include_path = ..\zlib-1.2.3
include_path = ..\freeglut-2.4.0\include
include_path = "..\OpenAL 1.0 Software Development Kit\include"
include_path = ..\Pre-built.2\include
define = _USE_MATH_DEFINES
define = _CRT_SECURE_NO_DEPRECATE
define = HAVE_CONFIG_H
define = FGFS
#define = FG_NDEBUG
#define = FG_NETWORK_OLK
#define = FG_JPEG_SERVER
define = FG_NEW_ENVIRONMENT
#define = FG_NEW_MOUSE
define = ENABLE_AUDIO_SUPPORT
define = ENABLE_PLIB_JOYSTICK
#add_lib = glut32.lib
#lib_path = ..\plib
#add_lib = ssg
#add_lib = sg
#add_lib = pui
#add_lib = fnt
#add_lib = sl
#add_lib = ul
#add_lib = ssgaux
#add_lib = net
#lib_path = ..\SimGear
#add_lib = SimGear
#add_project = ..\SimGear\SimGear.dsp
# Rule to create config.h
add_source_file = SOURCE = .\src\Include\config.h-msvc6\
\
!IF "$(CFG)" == "FlightGear - Win32 Release"\
\
# Begin Custom Build - Creating config.h\
InputPath=.\src\Include\config.h-msvc6\
\
".\src\Include\config.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\
copy .\src\Include\config.h-msvc6 .\src\Include\config.h\
\
# End Custom Build\
\
!ELSEIF "$(CFG)" == "FlightGear - Win32 Debug"\
\
# Begin Custom Build - Creating config.h\
InputPath=.\src\Include\config.h-msvc6\
\
".\src\Include\config.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\
copy .\src\Include\config.h-msvc6 .\src\Include\config.h\
\
# End Custom Build\
\
!ENDIF\

View file

@ -1,35 +0,0 @@
#!/bin/sh
echo "Running aclocal"
aclocal
echo "Running autoheader"
autoheader
if [ ! -e src/Include/config.h.in ]; then
echo "ERROR: autoheader didn't create simgear/simgear_config.h.in!"
exit 1
fi
echo "Running automake --add-missing"
automake --add-missing
echo "Running autoconf"
autoconf
if [ ! -e configure ]; then
echo "ERROR: configure was not created!"
exit 1
fi
echo ""
echo "======================================"
if [ -f config.cache ]; then
echo "config.cache exists. Removing the config.cache file will force"
echo "the ./configure script to rerun all it's tests rather than using"
echo "the previously cached values."
echo ""
fi
echo "Now you are ready to run './configure'"
echo "======================================"

File diff suppressed because it is too large Load diff

24
man/CMakeLists.txt Normal file
View file

@ -0,0 +1,24 @@
include(GNUInstallDirs)
set(MANPAGES
est-epsilon.1
fgfs.1
fgjs.1
gl-info.1
js_demo.1
pstest.1)
# map some variables to what the man-pages expect
set(PACKAGE ${CMAKE_PROJECT_NAME})
set(VERSION ${FLIGHTGEAR_VERSION})
foreach(man ${MANPAGES})
configure_file (
"${PROJECT_SOURCE_DIR}/man/${man}.in"
"${PROJECT_BINARY_DIR}/man/${man}"
)
install(FILES ${PROJECT_BINARY_DIR}/man/${man}
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT doc)
endforeach()

View file

@ -1,3 +0,0 @@
MAINTAINERCLEANFILES = Makefile.in
man_MANS = est-epsilon.1 fgfs.1 fgjs.1 gl-info.1 js_demo.1 pstest.1

View file

@ -89,7 +89,7 @@ Section "" ;No components page, name is not important
; VC runtime redistributables
File "$%VCINSTALLDIR%\redist\x86\Microsoft.VC100.CRT\*.dll"
File /r ${FGRunDir}\share
File /r ${FGRunDir}\share\locale
SetOutPath $INSTDIR\osgPlugins-${OSGVersion}
File ${OSGPluginsDir}\osgdb_ac.dll
@ -102,6 +102,7 @@ Section "" ;No components page, name is not important
File ${OSGPluginsDir}\osgdb_png.dll
File ${OSGPluginsDir}\osgdb_dds.dll
File ${OSGPluginsDir}\osgdb_txf.dll
File ${OSGPluginsDir}\osgdb_freetype.dll
File ${OSGPluginsDir}\osgdb_serializers_osg.dll
File ${OSGPluginsDir}\osgdb_serializers_osganimation.dll
File ${OSGPluginsDir}\osgdb_serializers_osgfx.dll

View file

@ -20,7 +20,8 @@
; C:\> subst X: /d
;
#define FGVER "v20110324"
#define FGVER "v20111024"
;#define FGVER "2.4.0"
[Setup]
AppId=FlightGear {#FGVER}

View file

@ -0,0 +1,91 @@
#!/bin/sh
echo $1 $2
if [ "x$1" != "x" ]; then
BASE="$1"
else
BASE="/home/curt/Projects/FlightGear/"
fi
if [ "x$2" != "x" ]; then
VERSION="$2"
else
VERSION="2.5"
fi
echo base dir = $BASE, version = $VERSION
cd $BASE
tar \
--exclude=CVS \
--exclude='*~' \
--exclude='*.bak' \
--exclude='*.tex' \
--exclude='*.xcf' \
--exclude='*/c172/Instruments.high' \
--exclude='*/Textures/Unused' \
--exclude='*/Textures/*.orig' \
--exclude='*/Textures.high/*.new' \
--exclude='*/Textures.high/*.orig' \
--exclude='*/Textures.high/*.save' \
--exclude='*/data/Data' \
--exclude='*/Docs/source' \
--exclude='*/Models/MNUAV' \
--exclude='*/Models/Airspace' \
-cjvf FlightGear-data-${VERSION}.tar.bz2 \
data/AI \
data/Aircraft/Generic \
data/Aircraft/Instruments \
data/Aircraft/Instruments-3d \
data/Aircraft/UIUC \
data/Aircraft/777-200 \
data/Aircraft/A6M2 \
data/Aircraft/ASK13 \
data/Aircraft/b1900d \
data/Aircraft/bo105 \
data/Aircraft/c172p \
data/Aircraft/CitationX \
data/Aircraft/Dragonfly \
data/Aircraft/dhc2 \
data/Aircraft/f-14b \
data/Aircraft/Cub \
data/Aircraft/SenecaII \
data/Aircraft/sopwithCamel \
data/Aircraft/ufo \
data/Aircraft/ZLT-NT \
data/Airports \
data/Astro \
data/ATC \
data/AUTHORS \
data/ChangeLog \
data/COPYING \
data/D* \
data/Effects \
data/Environment \
data/Fonts \
data/gui \
data/HLA \
data/Huds \
data/Input \
data/joysticks.xml \
data/keyboard.xml \
data/Lighting \
data/materials.dtd \
data/materials.xml \
data/mice.xml \
data/Models \
data/MP \
data/N* \
data/options.xml \
data/preferences.xml \
data/Protocol \
data/README \
data/Scenery/Airports \
data/Scenery/Objects \
data/Scenery/Terrain \
data/Shaders \
data/Sounds \
data/T* \
data/version

View file

@ -1 +0,0 @@
SUBDIRS = debug perl python

View file

@ -1 +0,0 @@
EXTRA_DIST = debug-fgfs sample.fgfs.supp

View file

@ -1 +0,0 @@
EXTRA_DIST = fgfsclient.c fgfsclient.cxx fgfsscript remote.html

View file

@ -1,3 +0,0 @@
SUBDIRS = src docs
EXTRA_DIST = build.xml fgfsclient.jar README main-class.txt

View file

@ -1 +0,0 @@
SUBDIRS = javadoc

View file

@ -1,4 +0,0 @@
EXTRA_DIST = index-all.html llclasses-frame.html index.html \
deprecated-list.html serialized-form.html help-doc.html \
overview-tree.html stylesheet.css package-list

View file

@ -1 +0,0 @@
EXTRA_DIST = FGFSDemo.java

View file

@ -1,2 +0,0 @@
SUBDIRS = examples \
traffic

View file

@ -1 +0,0 @@
EXTRA_DIST = build_ils.pl dafift2fix.pl dafift2ils.pl dafift2nav.pl

View file

@ -1,9 +0,0 @@
EXTRA_DIST = \
aircraft.pl \
autopilot.pl \
environment.pl \
flyplan.pl \
logging.pl \
position.pl \
reset.pl \
telnet.pl

View file

@ -1 +0,0 @@
EXTRA_DIST = calc-tile.pl

View file

@ -1,3 +0,0 @@
EXTRA_DIST = \
conf2xml.pl \
xml2conf.pl

View file

@ -1 +0,0 @@
EXTRA_DIST = FlightGear.py demo.py

View file

@ -820,10 +820,10 @@ bool FGAIAircraft::leadPointReached(FGAIWaypoint* curr) {
}
if (trafficRef) {
//cerr << "Tracking callsign : \"" << fgGetString("/ai/track-callsign") << "\"" << endl;
/* if (trafficRef->getCallSign() == fgGetString("/ai/track-callsign")) {
cerr << trafficRef->getCallSign() << " " << tgt_altitude_ft << " " << _getSpeed() << " "
<< _getAltitude() << " "<< _getLatitude() << " " << _getLongitude() << " " << dist_to_go << " " << lead_dist << " " << curr->name << " " << vs << " " << tgt_vs << " " << bearing << " " << minBearing << " " << speedFraction << endl;
}*/
//if (trafficRef->getCallSign() == fgGetString("/ai/track-callsign")) {
//cerr << trafficRef->getCallSign() << " " << tgt_altitude_ft << " " << _getSpeed() << " "
// << _getAltitude() << " "<< _getLatitude() << " " << _getLongitude() << " " << dist_to_go << " " << lead_dist << " " << curr->getName() << " " << vs << " " << //tgt_vs << " " << bearing << " " << minBearing << " " << speedFraction << endl;
//}
}
if ((dist_to_go < lead_dist) ||
((dist_to_go > prev_dist_to_go) && (bearing > (minBearing * 1.1))) ) {
@ -1275,9 +1275,9 @@ void FGAIAircraft::updateActualState() {
updatePosition();
if (onGround())
speed = _performance->actualSpeed(this, groundTargetSpeed, dt);
speed = _performance->actualSpeed(this, groundTargetSpeed, dt, holdPos);
else
speed = _performance->actualSpeed(this, (tgt_speed *speedFraction), dt);
speed = _performance->actualSpeed(this, (tgt_speed *speedFraction), dt, false);
//assertSpeed(speed);
updateHeading();
roll = _performance->actualBankAngle(this, tgt_roll, dt);

View file

@ -267,7 +267,7 @@ bool FGAIBase::init(bool search_in_AI_path) {
else
_installed = true;
osg::Node * mdl = SGModelLib::loadPagedModel(f, props, new FGNasalModelData(props));
osg::Node * mdl = SGModelLib::loadDeferredModel(f, props, new FGNasalModelData(props));
if (_model.valid())
{

View file

@ -357,7 +357,7 @@ void FGAIFlightPlan::createDefaultLandingTaxi(FGAIAircraft * ac,
double heading, lat, lon;
aAirport->getDynamics()->getParking(gateId, &lat, &lon, &heading);
wpt =
createOnGround(ac, "END", SGGeod::fromDeg(lon, lat), airportElev,
createOnGround(ac, "ENDtaxi", SGGeod::fromDeg(lon, lat), airportElev,
ac->getPerformance()->vTaxi());
pushBackWaypoint(wpt);
}
@ -1039,7 +1039,7 @@ bool FGAIFlightPlan::createParking(FGAIAircraft * ac, FGAirport * apt,
pushBackWaypoint(wpt);
wpt =
createOnGround(ac, "END", SGGeod::fromDeg(lon, lat), aptElev,
createOnGround(ac, "END-Parking", SGGeod::fromDeg(lon, lat), aptElev,
vTaxiReduced);
pushBackWaypoint(wpt);
return true;

View file

@ -38,13 +38,13 @@
// TODO: Use James Turner's createOnGround functions.
bool FGAIFlightPlan::createPushBack(FGAIAircraft *ac,
bool firstFlight, FGAirport *dep,
double latitude,
double longitude,
double radius,
const string& fltType,
const string& aircraftType,
const string& airline)
bool firstFlight, FGAirport *dep,
double latitude,
double longitude,
double radius,
const string& fltType,
const string& aircraftType,
const string& airline)
{
double lat, lon, heading;
double vTaxi = ac->getPerformance()->vTaxi();
@ -56,185 +56,185 @@ bool FGAIFlightPlan::createPushBack(FGAIAircraft *ac,
activeRunway.clear();
if (!(dep->getDynamics()->getGroundNetwork()->exists())) {
//cerr << "Push Back fallback" << endl;
createPushBackFallBack(ac, firstFlight, dep, latitude, longitude,
radius, fltType, aircraftType, airline);
//cerr << "Push Back fallback" << endl;
createPushBackFallBack(ac, firstFlight, dep, latitude, longitude,
radius, fltType, aircraftType, airline);
} else {
if (firstFlight) {
if (!(dep->getDynamics()->getAvailableParking(&lat, &lon,
&heading, &gateId,
radius, fltType,
aircraftType, airline))) {
SG_LOG(SG_INPUT, SG_WARN, "Warning: Could not find parking for a " <<
aircraftType <<
" of flight type " << fltType <<
" of airline " << airline <<
" at airport " << dep->getId());
return false;
char buffer[10];
snprintf (buffer, 10, "%d", gateId);
SGGeod coord = coord.fromDeg(lon, lat);
//FGTaxiNode *tn = dep->getDynamics()->getGroundNetwork()->findNode(node);
FGAIWaypoint *wpt = createOnGround(ac, string(buffer), coord, dep->getElevation(), vTaxiBackward);
wpt->setRouteIndex(-1);
pushBackWaypoint(wpt);
}
//cerr << "Success : GateId = " << gateId << endl;
SG_LOG(SG_INPUT, SG_WARN, "Warning: Succesfully found a parking for a " <<
aircraftType <<
" of flight type " << fltType <<
" of airline " << airline <<
" at airport " << dep->getId());
} else {
//cerr << "Push Back follow-up Flight" << endl;
dep->getDynamics()->getParking(gateId, &lat, &lon, &heading);
}
if (gateId < 0) {
createPushBackFallBack(ac, firstFlight, dep, latitude, longitude,
radius, fltType, aircraftType, airline);
return true;
if (firstFlight) {
}
//cerr << "getting parking " << gateId;
//cerr << " for a " <<
// aircraftType <<
// " of flight type " << fltType <<
// " of airline " << airline <<
// " at airport " << dep->getId() << endl;
FGParking *parking = dep->getDynamics()->getParking(gateId);
int pushBackNode = parking->getPushBackPoint();
if (!(dep->getDynamics()->getAvailableParking(&lat, &lon,
&heading, &gateId,
radius, fltType,
aircraftType, airline))) {
SG_LOG(SG_INPUT, SG_WARN, "Warning: Could not find parking for a " <<
aircraftType <<
" of flight type " << fltType <<
" of airline " << airline <<
" at airport " << dep->getId());
return false;
char buffer[10];
snprintf (buffer, 10, "%d", gateId);
SGGeod coord = coord.fromDeg(lon, lat);
//FGTaxiNode *tn = dep->getDynamics()->getGroundNetwork()->findNode(node);
FGAIWaypoint *wpt = createOnGround(ac, string(buffer), coord, dep->getElevation(), vTaxiBackward);
wpt->setRouteIndex(-1);
pushBackWaypoint(wpt);
}
//cerr << "Success : GateId = " << gateId << endl;
SG_LOG(SG_INPUT, SG_WARN, "Warning: Succesfully found a parking for a " <<
aircraftType <<
" of flight type " << fltType <<
" of airline " << airline <<
" at airport " << dep->getId());
} else {
//cerr << "Push Back follow-up Flight" << endl;
dep->getDynamics()->getParking(gateId, &lat, &lon, &heading);
}
if (gateId < 0) {
createPushBackFallBack(ac, firstFlight, dep, latitude, longitude,
radius, fltType, aircraftType, airline);
return true;
}
//cerr << "getting parking " << gateId;
//cerr << " for a " <<
// aircraftType <<
// " of flight type " << fltType <<
// " of airline " << airline <<
// " at airport " << dep->getId() << endl;
FGParking *parking = dep->getDynamics()->getParking(gateId);
int pushBackNode = parking->getPushBackPoint();
pushBackRoute = parking->getPushBackRoute();
if ((pushBackNode > 0) && (pushBackRoute == 0)) { // Load the already established route for this gate
int node, rte;
FGTaxiRoute route;
//cerr << "Creating push-back for " << gateId << " (" << parking->getName() << ") using push-back point " << pushBackNode << endl;
route = dep->getDynamics()->getGroundNetwork()->findShortestRoute(gateId, pushBackNode, false);
parking->setPushBackRoute(new FGTaxiRoute(route));
pushBackRoute = parking->getPushBackRoute();
if ((pushBackNode > 0) && (pushBackRoute == 0)) { // Load the already established route for this gate
int node, rte;
FGTaxiRoute route;
//cerr << "Creating push-back for " << gateId << " (" << parking->getName() << ") using push-back point " << pushBackNode << endl;
route = dep->getDynamics()->getGroundNetwork()->findShortestRoute(gateId, pushBackNode, false);
parking->setPushBackRoute(new FGTaxiRoute(route));
pushBackRoute = parking->getPushBackRoute();
int size = pushBackRoute->size();
if (size < 2) {
SG_LOG(SG_GENERAL, SG_WARN, "Push back route from gate " << gateId << " has only " << size << " nodes.");
SG_LOG(SG_GENERAL, SG_WARN, "Using " << pushBackNode);
}
pushBackRoute->first();
while(pushBackRoute->next(&node, &rte))
{
//FGTaxiNode *tn = apt->getDynamics()->getGroundNetwork()->findSegment(node)->getEnd();
char buffer[10];
snprintf (buffer, 10, "%d", node);
FGTaxiNode *tn = dep->getDynamics()->getGroundNetwork()->findNode(node);
//ids.pop_back();
//wpt = new waypoint;
SGGeod coord = coord.fromDeg(tn->getLongitude(), tn->getLatitude());
FGAIWaypoint *wpt = createOnGround(ac, string(buffer), coord, dep->getElevation(), vTaxiBackward);
wpt->setRouteIndex(rte);
pushBackWaypoint(wpt);
}
// some special considerations for the last point:
waypoints.back()->setName(string("PushBackPoint"));
waypoints.back()->setSpeed(vTaxi);
ac->setTaxiClearanceRequest(true);
} else { // In case of a push forward departure...
ac->setTaxiClearanceRequest(false);
double lat2 = 0.0, lon2 = 0.0, az2 = 0.0;
pushBackRoute = parking->getPushBackRoute();
int size = pushBackRoute->size();
if (size < 2) {
SG_LOG(SG_GENERAL, SG_WARN, "Push back route from gate " << gateId << " has only " << size << " nodes.");
SG_LOG(SG_GENERAL, SG_WARN, "Using " << pushBackNode);
}
pushBackRoute->first();
while (pushBackRoute->next(&node, &rte))
{
//FGTaxiNode *tn = apt->getDynamics()->getGroundNetwork()->findSegment(node)->getEnd();
char buffer[10];
snprintf (buffer, 10, "%d", node);
FGTaxiNode *tn = dep->getDynamics()->getGroundNetwork()->findNode(node);
//ids.pop_back();
//wpt = new waypoint;
SGGeod coord = coord.fromDeg(tn->getLongitude(), tn->getLatitude());
FGAIWaypoint *wpt = createOnGround(ac, string(buffer), coord, dep->getElevation(), vTaxiBackward);
//cerr << "Creating final push forward point for gate " << gateId << endl;
FGTaxiNode *tn = dep->getDynamics()->getGroundNetwork()->findNode(gateId);
FGTaxiSegmentVectorIterator ts = tn->getBeginRoute();
FGTaxiSegmentVectorIterator te = tn->getEndRoute();
// if the starting node equals the ending node, then there aren't any routes for this parking.
// in cases like these we should flag the gate as being inoperative and return false
if (ts == te) {
SG_LOG(SG_GENERAL, SG_ALERT, "Gate " << gateId << "doesn't seem to have routes associated with it.");
parking->setAvailable(false);
return false;
}
tn = (*ts)->getEnd();
lastNodeVisited = tn->getIndex();
if (tn == NULL) {
SG_LOG(SG_GENERAL, SG_ALERT, "No valid taxinode found");
exit(1);
}
double distance = (*ts)->getLength();
//cerr << "Length of push forward route = " << distance << " and heading is " << heading << endl;
lat2 = tn->getLatitude();
lon2 = tn->getLongitude();
wpt->setRouteIndex(rte);
pushBackWaypoint(wpt);
}
// some special considerations for the last point:
waypoints.back()->setName(string("PushBackPoint"));
waypoints.back()->setSpeed(vTaxi);
ac->setTaxiClearanceRequest(true);
} else { // In case of a push forward departure...
ac->setTaxiClearanceRequest(false);
double lat2 = 0.0, lon2 = 0.0, az2 = 0.0;
for (int i = 1; i < 10; i++) {
geo_direct_wgs_84 ( 0, lat, lon, heading,
((i / 10.0) * distance), &lat2, &lon2, &az2 );
char buffer[16];
snprintf(buffer, 16, "pushback-%02d", i);
SGGeod coord = coord.fromDeg(lon2, lat2);
//cerr << i << endl;
FGAIWaypoint *wpt = createOnGround(ac, string(buffer), coord, dep->getElevation(), vTaxiReduced);
//cerr << "Creating final push forward point for gate " << gateId << endl;
FGTaxiNode *tn = dep->getDynamics()->getGroundNetwork()->findNode(gateId);
FGTaxiSegmentVectorIterator ts = tn->getBeginRoute();
FGTaxiSegmentVectorIterator te = tn->getEndRoute();
// if the starting node equals the ending node, then there aren't any routes for this parking.
// in cases like these we should flag the gate as being inoperative and return false
if (ts == te) {
SG_LOG(SG_GENERAL, SG_ALERT, "Gate " << gateId << "doesn't seem to have routes associated with it.");
parking->setAvailable(false);
return false;
}
tn = (*ts)->getEnd();
lastNodeVisited = tn->getIndex();
if (tn == NULL) {
SG_LOG(SG_GENERAL, SG_ALERT, "No valid taxinode found");
exit(1);
}
double distance = (*ts)->getLength();
//cerr << "Length of push forward route = " << distance << " and heading is " << heading << endl;
lat2 = tn->getLatitude();
lon2 = tn->getLongitude();
wpt->setRouteIndex((*ts)->getIndex());
pushBackWaypoint(wpt);
}
// cerr << "Done " << endl;
waypoints.back()->setName(string("PushBackPoint"));
// cerr << "Done assinging new name" << endl;
}
for (int i = 1; i < 10; i++) {
geo_direct_wgs_84 ( 0, lat, lon, heading,
((i / 10.0) * distance), &lat2, &lon2, &az2 );
char buffer[16];
snprintf(buffer, 16, "pushback-%02d", i);
SGGeod coord = coord.fromDeg(lon2, lat2);
//cerr << i << endl;
FGAIWaypoint *wpt = createOnGround(ac, string(buffer), coord, dep->getElevation(), vTaxiReduced);
wpt->setRouteIndex((*ts)->getIndex());
pushBackWaypoint(wpt);
}
// cerr << "Done " << endl;
waypoints.back()->setName(string("PushBackPoint"));
// cerr << "Done assinging new name" << endl;
}
}
return true;
}
/*******************************************************************
* createPushBackFallBack
* This is the backup function for airports that don't have a
* network yet.
* This is the backup function for airports that don't have a
* network yet.
******************************************************************/
void FGAIFlightPlan::createPushBackFallBack(FGAIAircraft *ac, bool firstFlight, FGAirport *dep,
double latitude,
double longitude,
double radius,
const string& fltType,
const string& aircraftType,
const string& airline)
void FGAIFlightPlan::createPushBackFallBack(FGAIAircraft *ac, bool firstFlight, FGAirport *dep,
double latitude,
double longitude,
double radius,
const string& fltType,
const string& aircraftType,
const string& airline)
{
double heading;
double lat;
double lon;
double lat2 = 0.0;
double lon2 = 0.0;
double az2 = 0.0;
double heading;
double lat;
double lon;
double lat2 = 0.0;
double lon2 = 0.0;
double az2 = 0.0;
double vTaxi = ac->getPerformance()->vTaxi();
double vTaxiBackward = vTaxi * (-2.0/3.0);
double vTaxiReduced = vTaxi * (2.0/3.0);
double vTaxi = ac->getPerformance()->vTaxi();
double vTaxiBackward = vTaxi * (-2.0/3.0);
double vTaxiReduced = vTaxi * (2.0/3.0);
dep->getDynamics()->getParking(-1, &lat, &lon, &heading);
dep->getDynamics()->getParking(-1, &lat, &lon, &heading);
heading += 180.0;
if (heading > 360)
heading -= 360;
heading += 180.0;
if (heading > 360)
heading -= 360;
SGGeod coord = coord.fromDeg(lon, lat);
FGAIWaypoint *wpt = createOnGround(ac, string("park"), coord, dep->getElevation(), vTaxiBackward);
SGGeod coord = coord.fromDeg(lon, lat);
FGAIWaypoint *wpt = createOnGround(ac, string("park"), coord, dep->getElevation(), vTaxiBackward);
pushBackWaypoint(wpt);
pushBackWaypoint(wpt);
geo_direct_wgs_84 ( 0, lat, lon, heading,
10,
&lat2, &lon2, &az2 );
coord = coord.fromDeg(lon2, lat2);
wpt = createOnGround(ac, string("park2"), coord, dep->getElevation(), vTaxiBackward);
geo_direct_wgs_84 ( 0, lat, lon, heading,
10,
&lat2, &lon2, &az2 );
coord = coord.fromDeg(lon2, lat2);
wpt = createOnGround(ac, string("park2"), coord, dep->getElevation(), vTaxiBackward);
pushBackWaypoint(wpt);
pushBackWaypoint(wpt);
geo_direct_wgs_84 ( 0, lat, lon, heading,
2.2*radius,
&lat2, &lon2, &az2 );
coord = coord.fromDeg(lon2, lat2);
wpt = createOnGround(ac, string("taxiStart"), coord, dep->getElevation(), vTaxiReduced);
pushBackWaypoint(wpt);
geo_direct_wgs_84 ( 0, lat, lon, heading,
2.2*radius,
&lat2, &lon2, &az2 );
coord = coord.fromDeg(lon2, lat2);
wpt = createOnGround(ac, string("taxiStart"), coord, dep->getElevation(), vTaxiReduced);
pushBackWaypoint(wpt);
}

View file

@ -1,25 +0,0 @@
noinst_LIBRARIES = libAIModel.a
libAIModel_a_SOURCES = submodel.cxx submodel.hxx \
AIManager.hxx AIManager.cxx \
AIBase.hxx AIBase.cxx \
AIAircraft.hxx AIAircraft.cxx \
AIMultiplayer.hxx AIMultiplayer.cxx \
AIShip.hxx AIShip.cxx \
AIBallistic.hxx AIBallistic.cxx \
AIStorm.hxx AIStorm.cxx \
AIThermal.hxx AIThermal.cxx \
AIFlightPlan.hxx AIFlightPlan.cxx \
AIFlightPlanCreate.cxx \
AIFlightPlanCreatePushBack.cxx \
AIFlightPlanCreateCruise.cxx \
AICarrier.hxx AICarrier.cxx \
AIStatic.hxx AIStatic.cxx \
AITanker.cxx AITanker.hxx \
AIWingman.cxx AIWingman.hxx\
AIGroundVehicle.cxx AIGroundVehicle.hxx \
AIEscort.cxx AIEscort.hxx \
performancedata.cxx performancedata.hxx \
performancedb.cxx performancedb.hxx
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src

View file

@ -49,7 +49,7 @@ PerformanceData::PerformanceData( const std::string& filename)
PerformanceData::~PerformanceData()
{}
double PerformanceData::actualSpeed(FGAIAircraft* ac, double tgt_speed, double dt) {
double PerformanceData::actualSpeed(FGAIAircraft* ac, double tgt_speed, double dt, bool maxBrakes) {
// if (tgt_speed > _vTaxi & ac->onGround()) // maximum taxi speed on ground
// tgt_speed = _vTaxi;
// bad idea for a take off roll :-)
@ -66,7 +66,13 @@ double PerformanceData::actualSpeed(FGAIAircraft* ac, double tgt_speed, double d
} else if (speed_diff < 0.0) { // decelerate
if (ac->onGround()) {
// deceleration performance is better due to wheel brakes.
speed -= BRAKE_SETTING * _deceleration * dt;
double brakePower = 0;
if (maxBrakes) {
brakePower = 3;
} else {
brakePower = BRAKE_SETTING;
}
speed -= brakePower * _deceleration * dt;
} else {
speed -= _deceleration * dt;
}

View file

@ -29,7 +29,7 @@ public:
PerformanceData(const std::string& filename);
~PerformanceData();
double actualSpeed(FGAIAircraft* ac, double tgt_speed, double dt);
double actualSpeed(FGAIAircraft* ac, double tgt_speed, double dt, bool needMaxBrake);
double actualBankAngle(FGAIAircraft* ac, double tgt_roll, double dt);
double actualPitch(FGAIAircraft* ac, double tgt_pitch, double dt);
double actualHeading(FGAIAircraft* ac, double tgt_heading, double dt);

View file

@ -1,9 +0,0 @@
noinst_LIBRARIES = libATC.a
libATC_a_SOURCES = \
atcdialog.cxx atcdialog.hxx \
atc_mgr.cxx atc_mgr.hxx \
CommStation.cxx CommStation.hxx \
trafficcontrol.cxx trafficcontrol.hxx
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src

View file

@ -100,7 +100,7 @@ void FGATCManager::init() {
FGAirport *apt = FGAirport::findByIdent(airport);
if (apt && onGround) {
if (apt && onGround && !runway.empty()) {
FGAirportDynamics* dcs = apt->getDynamics();
int park_index = dcs->getNrOfParkings() - 1;
//cerr << "found information: " << runway << " " << airport << ": parking = " << parking << endl;

View file

@ -18,6 +18,10 @@
//
// $Id$
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <Main/fg_commands.hxx>
#include <Main/globals.hxx>

View file

@ -205,7 +205,13 @@ void FGATCDialog::PopupDialog() {
button_group->removeChildren("button", false);
string label;
FGATC* atcptr = globals->get_ATC_mgr()->GetComm1ATCPointer(); // Hardwired to comm1 at the moment
FGATCMgr* pAtcMgr = globals->get_ATC_mgr();
if (!pAtcMgr)
{
SG_LOG(SG_ATC, SG_ALERT, "ERROR! No ATC manager! Oops...");
return;
}
FGATC* atcptr = pAtcMgr->GetComm1ATCPointer(); // Hardwired to comm1 at the moment
if (!atcptr) {
label = "Not currently tuned to any ATC service";
@ -260,7 +266,13 @@ void FGATCDialog::PopupDialog() {
}
void FGATCDialog::PopupCallback(int num) {
FGATC* atcptr = globals->get_ATC_mgr()->GetComm1ATCPointer(); // FIXME - Hardwired to comm1 at the moment
FGATCMgr* pAtcMgr = globals->get_ATC_mgr();
if (!pAtcMgr)
{
SG_LOG(SG_ATC, SG_ALERT, "ERROR! No ATC manager! Oops...");
return;
}
FGATC* atcptr = pAtcMgr->GetComm1ATCPointer(); // FIXME - Hardwired to comm1 at the moment
if (!atcptr)
return;

View file

@ -48,9 +48,11 @@ FGATCMgr::FGATCMgr() :
voice(false),
#endif
{
globals->set_ATC_mgr(this);
}
FGATCMgr::~FGATCMgr() {
globals->set_ATC_mgr(NULL);
delete v1;
}

View file

@ -1,12 +0,0 @@
noinst_LIBRARIES = libATCDCL.a
libATCDCL_a_SOURCES = \
ATC.hxx ATC.cxx \
atis.hxx atis.cxx atis_lexicon.hxx atis_remap.hxx \
ATCDialogOld.hxx ATCDialogOld.cxx \
ATCVoice.hxx ATCVoice.cxx \
ATCmgr.hxx ATCmgr.cxx \
ATCutils.hxx ATCutils.cxx \
ATCProjection.hxx ATCProjection.cxx
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src

View file

@ -76,7 +76,14 @@ FGATIS::FGATIS() :
_prev_display(0),
refname("atis")
{
_vPtr = globals->get_ATC_mgr()->GetVoicePointer(ATIS);
FGATCMgr* pAtcMgr = globals->get_ATC_mgr();
if (!pAtcMgr)
{
SG_LOG(SG_ATC, SG_ALERT, "ERROR! No ATC manager! Oops...");
_vPtr = NULL;
}
else
_vPtr = pAtcMgr->GetVoicePointer(ATIS);
_voiceOK = (_vPtr == NULL ? false : true);
if (!(_type != ATIS || _type == AWOS)) {
SG_LOG(SG_ATC, SG_ALERT, "ERROR - _type not ATIS or AWOS in atis.cxx");

View file

@ -1,8 +0,0 @@
noinst_LIBRARIES = libAircraft.a
libAircraft_a_SOURCES = \
controls.cxx controls.hxx \
replay.cxx replay.hxx \
flightrecorder.cxx flightrecorder.hxx
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src

View file

@ -20,6 +20,10 @@
//
///////////////////////////////////////////////////////////////////////////////
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <string.h>
#include <assert.h>

View file

@ -1,24 +0,0 @@
noinst_LIBRARIES = libAirports.a
noinst_PROGRAMS = calc_loc
libAirports_a_SOURCES = \
apt_loader.cxx apt_loader.hxx \
runways.cxx runways.hxx \
simple.cxx simple.hxx \
runwayprefs.cxx runwayprefs.hxx \
parking.cxx parking.hxx \
gnnode.cxx gnnode.hxx \
groundnetwork.cxx groundnetwork.hxx \
dynamics.cxx dynamics.hxx \
dynamicloader.cxx dynamicloader.hxx \
sidstar.cxx sidstar.hxx \
runwayprefloader.cxx runwayprefloader.hxx \
xmlloader.cxx xmlloader.hxx \
runwaybase.cxx runwaybase.hxx \
pavement.cxx pavement.hxx
calc_loc_SOURCES = calc_loc.cxx
calc_loc_LDADD = -lsgmath -lsgdebug -lsgmisc -lsgstructure -lz $(base_LIBS)
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src

View file

@ -102,6 +102,7 @@ bool FGAirportDynamics::getAvailableParking(double *lat, double *lon,
//cerr << "Could not find parking spot at " << _ap->getId() << endl;
*lat = _ap->getLatitude();
*lon = _ap->getLongitude();
* gateId = -1;
*heading = 0;
found = true;
} else {

View file

@ -26,6 +26,7 @@
#include <math.h>
#include <algorithm>
#include <fstream>
#include <osg/Geode>

View file

@ -13,6 +13,10 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <simgear/misc/sg_path.hxx>
#include <simgear/xml/easyxml.hxx>
#include <simgear/misc/strutils.hxx>

View file

@ -1,18 +0,0 @@
noinst_LIBRARIES = libAutopilot.a
libAutopilot_a_SOURCES = \
route_mgr.cxx route_mgr.hxx \
autopilotgroup.cxx autopilotgroup.hxx \
autopilot.cxx autopilot.hxx functor.hxx \
inputvalue.cxx inputvalue.hxx \
component.cxx component.hxx \
analogcomponent.cxx analogcomponent.hxx \
pidcontroller.cxx pidcontroller.hxx \
pisimplecontroller.cxx pisimplecontroller.hxx \
predictor.cxx predictor.hxx \
digitalfilter.cxx digitalfilter.hxx \
digitalcomponent.cxx digitalcomponent.hxx \
logic.cxx logic.hxx \
flipflop.cxx flipflop.hxx
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src

View file

@ -1,9 +0,0 @@
noinst_LIBRARIES = libCockpit.a
libCockpit_a_SOURCES = \
panel.cxx panel.hxx \
panel_io.cxx panel_io.hxx
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src
SUBDIRS = built_in

View file

@ -1,7 +0,0 @@
noinst_LIBRARIES = libBuilt_in.a
libBuilt_in_a_SOURCES = \
FGMagRibbon.cxx FGMagRibbon.hxx
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src

View file

@ -1,23 +0,0 @@
# libdir = ${exec_prefix}/lib
# lib_LTLIBRARIES = libEnvironment.la
# libEnvironment_la_SOURCES = environment.c environment.h
noinst_LIBRARIES = libEnvironment.a
libEnvironment_a_SOURCES = \
environment.cxx environment.hxx \
environment_mgr.cxx environment_mgr.hxx \
environment_ctrl.cxx environment_ctrl.hxx \
fgmetar.cxx fgmetar.hxx fgclouds.cxx fgclouds.hxx \
realwx_ctrl.cxx realwx_ctrl.hxx \
metarproperties.cxx metarproperties.hxx \
metarairportfilter.cxx metarairportfilter.hxx \
atmosphere.cxx atmosphere.hxx \
precipitation_mgr.cxx precipitation_mgr.hxx \
ridge_lift.cxx ridge_lift.hxx \
ephemeris.cxx ephemeris.hxx \
terrainsampler.cxx terrainsampler.hxx \
presets.cxx presets.hxx \
gravity.cxx gravity.hxx
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src

View file

@ -28,8 +28,10 @@
#include <simgear/debug/logstream.hxx>
#include <simgear/scene/sky/sky.hxx>
#include <simgear/scene/model/particles.hxx>
#include <simgear/structure/event_mgr.hxx>
#include <Main/main.hxx>
#include <Main/renderer.hxx>
#include <Main/fg_props.hxx>
#include <FDM/flight.hxx>
@ -44,9 +46,6 @@
#include "Airports/simple.hxx"
#include "gravity.hxx"
class SGSky;
extern SGSky *thesky;
class FG3DCloudsListener : public SGPropertyChangeListener {
public:
FG3DCloudsListener( FGClouds * fgClouds );
@ -90,8 +89,8 @@ FGEnvironmentMgr::FGEnvironmentMgr () :
_altitude_n(fgGetNode("/position/altitude-ft", true)),
_longitude_n(fgGetNode( "/position/longitude-deg", true )),
_latitude_n( fgGetNode( "/position/latitude-deg", true )),
_positionTimeToLive(0.0),
_3dCloudsEnableListener(new FG3DCloudsListener(fgClouds) )
_3dCloudsEnableListener(new FG3DCloudsListener(fgClouds) ),
_sky(globals->get_renderer()->getSky())
{
set_subsystem("controller", Environment::LayerInterpolateController::createInstance( fgGetNode("/environment/config", true ) ));
set_subsystem("realwx", Environment::RealWxController::createInstance( fgGetNode("/environment/realwx", true ) ), 1.0 );
@ -145,6 +144,15 @@ FGEnvironmentMgr::init ()
_altitude_n->setDoubleValue(fgGetDouble("/sim/presets/altitude-ft"));
_longitude_n->setDoubleValue(fgGetDouble("/sim/presets/longitude-deg"));
_latitude_n->setDoubleValue(fgGetDouble("/sim/presets/latitude-deg"));
globals->get_event_mgr()->addTask("updateClosestAirport", this,
&FGEnvironmentMgr::updateClosestAirport, 30 );
}
void
FGEnvironmentMgr::shutdown()
{
globals->get_event_mgr()->removeTask("updateClosestAirport");
}
void
@ -162,7 +170,7 @@ FGEnvironmentMgr::bind ()
_tiedProperties.setRoot( fgGetNode( "/environment", true ) );
_tiedProperties.Tie( "effective-visibility-m", thesky,
_tiedProperties.Tie( "effective-visibility-m", _sky,
&SGSky::get_visibility );
_tiedProperties.Tie("rebuild-layers", fgClouds,
@ -211,15 +219,15 @@ FGEnvironmentMgr::bind ()
_tiedProperties.setRoot( fgGetNode("/sim/rendering", true ) );
_tiedProperties.Tie( "clouds3d-density", thesky,
_tiedProperties.Tie( "clouds3d-density", _sky,
&SGSky::get_3dCloudDensity,
&SGSky::set_3dCloudDensity);
_tiedProperties.Tie("clouds3d-vis-range", thesky,
_tiedProperties.Tie("clouds3d-vis-range", _sky,
&SGSky::get_3dCloudVisRange,
&SGSky::set_3dCloudVisRange);
_tiedProperties.Tie("clouds3d-wrap", thesky,
_tiedProperties.Tie("clouds3d-wrap", _sky,
&SGSky::get_3dCloudWrap,
&SGSky::set_3dCloudWrap);
@ -258,33 +266,30 @@ FGEnvironmentMgr::update (double dt)
_latitude_n->getDoubleValue(),
_altitude_n->getDoubleValue()
)));
}
_positionTimeToLive -= dt;
if( _positionTimeToLive <= 0.0 )
void
FGEnvironmentMgr::updateClosestAirport()
{
SG_LOG(SG_ENVIRONMENT, SG_DEBUG, "FGEnvironmentMgr::update: updating closest airport");
SGGeod pos = globals->get_aircraft_position();
FGAirport * nearestAirport = FGAirport::findClosest(pos, 100.0);
if( nearestAirport == NULL )
{
// update closest airport information
_positionTimeToLive = 30.0;
SG_LOG(SG_ENVIRONMENT, SG_INFO, "FGEnvironmentMgr::update: updating closest airport");
SGGeod pos = SGGeod::fromDeg(_longitude_n->getDoubleValue(),
_latitude_n->getDoubleValue());
FGAirport * nearestAirport = FGAirport::findClosest(pos, 100.0);
if( nearestAirport == NULL )
{
SG_LOG(SG_ENVIRONMENT,SG_WARN,"FGEnvironmentMgr::update: No airport within 100NM range");
}
else
{
const string currentId = fgGetString("/sim/airport/closest-airport-id", "");
if (currentId != nearestAirport->ident())
{
fgSetString("/sim/airport/closest-airport-id",
nearestAirport->ident().c_str());
}
}
SG_LOG(SG_ENVIRONMENT,SG_WARN,"FGEnvironmentMgr::update: No airport within 100NM range");
}
else
{
const string currentId = fgGetString("/sim/airport/closest-airport-id", "");
if (currentId != nearestAirport->ident())
{
SG_LOG(SG_ENVIRONMENT, SG_INFO, "FGEnvironmentMgr::updateClosestAirport: selected:" << nearestAirport->ident());
fgSetString("/sim/airport/closest-airport-id",
nearestAirport->ident().c_str());
}
}
}
FGEnvironment
@ -319,19 +324,19 @@ FGEnvironmentMgr::getEnvironment(const SGGeod& aPos) const
double
FGEnvironmentMgr::get_cloud_layer_span_m (int index) const
{
return thesky->get_cloud_layer(index)->getSpan_m();
return _sky->get_cloud_layer(index)->getSpan_m();
}
void
FGEnvironmentMgr::set_cloud_layer_span_m (int index, double span_m)
{
thesky->get_cloud_layer(index)->setSpan_m(span_m);
_sky->get_cloud_layer(index)->setSpan_m(span_m);
}
double
FGEnvironmentMgr::get_cloud_layer_elevation_ft (int index) const
{
return thesky->get_cloud_layer(index)->getElevation_m() * SG_METER_TO_FEET;
return _sky->get_cloud_layer(index)->getElevation_m() * SG_METER_TO_FEET;
}
void
@ -340,88 +345,88 @@ FGEnvironmentMgr::set_cloud_layer_elevation_ft (int index, double elevation_ft)
FGEnvironment env = *_environment;
env.set_elevation_ft(elevation_ft);
thesky->get_cloud_layer(index)
_sky->get_cloud_layer(index)
->setElevation_m(elevation_ft * SG_FEET_TO_METER);
thesky->get_cloud_layer(index)
_sky->get_cloud_layer(index)
->setSpeed(env.get_wind_speed_kt() * 0.5151); // 1 kt = 0.5151 m/s
thesky->get_cloud_layer(index)
_sky->get_cloud_layer(index)
->setDirection(env.get_wind_from_heading_deg());
}
double
FGEnvironmentMgr::get_cloud_layer_thickness_ft (int index) const
{
return thesky->get_cloud_layer(index)->getThickness_m() * SG_METER_TO_FEET;
return _sky->get_cloud_layer(index)->getThickness_m() * SG_METER_TO_FEET;
}
void
FGEnvironmentMgr::set_cloud_layer_thickness_ft (int index, double thickness_ft)
{
thesky->get_cloud_layer(index)
_sky->get_cloud_layer(index)
->setThickness_m(thickness_ft * SG_FEET_TO_METER);
}
double
FGEnvironmentMgr::get_cloud_layer_transition_ft (int index) const
{
return thesky->get_cloud_layer(index)->getTransition_m() * SG_METER_TO_FEET;
return _sky->get_cloud_layer(index)->getTransition_m() * SG_METER_TO_FEET;
}
void
FGEnvironmentMgr::set_cloud_layer_transition_ft (int index,
double transition_ft)
{
thesky->get_cloud_layer(index)
_sky->get_cloud_layer(index)
->setTransition_m(transition_ft * SG_FEET_TO_METER);
}
const char *
FGEnvironmentMgr::get_cloud_layer_coverage (int index) const
{
return thesky->get_cloud_layer(index)->getCoverageString().c_str();
return _sky->get_cloud_layer(index)->getCoverageString().c_str();
}
void
FGEnvironmentMgr::set_cloud_layer_coverage (int index,
const char * coverage_name)
{
if( thesky->get_cloud_layer(index)->getCoverageString() == coverage_name )
if( _sky->get_cloud_layer(index)->getCoverageString() == coverage_name )
return;
thesky->get_cloud_layer(index)->setCoverageString(coverage_name);
_sky->get_cloud_layer(index)->setCoverageString(coverage_name);
_cloudLayersDirty = true;
}
int
FGEnvironmentMgr::get_cloud_layer_coverage_type (int index) const
{
return thesky->get_cloud_layer(index)->getCoverage();
return _sky->get_cloud_layer(index)->getCoverage();
}
double
FGEnvironmentMgr::get_cloud_layer_visibility_m (int index) const
{
return thesky->get_cloud_layer(index)->getVisibility_m();
return _sky->get_cloud_layer(index)->getVisibility_m();
}
void
FGEnvironmentMgr::set_cloud_layer_visibility_m (int index, double visibility_m)
{
thesky->get_cloud_layer(index)->setVisibility_m(visibility_m);
_sky->get_cloud_layer(index)->setVisibility_m(visibility_m);
}
double
FGEnvironmentMgr::get_cloud_layer_maxalpha (int index ) const
{
return thesky->get_cloud_layer(index)->getMaxAlpha();
return _sky->get_cloud_layer(index)->getMaxAlpha();
}
void
FGEnvironmentMgr::set_cloud_layer_maxalpha (int index, double maxalpha)
{
thesky->get_cloud_layer(index)->setMaxAlpha(maxalpha);
_sky->get_cloud_layer(index)->setMaxAlpha(maxalpha);
}
void
@ -432,10 +437,10 @@ FGEnvironmentMgr::set_cloud_layer_coverage_type (int index, int type )
return;
}
if( static_cast<SGCloudLayer::Coverage>(type) == thesky->get_cloud_layer(index)->getCoverage() )
if( static_cast<SGCloudLayer::Coverage>(type) == _sky->get_cloud_layer(index)->getCoverage() )
return;
thesky->get_cloud_layer(index)->setCoverage(static_cast<SGCloudLayer::Coverage>(type));
_sky->get_cloud_layer(index)->setCoverage(static_cast<SGCloudLayer::Coverage>(type));
_cloudLayersDirty = true;
}

View file

@ -38,6 +38,7 @@ class FGMetarCtrl;
class FGMetarFetcher;
class FGClouds;
class FGPrecipitationMgr;
class SGSky;
/**
* Manage environment information.
@ -56,6 +57,7 @@ public:
virtual void init ();
virtual void reinit ();
virtual void shutdown ();
virtual void bind ();
virtual void unbind ();
virtual void update (double dt);
@ -74,7 +76,8 @@ public:
virtual FGEnvironment getEnvironment(const SGGeod& aPos) const;
private:
void updateClosestAirport();
double get_cloud_layer_span_m (int index) const;
void set_cloud_layer_span_m (int index, double span_m);
double get_cloud_layer_elevation_ft (int index) const;
@ -98,9 +101,10 @@ private:
SGPropertyNode_ptr _altitude_n;
SGPropertyNode_ptr _longitude_n;
SGPropertyNode_ptr _latitude_n;
double _positionTimeToLive;
simgear::TiedPropertyList _tiedProperties;
SGPropertyChangeListener * _3dCloudsEnableListener;
SGSky* _sky;
};
#endif // _ENVIRONMENT_MGR_HXX

View file

@ -32,6 +32,10 @@ Ephemeris::Ephemeris() :
_impl(NULL),
_latProp(NULL)
{
SGPath ephem_data_path(globals->get_fg_root());
ephem_data_path.append("Astro");
_impl = new SGEphemeris(ephem_data_path.c_str());
globals->set_ephem(_impl);
}
Ephemeris::~Ephemeris()
@ -41,15 +45,6 @@ Ephemeris::~Ephemeris()
void Ephemeris::init()
{
if (_impl) {
return;
}
SGPath ephem_data_path(globals->get_fg_root());
ephem_data_path.append("Astro");
_impl = new SGEphemeris(ephem_data_path.c_str());
globals->set_ephem(_impl);
_latProp = fgGetNode("/position/latitude-deg", true);
update(0.0);
}

View file

@ -38,13 +38,12 @@
#include <simgear/props/props_io.hxx>
#include <Main/globals.hxx>
#include <Main/renderer.hxx>
#include <Airports/simple.hxx>
#include <Main/util.hxx>
#include "fgclouds.hxx"
extern SGSky *thesky;
static bool do_delete_3Dcloud (const SGPropertyNode *arg);
static bool do_move_3Dcloud (const SGPropertyNode *arg);
static bool do_add_3Dcloud (const SGPropertyNode *arg);
@ -182,6 +181,8 @@ void FGClouds::buildLayer(int iLayer, const string& name, double coverage) {
int CloudVarietyCount = 0;
double totalCount = 0.0;
SGSky* thesky = globals->get_renderer()->getSky();
SGPropertyNode *cloud_def_root = fgGetNode("/environment/cloudlayers/clouds", false);
SGPropertyNode *box_def_root = fgGetNode("/environment/cloudlayers/boxes", false);
SGPropertyNode *layer_def_root = fgGetNode("/environment/cloudlayers/layers", false);
@ -274,6 +275,7 @@ void FGClouds::buildCloudLayers(void) {
double cumulus_base = 122.0 * (temperature_degc - dewpoint_degc);
double stratus_base = 100.0 * (100.0 - rel_humidity) * SG_FEET_TO_METER;
SGSky* thesky = globals->get_renderer()->getSky();
for(int iLayer = 0 ; iLayer < thesky->get_cloud_layer_count(); iLayer++) {
SGPropertyNode *cloud_root = fgGetNode("/environment/clouds/layer", iLayer, true);
@ -366,7 +368,7 @@ bool FGClouds::get_3dClouds() const
float x = arg->getFloatValue("x-offset-m", 0.0f);
float y = arg->getFloatValue("y-offset-m", 0.0f);
SGSky* thesky = globals->get_renderer()->getSky();
SGCloudField *layer = thesky->get_cloud_layer(l)->get_layer3D();
SGNewCloud cld = SGNewCloud(texture_root, arg);
bool success = layer->addCloud(lon, lat, alt, x, y, index, cld.genCloud());
@ -392,6 +394,7 @@ bool FGClouds::get_3dClouds() const
int l = arg->getIntValue("layer", 0);
int i = arg->getIntValue("index", 0);
SGSky* thesky = globals->get_renderer()->getSky();
SGCloudField *layer = thesky->get_cloud_layer(l)->get_layer3D();
return layer->deleteCloud(i);
}
@ -410,7 +413,8 @@ bool FGClouds::get_3dClouds() const
{
int l = arg->getIntValue("layer", 0);
int i = arg->getIntValue("index", 0);
SGSky* thesky = globals->get_renderer()->getSky();
float lon = arg->getFloatValue("lon-deg", 0.0f);
float lat = arg->getFloatValue("lat-deg", 0.0f);
float alt = arg->getFloatValue("alt-ft", 0.0f);

View file

@ -39,13 +39,11 @@
#include <Main/fg_props.hxx>
#include <Main/globals.hxx>
#include <Main/renderer.hxx>
#include <Scenery/scenery.hxx>
#include "precipitation_mgr.hxx"
extern SGSky *thesky;
/**
* @brief FGPrecipitation Manager constructor
*
@ -141,6 +139,8 @@ float FGPrecipitationMgr::getPrecipitationAtAltitudeMax(void)
max = SGCloudLayer::SG_MAX_CLOUD_COVERAGES;
result = 0;
SGSky* thesky = globals->get_renderer()->getSky();
// To avoid messing up
if (thesky == NULL)
return result;

View file

@ -39,6 +39,7 @@
#include <simgear/io/HTTPClient.hxx>
#include <simgear/io/HTTPRequest.hxx>
#include <simgear/timing/sg_time.hxx>
#include <simgear/structure/event_mgr.hxx>
#include <algorithm>
@ -143,13 +144,14 @@ public:
virtual void init ();
virtual void reinit ();
virtual void shutdown ();
protected:
void bind();
void unbind();
void update( double dt );
virtual void update (bool first, double delta_time_sec);
void checkNearbyMetar();
long getMetarMaxAgeMin() const { return _max_age_n == NULL ? 0 : _max_age_n->getLongValue(); }
@ -162,8 +164,7 @@ protected:
simgear::TiedPropertyList _tiedProperties;
typedef std::vector<LiveMetarProperties_ptr> MetarPropertiesList;
MetarPropertiesList _metarProperties;
private:
double _positionTimeToLive;
};
/* -------------------------------------------------------------------------------- */
@ -178,8 +179,7 @@ BasicRealWxController::BasicRealWxController( SGPropertyNode_ptr rootNode, Metar
_ground_elevation_n( fgGetNode( "/position/ground-elev-m", true )),
_max_age_n( fgGetNode( "/environment/params/metar-max-age-min", false ) ),
_enabled(true),
__enabled(false),
_positionTimeToLive(0.0)
__enabled(false)
{
// at least instantiate MetarProperties for /environment/metar
_metarProperties.push_back( new LiveMetarProperties(
@ -200,12 +200,20 @@ void BasicRealWxController::init()
{
__enabled = false;
update(0); // fetch data ASAP
globals->get_event_mgr()->addTask("checkNearbyMetar", this,
&BasicRealWxController::checkNearbyMetar, 60 );
}
void BasicRealWxController::reinit()
{
__enabled = false;
}
void BasicRealWxController::shutdown()
{
globals->get_event_mgr()->removeTask("checkNearbyMetar");
}
void BasicRealWxController::bind()
{
@ -230,50 +238,43 @@ void BasicRealWxController::update( double dt )
p->update(dt);
}
update( firstIteration, dt );
__enabled = true;
} else {
__enabled = false;
}
}
void BasicRealWxController::update( bool first, double dt )
void BasicRealWxController::checkNearbyMetar()
{
_positionTimeToLive -= dt;
try {
const SGGeod & pos = globals->get_aircraft_position();
if( _positionTimeToLive <= 0.0 ) {
// check nearest airport
SG_LOG(SG_ENVIRONMENT, SG_DEBUG, "NoaaMetarRealWxController::update(): (re) checking nearby airport with METAR" );
FGAirport * nearestAirport = FGAirport::findClosest(pos, 10000.0, MetarAirportFilter::instance() );
if( nearestAirport == NULL ) {
SG_LOG(SG_ENVIRONMENT,SG_WARN,"RealWxController::update can't find airport with METAR within 10000NM" );
return;
}
try {
const SGGeod & pos = globals->get_aircraft_position();
SG_LOG(SG_ENVIRONMENT, SG_DEBUG,
"NoaaMetarRealWxController::update(): nearest airport with METAR is: " << nearestAirport->ident() );
// check nearest airport
SG_LOG(SG_ENVIRONMENT, SG_INFO, "NoaaMetarRealWxController::update(): (re) checking nearby airport with METAR" );
_positionTimeToLive = 60.0;
FGAirport * nearestAirport = FGAirport::findClosest(pos, 10000.0, MetarAirportFilter::instance() );
if( nearestAirport == NULL ) {
SG_LOG(SG_ENVIRONMENT,SG_WARN,"RealWxController::update can't find airport with METAR within 10000NM" );
return;
}
SG_LOG(SG_ENVIRONMENT, SG_INFO,
"NoaaMetarRealWxController::update(): nearest airport with METAR is: " << nearestAirport->ident() );
// if it has changed, invalidate the associated METAR
if( _metarProperties[0]->getStationId() != nearestAirport->ident() ) {
SG_LOG(SG_ENVIRONMENT, SG_INFO,
"NoaaMetarRealWxController::update(): nearest airport with METAR has changed. Old: '" <<
_metarProperties[0]->getStationId() <<
"', new: '" << nearestAirport->ident() << "'" );
_metarProperties[0]->setStationId( nearestAirport->ident() );
_metarProperties[0]->setTimeToLive( 0.0 );
}
}
catch( sg_exception & ) {
return;
}
// if it has changed, invalidate the associated METAR
if( _metarProperties[0]->getStationId() != nearestAirport->ident() ) {
SG_LOG(SG_ENVIRONMENT, SG_INFO,
"NoaaMetarRealWxController::update(): nearest airport with METAR has changed. Old: '" <<
_metarProperties[0]->getStationId() <<
"', new: '" << nearestAirport->ident() << "'" );
_metarProperties[0]->setStationId( nearestAirport->ident() );
_metarProperties[0]->setTimeToLive( 0.0 );
}
}
catch( sg_exception & ) {
return;
}
}
/* -------------------------------------------------------------------------------- */

View file

@ -1,11 +0,0 @@
noinst_LIBRARIES = libExternalNet.a
# noinst_PROGRAMS = demo_fdm
libExternalNet_a_SOURCES = \
ExternalNet.cxx ExternalNet.hxx
# demo_fdm_SOURCES = demo_fdm.cxx demo_httpd.cxx demo_httpd.hxx
# demo_LDADD =
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src

View file

@ -1,11 +0,0 @@
noinst_LIBRARIES = libExternalPipe.a
# noinst_PROGRAMS = demo_fdm
libExternalPipe_a_SOURCES = \
ExternalPipe.cxx ExternalPipe.hxx
# demo_fdm_SOURCES = demo_fdm.cxx demo_httpd.cxx demo_httpd.hxx
# demo_LDADD =
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src

View file

@ -70,7 +70,7 @@ using namespace std;
namespace JSBSim {
static const char *IdSrc = "$Id: FGFDMExec.cpp,v 1.115 2011/09/25 11:56:00 bcoconni Exp $";
static const char *IdSrc = "$Id: FGFDMExec.cpp,v 1.118 2011/10/22 15:11:23 bcoconni Exp $";
static const char *IdHdr = ID_FDMEXEC;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -85,7 +85,7 @@ FGFDMExec::FGFDMExec(FGPropertyManager* root, unsigned int* fdmctr) : Root(root)
Frame = 0;
Error = 0;
GroundCallback = 0;
GroundCallback = new FGDefaultGroundCallback();
IC = 0;
Trim = 0;
Script = 0;
@ -186,6 +186,9 @@ FGFDMExec::~FGFDMExec()
if (FDMctr > 0) (*FDMctr)--;
if(GroundCallback)
delete GroundCallback;
Debug(1);
}
@ -210,7 +213,7 @@ bool FGFDMExec::Allocate(void)
Models[ePropulsion] = new FGPropulsion(this);
Models[eAerodynamics] = new FGAerodynamics (this);
GroundCallback = new FGGroundCallback(((FGInertial*)Models[eInertial])->GetRefRadius());
GroundCallback->SetSeaLevelRadius(((FGInertial*)Models[eInertial])->GetRefRadius());
Models[eGroundReactions] = new FGGroundReactions(this);
Models[eExternalReactions] = new FGExternalReactions(this);
@ -266,8 +269,6 @@ bool FGFDMExec::DeAllocate(void)
delete IC;
delete Trim;
delete GroundCallback;
Error = 0;
modelLoaded = false;
@ -303,11 +304,11 @@ bool FGFDMExec::Run(void)
firstPass = false;
}
IncrTime();
// returns true if success, false if complete
if (Script != 0 && !IntegrationSuspended()) success = Script->RunScript();
IncrTime();
for (unsigned int i = 0; i < Models.size(); i++) {
LoadInputs(i);
Models[i]->Run(holding);
@ -563,9 +564,7 @@ void FGFDMExec::Initialize(FGInitialCondition *FGIC)
Propagate->InitializeDerivatives();
LoadInputs(eAtmosphere);
Atmosphere->Run(false);
Winds->SetWindNED( FGIC->GetWindNFpsIC(),
FGIC->GetWindEFpsIC(),
FGIC->GetWindDFpsIC() );
Winds->SetWindNED(FGIC->GetWindNEDFpsIC());
Auxiliary->Run(false);
}

View file

@ -56,7 +56,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_FDMEXEC "$Id: FGFDMExec.h,v 1.71 2011/09/07 02:37:04 jberndt Exp $"
#define ID_FDMEXEC "$Id: FGFDMExec.h,v 1.72 2011/10/14 22:46:49 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@ -181,7 +181,7 @@ CLASS DOCUMENTATION
property actually maps toa function call of DoTrim().
@author Jon S. Berndt
@version $Revision: 1.71 $
@version $Revision: 1.72 $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -269,7 +269,8 @@ public:
bool RunIC(void);
/** Sets the ground callback pointer.
@param gc A pointer to a ground callback object. */
@param gc A pointer to a ground callback object.
*/
void SetGroundCallback(FGGroundCallback* gc);
/** Loads an aircraft model.

View file

@ -44,7 +44,7 @@ INCLUDES
namespace JSBSim {
static const char *IdSrc = "$Id: FGJSBBase.cpp,v 1.31 2011/07/27 03:55:48 jberndt Exp $";
static const char *IdSrc = "$Id: FGJSBBase.cpp,v 1.32 2011/10/22 14:38:30 bcoconni Exp $";
static const char *IdHdr = ID_JSBBASE;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -283,5 +283,67 @@ double FGJSBBase::GaussianRandomNumber(void)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
double FGJSBBase::VcalibratedFromMach(double mach, double p, double psl, double rhosl)
{
double pt,A;
if (mach < 0) mach=0;
if (mach < 1) //calculate total pressure assuming isentropic flow
pt=p*pow((1 + 0.2*mach*mach),3.5);
else {
// shock in front of pitot tube, we'll assume its normal and use
// the Rayleigh Pitot Tube Formula, i.e. the ratio of total
// pressure behind the shock to the static pressure in front of
// the normal shock assumption should not be a bad one -- most supersonic
// aircraft place the pitot probe out front so that it is the forward
// most point on the aircraft. The real shock would, of course, take
// on something like the shape of a rounded-off cone but, here again,
// the assumption should be good since the opening of the pitot probe
// is very small and, therefore, the effects of the shock curvature
// should be small as well. AFAIK, this approach is fairly well accepted
// within the aerospace community
// The denominator below is zero for Mach ~ 0.38, for which
// we'll never be here, so we're safe
pt = p*166.92158*pow(mach,7.0)/pow(7*mach*mach-1,2.5);
}
A = pow(((pt-p)/psl+1),0.28571);
return sqrt(7*psl/rhosl*(A-1));
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
double FGJSBBase::MachFromVcalibrated(double vcas, double p, double psl, double rhosl)
{
double pt = p + psl*(pow(1+vcas*vcas*rhosl/(7.0*psl),3.5)-1);
if (pt/p < 1.89293)
return sqrt(5.0*(pow(pt/p, 0.2857143) -1)); // Mach < 1
else {
// Mach >= 1
double mach = sqrt(0.77666*pt/p); // Initial guess is based on a quadratic approximation of the Rayleigh formula
double delta = 1.;
double target = pt/(166.92158*p);
int iter = 0;
// Find the root with Newton-Raphson. Since the differential is never zero,
// the function is monotonic and has only one root with a multiplicity of one.
// Convergence is certain.
while (delta > 1E-5 && iter < 10) {
double m2 = mach*mach; // Mach^2
double m6 = m2*m2*m2; // Mach^6
delta = mach*m6/pow(7.0*m2-1.0,2.5) - target;
double diff = 7.0*m6*(2.0*m2-1)/pow(7.0*m2-1.0,3.5); // Never zero when Mach >= 1
mach -= delta/diff;
iter++;
}
return mach;
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
} // namespace JSBSim

View file

@ -56,7 +56,7 @@ using std::max;
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_JSBBASE "$Id: FGJSBBase.h,v 1.33 2011/06/27 03:14:25 jberndt Exp $"
#define ID_JSBBASE "$Id: FGJSBBase.h,v 1.34 2011/10/22 14:38:30 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@ -72,7 +72,7 @@ CLASS DOCUMENTATION
* This class provides universal constants, utility functions, messaging
* functions, and enumerated constants to JSBSim.
@author Jon S. Berndt
@version $Id: FGJSBBase.h,v 1.33 2011/06/27 03:14:25 jberndt Exp $
@version $Id: FGJSBBase.h,v 1.34 2011/10/22 14:38:30 bcoconni Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -256,6 +256,29 @@ public:
return kelvin - 273.15;
}
/** Calculate the calibrated airspeed from the Mach number. It uses the
* Rayleigh formula for supersonic speeds (See "Introduction to Aerodynamics
* of a Compressible Fluid - H.W. Liepmann, A.E. Puckett - Wiley & sons
* (1947)" §5.4 pp 75-80)
* @param mach The Mach number
* @param p Pressure in psf
* @param psl Pressure at sea level in psf
* @param rhosl Density at sea level in slugs/ft^3
* @return The calibrated airspeed (CAS) in ft/s
* */
static double VcalibratedFromMach(double mach, double p, double psl, double rhosl);
/** Calculate the Mach number from the calibrated airspeed. For subsonic
* speeds, the reversed formula has a closed form. For supersonic speeds, the
* Rayleigh formula is reversed by the Newton-Raphson algorithm.
* @param vcas The calibrated airspeed (CAS) in ft/s
* @param p Pressure in psf
* @param psl Pressure at sea level in psf
* @param rhosl Density at sea level in slugs/ft^3
* @return The Mach number
* */
static double MachFromVcalibrated(double vcas, double p, double psl, double rhosl);
/** Finite precision comparison.
@param a first value to compare
@param b second value to compare

View file

@ -112,6 +112,26 @@ public:
cont = FGColumnVector3( contact[0], contact[1], contact[2] );
return agl;
}
virtual double GetTerrainGeoCentRadius(double t, const FGLocation& l) const {
double loc_cart[3] = { l(eX), l(eY), l(eZ) };
double contact[3], normal[3], vel[3], angularVel[3], agl = 0;
mInterface->get_agl_ft(t, loc_cart, SG_METER_TO_FEET*2, contact, normal,
vel, angularVel, &agl);
return sqrt(contact[0]*contact[0]+contact[1]*contact[1]+contact[2]*contact[2]);
}
virtual double GetSeaLevelRadius(const FGLocation& l) const {
double seaLevelRadius, latGeoc;
sgGeodToGeoc(l.GetGeodLatitudeRad(), l.GetGeodAltitude(),
&seaLevelRadius, &latGeoc);
return seaLevelRadius * SG_METER_TO_FEET;
}
virtual void SetTerrainGeoCentRadius(double radius) {}
virtual void SetSeaLevelRadius(double radius) {}
private:
FGJSBsim* mInterface;
};
@ -371,9 +391,6 @@ void FGJSBsim::init()
-wind_from_east->getDoubleValue(),
-wind_from_down->getDoubleValue() );
//Atmosphere->SetExTemperature(get_Static_temperature());
//Atmosphere->SetExPressure(get_Static_pressure());
//Atmosphere->SetExDensity(get_Density());
SG_LOG(SG_FLIGHT,SG_INFO,"T,p,rho: " << Atmosphere->GetTemperature()
<< ", " << Atmosphere->GetPressure()
<< ", " << Atmosphere->GetDensity() );
@ -394,7 +411,6 @@ void FGJSBsim::init()
needTrim = startup_trim->getBoolValue();
common_init();
fgic->SetSeaLevelRadiusFtIC( get_Sea_level_radius() );
copy_to_JSBsim();
fdmex->RunIC(); //loop JSBSim once w/o integrating
@ -661,9 +677,6 @@ bool FGJSBsim::copy_to_JSBsim()
} // end FGEngine code block
}
Propagate->SetSeaLevelRadius( get_Sea_level_radius() );
Atmosphere->SetTemperature(temperature->getDoubleValue(), get_Altitude(), FGAtmosphere::eCelsius);
Atmosphere->SetPressureSL(pressureSL->getDoubleValue(), FGAtmosphere::eInchesHg);
@ -1024,11 +1037,10 @@ void FGJSBsim::set_Latitude(double lat)
fgic->SetSeaLevelRadiusFtIC( sea_level_radius_ft );
fgic->SetLatitudeRadIC( lat_geoc );
}
else {
Propagate->SetSeaLevelRadius( sea_level_radius_ft );
else
Propagate->SetLatitude(lat_geoc);
FGInterface::set_Latitude(lat);
}
FGInterface::set_Latitude(lat);
}
@ -1038,10 +1050,10 @@ void FGJSBsim::set_Longitude(double lon)
if (needTrim)
fgic->SetLongitudeRadIC(lon);
else {
else
Propagate->SetLongitude(lon);
FGInterface::set_Longitude(lon);
}
FGInterface::set_Longitude(lon);
}
// Sets the altitude above sea level.
@ -1051,10 +1063,10 @@ void FGJSBsim::set_Altitude(double alt)
if (needTrim)
fgic->SetAltitudeASLFtIC(alt);
else {
else
Propagate->SetAltitudeASL(alt);
FGInterface::set_Altitude(alt);
}
FGInterface::set_Altitude(alt);
}
void FGJSBsim::set_V_calibrated_kts(double vc)
@ -1064,7 +1076,10 @@ void FGJSBsim::set_V_calibrated_kts(double vc)
if (needTrim)
fgic->SetVcalibratedKtsIC(vc);
else {
double mach = getMachFromVcas(vc);
double p=pressure->getDoubleValue();
double psl=fdmex->GetAtmosphere()->GetPressureSL();
double rhosl=fdmex->GetAtmosphere()->GetDensitySL();
double mach = FGJSBBase::MachFromVcalibrated(vc, p, psl, rhosl);
double temp = 1.8*(temperature->getDoubleValue()+273.15);
double soundSpeed = sqrt(1.4*1716.0*temp);
FGColumnVector3 vUVW = Propagate->GetUVW();
@ -1073,9 +1088,9 @@ void FGJSBsim::set_V_calibrated_kts(double vc)
Propagate->SetUVW(1, vUVW(1));
Propagate->SetUVW(2, vUVW(2));
Propagate->SetUVW(3, vUVW(3));
FGInterface::set_V_calibrated_kts(vc);
}
FGInterface::set_V_calibrated_kts(vc);
}
void FGJSBsim::set_Mach_number(double mach)
@ -1093,9 +1108,9 @@ void FGJSBsim::set_Mach_number(double mach)
Propagate->SetUVW(1, vUVW(1));
Propagate->SetUVW(2, vUVW(2));
Propagate->SetUVW(3, vUVW(3));
FGInterface::set_Mach_number(mach);
}
FGInterface::set_Mach_number(mach);
}
void FGJSBsim::set_Velocities_Local( double north, double east, double down )
@ -1114,9 +1129,9 @@ void FGJSBsim::set_Velocities_Local( double north, double east, double down )
Propagate->SetUVW(1, vUVW(1));
Propagate->SetUVW(2, vUVW(2));
Propagate->SetUVW(3, vUVW(3));
FGInterface::set_Velocities_Local(north, east, down);
}
FGInterface::set_Velocities_Local(north, east, down);
}
void FGJSBsim::set_Velocities_Wind_Body( double u, double v, double w)
@ -1133,9 +1148,9 @@ void FGJSBsim::set_Velocities_Wind_Body( double u, double v, double w)
Propagate->SetUVW(1, u);
Propagate->SetUVW(2, v);
Propagate->SetUVW(3, w);
FGInterface::set_Velocities_Wind_Body(u, v, w);
}
FGInterface::set_Velocities_Wind_Body(u, v, w);
}
//Euler angles
@ -1155,9 +1170,9 @@ void FGJSBsim::set_Euler_Angles( double phi, double theta, double psi )
FGMatrix33 Ti2b = Tl2b*Propagate->GetTi2l();
FGQuaternion Qi = Ti2b.GetQuaternion();
Propagate->SetInertialOrientation(Qi);
FGInterface::set_Euler_Angles(phi, theta, psi);
}
FGInterface::set_Euler_Angles(phi, theta, psi);
}
//Flight Path
@ -1178,9 +1193,9 @@ void FGJSBsim::set_Climb_Rate( double roc)
Propagate->SetUVW(1, vUVW(1));
Propagate->SetUVW(2, vUVW(2));
Propagate->SetUVW(3, vUVW(3));
FGInterface::set_Climb_Rate(roc);
}
FGInterface::set_Climb_Rate(roc);
}
}
@ -1199,45 +1214,9 @@ void FGJSBsim::set_Gamma_vert_rad( double gamma)
Propagate->SetUVW(1, vUVW(1));
Propagate->SetUVW(2, vUVW(2));
Propagate->SetUVW(3, vUVW(3));
FGInterface::set_Gamma_vert_rad(gamma);
}
}
}
// Reverse the VCAS formula to obtain the corresponding Mach number. For subsonic
// speeds, the reversed formula has a closed form. For supersonic speeds, the
// formula is reversed by the Newton-Raphson algorithm.
double FGJSBsim::getMachFromVcas(double vcas)
{
double p=pressure->getDoubleValue();
double psl=fdmex->GetAtmosphere()->GetPressureSL();
double rhosl=fdmex->GetAtmosphere()->GetDensitySL();
double pt = p + psl*(pow(1+vcas*vcas*rhosl/(7.0*psl),3.5)-1);
if (pt/p < 1.89293)
return sqrt(5.0*(pow(pt/p, 0.2857143) -1)); // Mach < 1
else {
// Mach >= 1
double mach = sqrt(0.77666*pt/p); // Initial guess is based on a quadratic approximation of the Rayleigh formula
double delta = 1.;
double target = pt/(166.92158*p);
int iter = 0;
// Find the root with Newton-Raphson. Since the differential is never zero,
// the function is monotonic and has only one root with a multiplicity of one.
// Convergence is certain.
while (delta > 1E-5 && iter < 10) {
double m2 = mach*mach; // Mach^2
double m6 = m2*m2*m2; // Mach^6
delta = mach*m6/pow(7.0*m2-1.0,2.5) - target;
double diff = 7.0*m6*(2.0*m2-1)/pow(7.0*m2-1.0,3.5); // Never zero when Mach >= 1
mach -= delta/diff;
iter++;
}
return mach;
FGInterface::set_Gamma_vert_rad(gamma);
}
}

View file

@ -297,7 +297,6 @@ private:
void do_trim(void);
double getMachFromVcas(double vcas);
bool update_ground_cache(JSBSim::FGLocation cart, double* cart_pos, double dt);
void init_gear(void);
void update_gear(void);

View file

@ -1,9 +0,0 @@
SUBDIRS = initialization models input_output math
noinst_LIBRARIES = libJSBSim.a
libJSBSim_a_SOURCES = FGFDMExec.cpp FGJSBBase.cpp JSBSim.cxx
noinst_HEADERS = FGFDMExec.h FGJSBBase.h JSBSim.hxx
INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/src/FDM/JSBSim

View file

@ -63,7 +63,7 @@ using namespace std;
namespace JSBSim {
static const char *IdSrc = "$Id: FGInitialCondition.cpp,v 1.69 2011/08/04 12:46:32 jberndt Exp $";
static const char *IdSrc = "$Id: FGInitialCondition.cpp,v 1.75 2011/10/23 15:05:32 bcoconni Exp $";
static const char *IdHdr = ID_INITIALCONDITION;
//******************************************************************************
@ -74,6 +74,7 @@ FGInitialCondition::FGInitialCondition(FGFDMExec *FDMExec) : fdmex(FDMExec)
if(FDMExec != NULL ) {
PropertyManager=fdmex->GetPropertyManager();
Atmosphere=fdmex->GetAtmosphere();
Constructing = true;
bind();
Constructing = false;
@ -105,16 +106,13 @@ void FGInitialCondition::ResetIC(double u0, double v0, double w0,
InitializeIC();
p = p0; q = q0; r = r0;
vPQR_body = FGColumnVector3(p0, q0, r0);
alpha = alpha0; beta = beta0;
phi = phi0; theta = theta0; psi = psi0;
position.SetPosition(lonRad0, latRad0, altAGLFt0 + terrain_elevation + sea_level_radius);
FGQuaternion Quat(phi, theta, psi);
Quat.Normalize();
Tl2b = Quat.GetT();
Tb2l = Tl2b.Transposed();
orientation = FGQuaternion(phi0, theta0, psi0);
const FGMatrix33& Tb2l = orientation.GetTInv();
vUVW_NED = Tb2l * FGColumnVector3(u0, v0, w0);
vt = vUVW_NED.Magnitude();
@ -132,21 +130,20 @@ void FGInitialCondition::ResetIC(double u0, double v0, double w0,
void FGInitialCondition::InitializeIC(void)
{
alpha=beta=0;
theta=phi=psi=0;
terrain_elevation = 0;
sea_level_radius = fdmex->GetInertial()->GetRefRadius();
position.SetEllipse(fdmex->GetInertial()->GetSemimajor(), fdmex->GetInertial()->GetSemiminor());
position.SetPosition(0., 0., sea_level_radius);
position.SetEarthPositionAngle(fdmex->GetPropagate()->GetEarthPositionAngle());
orientation = FGQuaternion(0.0, 0.0, 0.0);
vUVW_NED.InitMatrix();
p=q=r=0;
vPQR_body.InitMatrix();
vt=0;
targetNlfIC = 1.0;
Tw2b.InitMatrix(1., 0., 0., 0., 1., 0., 0., 0., 1.);
Tb2w.InitMatrix(1., 0., 0., 0., 1., 0., 0., 0., 1.);
Tl2b.InitMatrix(1., 0., 0., 0., 1., 0., 0., 0., 1.);
Tb2l.InitMatrix(1., 0., 0., 0., 1., 0., 0., 0., 1.);
}
//******************************************************************************
@ -168,12 +165,12 @@ void FGInitialCondition::WriteStateFile(int num)
if (outfile.is_open()) {
outfile << "<?xml version=\"1.0\"?>" << endl;
outfile << "<initialize name=\"reset00\">" << endl;
outfile << " <ubody unit=\"FT/SEC\"> " << Propagate->GetUVW(eX) << " </ubody> " << endl;
outfile << " <vbody unit=\"FT/SEC\"> " << Propagate->GetUVW(eY) << " </vbody> " << endl;
outfile << " <wbody unit=\"FT/SEC\"> " << Propagate->GetUVW(eZ) << " </wbody> " << endl;
outfile << " <phi unit=\"DEG\"> " << Propagate->GetEuler(ePhi) << " </phi>" << endl;
outfile << " <theta unit=\"DEG\"> " << Propagate->GetEuler(eTht) << " </theta>" << endl;
outfile << " <psi unit=\"DEG\"> " << Propagate->GetEuler(ePsi) << " </psi>" << endl;
outfile << " <ubody unit=\"FT/SEC\"> " << Propagate->GetUVW(eU) << " </ubody> " << endl;
outfile << " <vbody unit=\"FT/SEC\"> " << Propagate->GetUVW(eV) << " </vbody> " << endl;
outfile << " <wbody unit=\"FT/SEC\"> " << Propagate->GetUVW(eW) << " </wbody> " << endl;
outfile << " <phi unit=\"DEG\"> " << Propagate->GetEuler(ePhi)*radtodeg << " </phi>" << endl;
outfile << " <theta unit=\"DEG\"> " << Propagate->GetEuler(eTht)*radtodeg << " </theta>" << endl;
outfile << " <psi unit=\"DEG\"> " << Propagate->GetEuler(ePsi)*radtodeg << " </psi>" << endl;
outfile << " <longitude unit=\"DEG\"> " << Propagate->GetLongitudeDeg() << " </longitude>" << endl;
outfile << " <latitude unit=\"DEG\"> " << Propagate->GetLatitudeDeg() << " </latitude>" << endl;
outfile << " <altitude unit=\"FT\"> " << Propagate->GetDistanceAGL() << " </altitude>" << endl;
@ -189,8 +186,8 @@ void FGInitialCondition::WriteStateFile(int num)
void FGInitialCondition::SetVequivalentKtsIC(double ve)
{
double altitudeASL = position.GetRadius() - sea_level_radius;
double rho = fdmex->GetAtmosphere()->GetDensity(altitudeASL);
double rhoSL = fdmex->GetAtmosphere()->GetDensitySL();
double rho = Atmosphere->GetDensity(altitudeASL);
double rhoSL = Atmosphere->GetDensitySL();
SetVtrueFpsIC(ve*ktstofps*sqrt(rhoSL/rho));
lastSpeedSet = setve;
}
@ -200,7 +197,7 @@ void FGInitialCondition::SetVequivalentKtsIC(double ve)
void FGInitialCondition::SetMachIC(double mach)
{
double altitudeASL = position.GetRadius() - sea_level_radius;
double temperature = fdmex->GetAtmosphere()->GetTemperature(altitudeASL);
double temperature = Atmosphere->GetTemperature(altitudeASL);
double soundSpeed = sqrt(SHRatio*Reng*temperature);
SetVtrueFpsIC(mach*soundSpeed);
lastSpeedSet = setmach;
@ -211,8 +208,11 @@ void FGInitialCondition::SetMachIC(double mach)
void FGInitialCondition::SetVcalibratedKtsIC(double vcas)
{
double altitudeASL = position.GetRadius() - sea_level_radius;
double mach = getMachFromVcas(fabs(vcas)*ktstofps);
double temperature = fdmex->GetAtmosphere()->GetTemperature(altitudeASL);
double pressure = Atmosphere->GetPressure(altitudeASL);
double pressureSL = Atmosphere->GetPressureSL();
double rhoSL = Atmosphere->GetDensitySL();
double mach = MachFromVcalibrated(fabs(vcas)*ktstofps, pressure, pressureSL, rhoSL);
double temperature = Atmosphere->GetTemperature(altitudeASL);
double soundSpeed = sqrt(SHRatio*Reng*temperature);
SetVtrueFpsIC(mach*soundSpeed);
@ -225,6 +225,7 @@ void FGInitialCondition::SetVcalibratedKtsIC(double vcas)
void FGInitialCondition::calcAeroAngles(const FGColumnVector3& _vt_NED)
{
const FGMatrix33& Tl2b = orientation.GetT();
FGColumnVector3 _vt_BODY = Tl2b * _vt_NED;
double ua = _vt_BODY(eX);
double va = _vt_BODY(eY);
@ -271,11 +272,12 @@ void FGInitialCondition::calcAeroAngles(const FGColumnVector3& _vt_NED)
void FGInitialCondition::SetVgroundFpsIC(double vg)
{
const FGMatrix33& Tb2l = orientation.GetTInv();
FGColumnVector3 _vt_NED = Tb2l * Tw2b * FGColumnVector3(vt, 0., 0.);
FGColumnVector3 _vWIND_NED = _vt_NED - vUVW_NED;
vUVW_NED(eU) = vg*cos(psi);
vUVW_NED(eV) = vg*sin(psi);
vUVW_NED(eU) = vg * orientation.GetCosEuler(ePsi);
vUVW_NED(eV) = vg * orientation.GetSinEuler(ePsi);
vUVW_NED(eW) = 0.;
_vt_NED = vUVW_NED + _vWIND_NED;
vt = _vt_NED.Magnitude();
@ -294,6 +296,7 @@ void FGInitialCondition::SetVgroundFpsIC(double vg)
void FGInitialCondition::SetVtrueFpsIC(double vtrue)
{
const FGMatrix33& Tb2l = orientation.GetTInv();
FGColumnVector3 _vt_NED = Tb2l * Tw2b * FGColumnVector3(vt, 0., 0.);
FGColumnVector3 _vWIND_NED = _vt_NED - vUVW_NED;
@ -322,6 +325,7 @@ void FGInitialCondition::SetClimbRateFpsIC(double hdot)
return;
}
const FGMatrix33& Tb2l = orientation.GetTInv();
FGColumnVector3 _vt_NED = Tb2l * Tw2b * FGColumnVector3(vt, 0., 0.);
FGColumnVector3 _WIND_NED = _vt_NED - vUVW_NED;
double hdot0 = -_vt_NED(eW);
@ -345,6 +349,7 @@ void FGInitialCondition::SetClimbRateFpsIC(double hdot)
void FGInitialCondition::SetAlphaRadIC(double alfa)
{
const FGMatrix33& Tb2l = orientation.GetTInv();
FGColumnVector3 _vt_NED = Tb2l * Tw2b * FGColumnVector3(vt, 0., 0.);
calcThetaBeta(alfa, _vt_NED);
}
@ -356,9 +361,10 @@ void FGInitialCondition::SetAlphaRadIC(double alfa)
void FGInitialCondition::calcThetaBeta(double alfa, const FGColumnVector3& _vt_NED)
{
FGColumnVector3 vOrient = orientation.GetEuler();
double calpha = cos(alfa), salpha = sin(alfa);
double cpsi = cos(psi), spsi = sin(psi);
double cphi = cos(phi), sphi = sin(phi);
double cpsi = orientation.GetCosEuler(ePsi), spsi = orientation.GetSinEuler(ePsi);
double cphi = orientation.GetCosEuler(ePhi), sphi = orientation.GetSinEuler(ePhi);
FGMatrix33 Tpsi( cpsi, spsi, 0.,
-spsi, cpsi, 0.,
0., 0., 1.);
@ -400,13 +406,11 @@ void FGInitialCondition::calcThetaBeta(double alfa, const FGColumnVector3& _vt_N
v0xz.Normalize();
v1xz.Normalize();
double sinTheta = (v1xz * v0xz)(eY);
theta = asin(sinTheta);
vOrient(eTht) = asin(sinTheta);
FGQuaternion Quat(phi, theta, psi);
Quat.Normalize();
Tl2b = Quat.GetT();
Tb2l = Quat.GetTInv();
orientation = FGQuaternion(vOrient);
const FGMatrix33& Tl2b = orientation.GetT();
FGColumnVector3 v2 = Talpha * Tl2b * _vt_NED;
alpha = alfa;
@ -430,18 +434,24 @@ void FGInitialCondition::calcThetaBeta(double alfa, const FGColumnVector3& _vt_N
void FGInitialCondition::SetBetaRadIC(double bta)
{
const FGMatrix33& Tb2l = orientation.GetTInv();
FGColumnVector3 _vt_NED = Tb2l * Tw2b * FGColumnVector3(vt, 0., 0.);
FGColumnVector3 vOrient = orientation.GetEuler();
beta = bta;
double calpha = cos(alpha), salpha = sin(alpha);
double cbeta = cos(beta), sbeta = sin(beta);
double cphi = orientation.GetCosEuler(ePhi), sphi = orientation.GetSinEuler(ePhi);
FGMatrix33 TphiInv(1., 0., 0.,
0., cphi,-sphi,
0., sphi, cphi);
Tw2b = FGMatrix33(calpha*cbeta, -calpha*sbeta, -salpha,
sbeta, cbeta, 0.0,
salpha*cbeta, -salpha*sbeta, calpha);
Tb2w = Tw2b.Transposed();
FGColumnVector3 vf = FGQuaternion(eX, phi).GetTInv() * Tw2b * FGColumnVector3(vt, 0., 0.);
FGColumnVector3 vf = TphiInv * Tw2b * FGColumnVector3(vt, 0., 0.);
FGColumnVector3 v0xy(_vt_NED(eX), _vt_NED(eY), 0.);
FGColumnVector3 v1xy(sqrt(v0xy(eX)*v0xy(eX)+v0xy(eY)*v0xy(eY)-vf(eY)*vf(eY)),vf(eY),0.);
v0xy.Normalize();
@ -451,7 +461,7 @@ void FGInitialCondition::SetBetaRadIC(double bta)
double sinPsi = (v1xy * v0xy)(eZ);
double cosPsi = DotProduct(v0xy, v1xy);
psi = atan2(sinPsi, cosPsi);
vOrient(ePsi) = atan2(sinPsi, cosPsi);
FGMatrix33 Tpsi( cosPsi, sinPsi, 0.,
-sinPsi, cosPsi, 0.,
0., 0., 1.);
@ -462,64 +472,32 @@ void FGInitialCondition::SetBetaRadIC(double bta)
v2xz.Normalize();
vfxz.Normalize();
double sinTheta = (v2xz * vfxz)(eY);
theta = -asin(sinTheta);
vOrient(eTht) = -asin(sinTheta);
FGQuaternion Quat(phi, theta, psi);
Quat.Normalize();
Tl2b = Quat.GetT();
Tb2l = Quat.GetTInv();
orientation = FGQuaternion(vOrient);
}
//******************************************************************************
// Modifies the body frame orientation (roll angle phi). The true airspeed in
// the local NED frame is kept unchanged. Hence the true airspeed in the body
// frame is modified.
// Modifies the body frame orientation.
void FGInitialCondition::SetPhiRadIC(double fi)
void FGInitialCondition::SetEulerAngleRadIC(int idx, double angle)
{
const FGMatrix33& Tb2l = orientation.GetTInv();
const FGMatrix33& Tl2b = orientation.GetT();
FGColumnVector3 _vt_NED = Tb2l * Tw2b * FGColumnVector3(vt, 0., 0.);
FGColumnVector3 _vWIND_NED = _vt_NED - vUVW_NED;
FGColumnVector3 _vUVW_BODY = Tl2b * vUVW_NED;
FGColumnVector3 vOrient = orientation.GetEuler();
phi = fi;
FGQuaternion Quat = FGQuaternion(phi, theta, psi);
Quat.Normalize();
Tl2b = Quat.GetT();
Tb2l = Quat.GetTInv();
vOrient(idx) = angle;
orientation = FGQuaternion(vOrient);
calcAeroAngles(_vt_NED);
}
//******************************************************************************
// Modifies the body frame orientation (pitch angle theta). The true airspeed in
// the local NED frame is kept unchanged. Hence the true airspeed in the body
// frame is modified.
void FGInitialCondition::SetThetaRadIC(double teta)
{
FGColumnVector3 _vt_NED = Tb2l * Tw2b * FGColumnVector3(vt, 0., 0.);
theta = teta;
FGQuaternion Quat = FGQuaternion(phi, theta, psi);
Quat.Normalize();
Tl2b = Quat.GetT();
Tb2l = Quat.GetTInv();
calcAeroAngles(_vt_NED);
}
//******************************************************************************
// Modifies the body frame orientation (yaw angle psi). The true airspeed in
// the local NED frame is kept unchanged. Hence the true airspeed in the body
// frame is modified.
void FGInitialCondition::SetPsiRadIC(double psy)
{
FGColumnVector3 _vt_NED = Tb2l * Tw2b * FGColumnVector3(vt, 0., 0.);
psi = psy;
FGQuaternion Quat = FGQuaternion(phi, theta, psi);
Quat.Normalize();
Tl2b = Quat.GetT();
Tb2l = Quat.GetTInv();
if ((lastSpeedSet != setned) && (lastSpeedSet != setvg)) {
const FGMatrix33& newTb2l = orientation.GetTInv();
vUVW_NED = newTb2l * _vUVW_BODY;
_vt_NED = vUVW_NED + _vWIND_NED;
vt = _vt_NED.Magnitude();
}
calcAeroAngles(_vt_NED);
}
@ -531,6 +509,8 @@ void FGInitialCondition::SetPsiRadIC(double psy)
void FGInitialCondition::SetBodyVelFpsIC(int idx, double vel)
{
const FGMatrix33& Tb2l = orientation.GetTInv();
const FGMatrix33& Tl2b = orientation.GetT();
FGColumnVector3 _vt_NED = Tb2l * Tw2b * FGColumnVector3(vt, 0., 0.);
FGColumnVector3 _vUVW_BODY = Tl2b * vUVW_NED;
FGColumnVector3 _vWIND_NED = _vt_NED - vUVW_NED;
@ -552,6 +532,7 @@ void FGInitialCondition::SetBodyVelFpsIC(int idx, double vel)
void FGInitialCondition::SetNEDVelFpsIC(int idx, double vel)
{
const FGMatrix33& Tb2l = orientation.GetTInv();
FGColumnVector3 _vt_NED = Tb2l * Tw2b * FGColumnVector3(vt, 0., 0.);
FGColumnVector3 _vWIND_NED = _vt_NED - vUVW_NED;
@ -583,9 +564,10 @@ void FGInitialCondition::SetWindNEDFpsIC(double wN, double wE, double wD )
void FGInitialCondition::SetCrossWindKtsIC(double cross)
{
const FGMatrix33& Tb2l = orientation.GetTInv();
FGColumnVector3 _vt_NED = Tb2l * Tw2b * FGColumnVector3(vt, 0., 0.);
FGColumnVector3 _vWIND_NED = _vt_NED - vUVW_NED;
FGColumnVector3 _vCROSS(-sin(psi), cos(psi), 0.);
FGColumnVector3 _vCROSS(-orientation.GetSinEuler(ePsi), orientation.GetCosEuler(ePsi), 0.);
// Gram-Schmidt process is used to remove the existing cross wind component
_vWIND_NED -= DotProduct(_vWIND_NED, _vCROSS) * _vCROSS;
@ -605,13 +587,14 @@ void FGInitialCondition::SetCrossWindKtsIC(double cross)
void FGInitialCondition::SetHeadWindKtsIC(double head)
{
const FGMatrix33& Tb2l = orientation.GetTInv();
FGColumnVector3 _vt_NED = Tb2l * Tw2b * FGColumnVector3(vt, 0., 0.);
FGColumnVector3 _vWIND_NED = _vt_NED - vUVW_NED;
// This is a head wind, so the direction vector for the wind
// needs to be set opposite to the heading the aircraft
// is taking. So, the cos and sin of the heading (psi)
// are negated in the line below.
FGColumnVector3 _vHEAD(-cos(psi), -sin(psi), 0.);
FGColumnVector3 _vHEAD(-orientation.GetCosEuler(ePsi), -orientation.GetSinEuler(ePsi), 0.);
// Gram-Schmidt process is used to remove the existing head wind component
_vWIND_NED -= DotProduct(_vWIND_NED, _vHEAD) * _vHEAD;
@ -632,6 +615,7 @@ void FGInitialCondition::SetHeadWindKtsIC(double head)
void FGInitialCondition::SetWindDownKtsIC(double wD)
{
const FGMatrix33& Tb2l = orientation.GetTInv();
FGColumnVector3 _vt_NED = Tb2l * Tw2b * FGColumnVector3(vt, 0., 0.);
_vt_NED(eW) = vUVW_NED(eW) + wD;
@ -647,6 +631,7 @@ void FGInitialCondition::SetWindDownKtsIC(double wD)
void FGInitialCondition::SetWindMagKtsIC(double mag)
{
const FGMatrix33& Tb2l = orientation.GetTInv();
FGColumnVector3 _vt_NED = Tb2l * Tw2b * FGColumnVector3(vt, 0., 0.);
FGColumnVector3 _vWIND_NED = _vt_NED - vUVW_NED;
FGColumnVector3 _vHEAD(_vWIND_NED(eU), _vWIND_NED(eV), 0.);
@ -672,6 +657,7 @@ void FGInitialCondition::SetWindMagKtsIC(double mag)
void FGInitialCondition::SetWindDirDegIC(double dir)
{
const FGMatrix33& Tb2l = orientation.GetTInv();
FGColumnVector3 _vt_NED = Tb2l * Tw2b * FGColumnVector3(vt, 0., 0.);
FGColumnVector3 _vWIND_NED = _vt_NED - vUVW_NED;
double mag = _vWIND_NED.Magnitude(eU, eV);
@ -693,25 +679,30 @@ void FGInitialCondition::SetWindDirDegIC(double dir)
void FGInitialCondition::SetAltitudeASLFtIC(double alt)
{
double altitudeASL = position.GetRadius() - sea_level_radius;
double temperature = fdmex->GetAtmosphere()->GetTemperature(altitudeASL);
double temperature = Atmosphere->GetTemperature(altitudeASL);
double pressure = Atmosphere->GetPressure(altitudeASL);
double pressureSL = Atmosphere->GetPressureSL();
double soundSpeed = sqrt(SHRatio*Reng*temperature);
double rho = fdmex->GetAtmosphere()->GetDensity(altitudeASL);
double rhoSL = fdmex->GetAtmosphere()->GetDensitySL();
double rho = Atmosphere->GetDensity(altitudeASL);
double rhoSL = Atmosphere->GetDensitySL();
double mach0 = vt / soundSpeed;
double vc0 = calcVcas(mach0);
double vc0 = VcalibratedFromMach(mach0, pressure, pressureSL, rhoSL);
double ve0 = vt * sqrt(rho/rhoSL);
altitudeASL=alt;
position.SetRadius(alt + sea_level_radius);
temperature = fdmex->GetAtmosphere()->GetTemperature(altitudeASL);
temperature = Atmosphere->GetTemperature(altitudeASL);
soundSpeed = sqrt(SHRatio*Reng*temperature);
rho = fdmex->GetAtmosphere()->GetDensity(altitudeASL);
rho = Atmosphere->GetDensity(altitudeASL);
pressure = Atmosphere->GetPressure(altitudeASL);
switch(lastSpeedSet) {
case setvc:
mach0 = getMachFromVcas(vc0);
mach0 = MachFromVcalibrated(vc0, pressure, pressureSL, rhoSL);
SetVtrueFpsIC(mach0 * soundSpeed);
break;
case setmach:
SetVtrueFpsIC(mach0 * soundSpeed);
break;
@ -723,90 +714,11 @@ void FGInitialCondition::SetAltitudeASLFtIC(double alt)
}
}
//******************************************************************************
// Calculate the VCAS. Uses the Rayleigh formula for supersonic speeds
// (See "Introduction to Aerodynamics of a Compressible Fluid - H.W. Liepmann,
// A.E. Puckett - Wiley & sons (1947)" §5.4 pp 75-80)
double FGInitialCondition::calcVcas(double Mach) const
{
double altitudeASL = position.GetRadius() - sea_level_radius;
double p=fdmex->GetAtmosphere()->GetPressure(altitudeASL);
double psl=fdmex->GetAtmosphere()->GetPressureSL();
double rhosl=fdmex->GetAtmosphere()->GetDensitySL();
double pt,A,vcas;
if (Mach < 0) Mach=0;
if (Mach < 1) //calculate total pressure assuming isentropic flow
pt=p*pow((1 + 0.2*Mach*Mach),3.5);
else {
// shock in front of pitot tube, we'll assume its normal and use
// the Rayleigh Pitot Tube Formula, i.e. the ratio of total
// pressure behind the shock to the static pressure in front of
// the normal shock assumption should not be a bad one -- most supersonic
// aircraft place the pitot probe out front so that it is the forward
// most point on the aircraft. The real shock would, of course, take
// on something like the shape of a rounded-off cone but, here again,
// the assumption should be good since the opening of the pitot probe
// is very small and, therefore, the effects of the shock curvature
// should be small as well. AFAIK, this approach is fairly well accepted
// within the aerospace community
// The denominator below is zero for Mach ~ 0.38, for which
// we'll never be here, so we're safe
pt = p*166.92158*pow(Mach,7.0)/pow(7*Mach*Mach-1,2.5);
}
A = pow(((pt-p)/psl+1),0.28571);
vcas = sqrt(7*psl/rhosl*(A-1));
//cout << "calcVcas: vcas= " << vcas*fpstokts << " mach= " << Mach << " pressure: " << pt << endl;
return vcas;
}
//******************************************************************************
// Reverse the VCAS formula to obtain the corresponding Mach number. For subsonic
// speeds, the reversed formula has a closed form. For supersonic speeds, the
// formula is reversed by the Newton-Raphson algorithm.
double FGInitialCondition::getMachFromVcas(double vcas)
{
double altitudeASL = position.GetRadius() - sea_level_radius;
double p=fdmex->GetAtmosphere()->GetPressure(altitudeASL);
double psl=fdmex->GetAtmosphere()->GetPressureSL();
double rhosl=fdmex->GetAtmosphere()->GetDensitySL();
double pt = p + psl*(pow(1+vcas*vcas*rhosl/(7.0*psl),3.5)-1);
if (pt/p < 1.89293)
return sqrt(5.0*(pow(pt/p, 0.2857143) -1)); // Mach < 1
else {
// Mach >= 1
double mach = sqrt(0.77666*pt/p); // Initial guess is based on a quadratic approximation of the Rayleigh formula
double delta = 1.;
double target = pt/(166.92158*p);
int iter = 0;
// Find the root with Newton-Raphson. Since the differential is never zero,
// the function is monotonic and has only one root with a multiplicity of one.
// Convergence is certain.
while (delta > 1E-5 && iter < 10) {
double m2 = mach*mach; // Mach^2
double m6 = m2*m2*m2; // Mach^6
delta = mach*m6/pow(7.0*m2-1.0,2.5) - target;
double diff = 7.0*m6*(2.0*m2-1)/pow(7.0*m2-1.0,3.5); // Never zero when Mach >= 1
mach -= delta/diff;
iter++;
}
return mach;
}
}
//******************************************************************************
double FGInitialCondition::GetWindDirDegIC(void) const
{
const FGMatrix33& Tb2l = orientation.GetTInv();
FGColumnVector3 _vt_NED = Tb2l * Tw2b * FGColumnVector3(vt, 0., 0.);
FGColumnVector3 _vWIND_NED = _vt_NED - vUVW_NED;
@ -818,6 +730,7 @@ double FGInitialCondition::GetWindDirDegIC(void) const
double FGInitialCondition::GetNEDWindFpsIC(int idx) const
{
const FGMatrix33& Tb2l = orientation.GetTInv();
FGColumnVector3 _vt_NED = Tb2l * Tw2b * FGColumnVector3(vt, 0., 0.);
FGColumnVector3 _vWIND_NED = _vt_NED - vUVW_NED;
@ -828,6 +741,7 @@ double FGInitialCondition::GetNEDWindFpsIC(int idx) const
double FGInitialCondition::GetWindFpsIC(void) const
{
const FGMatrix33& Tb2l = orientation.GetTInv();
FGColumnVector3 _vt_NED = Tb2l * Tw2b * FGColumnVector3(vt, 0., 0.);
FGColumnVector3 _vWIND_NED = _vt_NED - vUVW_NED;
@ -838,6 +752,7 @@ double FGInitialCondition::GetWindFpsIC(void) const
double FGInitialCondition::GetBodyWindFpsIC(int idx) const
{
const FGMatrix33& Tl2b = orientation.GetT();
FGColumnVector3 _vt_BODY = Tw2b * FGColumnVector3(vt, 0., 0.);
FGColumnVector3 _vUVW_BODY = Tl2b * vUVW_NED;
FGColumnVector3 _vWIND_BODY = _vt_BODY - _vUVW_BODY;
@ -850,10 +765,13 @@ double FGInitialCondition::GetBodyWindFpsIC(int idx) const
double FGInitialCondition::GetVcalibratedKtsIC(void) const
{
double altitudeASL = position.GetRadius() - sea_level_radius;
double temperature = fdmex->GetAtmosphere()->GetTemperature(altitudeASL);
double temperature = Atmosphere->GetTemperature(altitudeASL);
double pressure = Atmosphere->GetPressure(altitudeASL);
double pressureSL = Atmosphere->GetPressureSL();
double rhoSL = Atmosphere->GetDensitySL();
double soundSpeed = sqrt(SHRatio*Reng*temperature);
double mach = vt / soundSpeed;
return fpstokts * calcVcas(mach);
return fpstokts * VcalibratedFromMach(mach, pressure, pressureSL, rhoSL);
}
//******************************************************************************
@ -861,8 +779,8 @@ double FGInitialCondition::GetVcalibratedKtsIC(void) const
double FGInitialCondition::GetVequivalentKtsIC(void) const
{
double altitudeASL = position.GetRadius() - sea_level_radius;
double rho = fdmex->GetAtmosphere()->GetDensity(altitudeASL);
double rhoSL = fdmex->GetAtmosphere()->GetDensitySL();
double rho = Atmosphere->GetDensity(altitudeASL);
double rhoSL = Atmosphere->GetDensitySL();
return fpstokts * vt * sqrt(rho/rhoSL);
}
@ -871,7 +789,7 @@ double FGInitialCondition::GetVequivalentKtsIC(void) const
double FGInitialCondition::GetMachIC(void) const
{
double altitudeASL = position.GetRadius() - sea_level_radius;
double temperature = fdmex->GetAtmosphere()->GetTemperature(altitudeASL);
double temperature = Atmosphere->GetTemperature(altitudeASL);
double soundSpeed = sqrt(SHRatio*Reng*temperature);
return vt / soundSpeed;
}
@ -880,6 +798,7 @@ double FGInitialCondition::GetMachIC(void) const
double FGInitialCondition::GetBodyVelFpsIC(int idx) const
{
const FGMatrix33& Tl2b = orientation.GetT();
FGColumnVector3 _vUVW_BODY = Tl2b * vUVW_NED;
return _vUVW_BODY(idx);
@ -923,6 +842,8 @@ bool FGInitialCondition::Load(string rstfile, bool useStoredPath)
result = Load_v1();
}
fdmex->RunIC();
// Check to see if any engines are specified to be initialized in a running state
FGPropulsion* propulsion = fdmex->GetPropulsion();
Element* running_elements = document->FindElement("running");
@ -937,9 +858,6 @@ bool FGInitialCondition::Load(string rstfile, bool useStoredPath)
running_elements = document->FindNextElement("running");
}
fdmex->RunIC();
fdmex->GetPropagate()->DumpState();
return result;
}
@ -963,17 +881,16 @@ bool FGInitialCondition::Load_v1(void)
else if (document->FindElement("altitudeMSL")) // This is feet above sea level
position.SetRadius(document->FindElementValueAsNumberConvertTo("altitudeMSL", "FT") + sea_level_radius);
if (document->FindElement("phi"))
phi = document->FindElementValueAsNumberConvertTo("phi", "RAD");
if (document->FindElement("theta"))
theta = document->FindElementValueAsNumberConvertTo("theta", "RAD");
if (document->FindElement("psi"))
psi = document->FindElementValueAsNumberConvertTo("psi", "RAD");
FGColumnVector3 vOrient = orientation.GetEuler();
FGQuaternion Quat(phi, theta, psi);
Quat.Normalize();
Tl2b = Quat.GetT();
Tb2l = Quat.GetTInv();
if (document->FindElement("phi"))
vOrient(ePhi) = document->FindElementValueAsNumberConvertTo("phi", "RAD");
if (document->FindElement("theta"))
vOrient(eTht) = document->FindElementValueAsNumberConvertTo("theta", "RAD");
if (document->FindElement("psi"))
vOrient(ePsi) = document->FindElementValueAsNumberConvertTo("psi", "RAD");
orientation = FGQuaternion(vOrient);
if (document->FindElement("ubody"))
SetUBodyFpsIC(document->FindElementValueAsNumberConvertTo("ubody", "FT/SEC"));
@ -1024,9 +941,7 @@ bool FGInitialCondition::Load_v1(void)
-radInv*vUVW_NED(eNorth),
-radInv*vUVW_NED(eEast)*position.GetTanLatitude() );
p = vOmegaLocal(eP);
q = vOmegaLocal(eR);
r = vOmegaLocal(eQ);
vPQR_body = vOmegaLocal;
return result;
}
@ -1111,7 +1026,6 @@ bool FGInitialCondition::Load_v2(void)
// ToDo: Do we need to deal with normalization of the quaternions here?
Element* orientation_el = document->FindElement("orientation");
FGQuaternion QuatLocal2Body;
if (orientation_el) {
string frame = orientation_el->GetAttributeValue("frame");
frame = to_lower(frame);
@ -1132,7 +1046,7 @@ bool FGInitialCondition::Load_v2(void)
QuatI2Body.Normalize();
FGQuaternion QuatLocal2I = position.GetTl2i();
QuatLocal2I.Normalize();
QuatLocal2Body = QuatLocal2I * QuatI2Body;
orientation = QuatLocal2I * QuatI2Body;
} else if (frame == "ecef") {
@ -1150,11 +1064,11 @@ bool FGInitialCondition::Load_v2(void)
QuatEC2Body.Normalize();
FGQuaternion QuatLocal2EC = position.GetTl2ec(); // Get Q_e/l from matrix
QuatLocal2EC.Normalize();
QuatLocal2Body = QuatLocal2EC * QuatEC2Body; // Q_b/l = Q_e/l * Q_b/e
orientation = QuatLocal2EC * QuatEC2Body; // Q_b/l = Q_e/l * Q_b/e
} else if (frame == "local") {
QuatLocal2Body = FGQuaternion(vOrient);
orientation = FGQuaternion(vOrient);
} else {
@ -1165,13 +1079,6 @@ bool FGInitialCondition::Load_v2(void)
}
}
QuatLocal2Body.Normalize();
phi = QuatLocal2Body.GetEuler(ePhi);
theta = QuatLocal2Body.GetEuler(eTht);
psi = QuatLocal2Body.GetEuler(ePsi);
Tl2b = QuatLocal2Body.GetT();
Tb2l = QuatLocal2Body.GetTInv();
// Initialize vehicle velocity
// Allowable frames
// - ECI (Earth Centered Inertial)
@ -1183,6 +1090,8 @@ bool FGInitialCondition::Load_v2(void)
Element* velocity_el = document->FindElement("velocity");
FGColumnVector3 vInitVelocity = FGColumnVector3(0.0, 0.0, 0.0);
FGMatrix33 mTec2l = position.GetTec2l();
const FGMatrix33& Tb2l = orientation.GetTInv();
if (velocity_el) {
string frame = velocity_el->GetAttributeValue("frame");
@ -1224,8 +1133,8 @@ bool FGInitialCondition::Load_v2(void)
// - ECEF (Earth Centered, Earth Fixed)
// - Body
FGColumnVector3 vLocalRate;
Element* attrate_el = document->FindElement("attitude_rate");
const FGMatrix33& Tl2b = orientation.GetT();
// Refer to Stevens and Lewis, 1.5-14a, pg. 49.
// This is the rotation rate of the "Local" frame, expressed in the local frame.
@ -1242,11 +1151,11 @@ bool FGInitialCondition::Load_v2(void)
FGColumnVector3 vAttRate = attrate_el->FindElementTripletConvertTo("RAD/SEC");
if (frame == "eci") {
vLocalRate = Tl2b * position.GetTi2l() * (vAttRate - vOmegaEarth);
vPQR_body = Tl2b * position.GetTi2l() * (vAttRate - vOmegaEarth);
} else if (frame == "ecef") {
vLocalRate = Tl2b * position.GetTec2l() * vAttRate;
vPQR_body = Tl2b * position.GetTec2l() * vAttRate;
} else if (frame == "local") {
vLocalRate = vAttRate + vOmegaLocal;
vPQR_body = vAttRate + vOmegaLocal;
} else if (!frame.empty()) { // misspelling of frame
cerr << endl << fgred << " Attitude rate frame type: \"" << frame
@ -1254,17 +1163,13 @@ bool FGInitialCondition::Load_v2(void)
result = false;
} else if (frame.empty()) {
vLocalRate = vOmegaLocal;
vPQR_body = vOmegaLocal;
}
} else { // Body frame attitude rate assumed 0 relative to local.
vLocalRate = vOmegaLocal;
vPQR_body = vOmegaLocal;
}
p = vLocalRate(eP);
q = vLocalRate(eQ);
r = vLocalRate(eR);
return result;
}
@ -1317,7 +1222,9 @@ void FGInitialCondition::bind(void)
&FGInitialCondition::SetPhiDegIC,
true);
PropertyManager->Tie("ic/psi-true-deg", this,
&FGInitialCondition::GetPsiDegIC );
&FGInitialCondition::GetPsiDegIC,
&FGInitialCondition::SetPsiDegIC,
true);
PropertyManager->Tie("ic/lat-gc-deg", this,
&FGInitialCondition::GetLatitudeDegIC,
&FGInitialCondition::SetLatitudeDegIC,
@ -1414,7 +1321,9 @@ void FGInitialCondition::bind(void)
&FGInitialCondition::SetPhiRadIC,
true);
PropertyManager->Tie("ic/psi-true-rad", this,
&FGInitialCondition::GetPsiRadIC);
&FGInitialCondition::GetPsiRadIC,
&FGInitialCondition::SetPsiRadIC,
true);
PropertyManager->Tie("ic/lat-gc-rad", this,
&FGInitialCondition::GetLatitudeRadIC,
&FGInitialCondition::SetLatitudeRadIC,

View file

@ -54,7 +54,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_INITIALCONDITION "$Id: FGInitialCondition.h,v 1.28 2011/07/10 19:03:49 jberndt Exp $"
#define ID_INITIALCONDITION "$Id: FGInitialCondition.h,v 1.31 2011/10/23 15:05:32 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@ -65,6 +65,7 @@ namespace JSBSim {
class FGFDMExec;
class FGMatrix33;
class FGColumnVector3;
class FGAtmosphere;
typedef enum { setvt, setvc, setve, setmach, setuvw, setned, setvg } speedset;
@ -213,7 +214,7 @@ CLASS DOCUMENTATION
@property ic/r-rad_sec (read/write) Yaw rate initial condition in radians/second
@author Tony Peden
@version "$Id: FGInitialCondition.h,v 1.28 2011/07/10 19:03:49 jberndt Exp $"
@version "$Id: FGInitialCondition.h,v 1.31 2011/10/23 15:05:32 bcoconni Exp $"
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -349,15 +350,15 @@ public:
/** Gets the initial pitch angle.
@return Initial pitch angle in degrees */
double GetThetaDegIC(void) const { return theta*radtodeg; }
double GetThetaDegIC(void) const { return orientation.GetEulerDeg(eTht); }
/** Gets the initial roll angle.
@return Initial phi in degrees */
double GetPhiDegIC(void) const { return phi*radtodeg; }
double GetPhiDegIC(void) const { return orientation.GetEulerDeg(ePhi); }
/** Gets the initial heading angle.
@return Initial psi in degrees */
double GetPsiDegIC(void) const { return psi*radtodeg; }
double GetPsiDegIC(void) const { return orientation.GetEulerDeg(ePsi); }
/** Gets the initial latitude.
@return Initial geocentric latitude in degrees */
@ -411,17 +412,17 @@ public:
@param vd Initial down velocity in feet/second */
void SetVDownFpsIC(double vd) { SetNEDVelFpsIC(eW, vd); }
/** Sets the initial roll rate.
/** Sets the initial body axis roll rate.
@param P Initial roll rate in radians/second */
void SetPRadpsIC(double P) { p = P; }
void SetPRadpsIC(double P) { vPQR_body(eP) = P; }
/** Sets the initial pitch rate.
/** Sets the initial body axis pitch rate.
@param Q Initial pitch rate in radians/second */
void SetQRadpsIC(double Q) { q = Q; }
void SetQRadpsIC(double Q) { vPQR_body(eQ) = Q; }
/** Sets the initial yaw rate.
/** Sets the initial body axis yaw rate.
@param R initial yaw rate in radians/second */
void SetRRadpsIC(double R) { r = R; }
void SetRRadpsIC(double R) { vPQR_body(eR) = R; }
/** Sets the initial wind velocity.
@param wN Initial wind velocity in local north direction, feet/second
@ -473,6 +474,14 @@ public:
@return Initial body axis Z wind velocity in feet/second */
double GetWindWFpsIC(void) const { return GetBodyWindFpsIC(eW); }
/** Gets the initial wind velocity in the NED local frame
@return Initial wind velocity in NED frame in feet/second */
const FGColumnVector3 GetWindNEDFpsIC(void) const {
const FGMatrix33& Tb2l = orientation.GetTInv();
FGColumnVector3 _vt_NED = Tb2l * Tw2b * FGColumnVector3(vt, 0., 0.);
return _vt_NED - vUVW_NED;
}
/** Gets the initial wind velocity in local frame.
@return Initial wind velocity toward north in feet/second */
double GetWindNFpsIC(void) const { return GetNEDWindFpsIC(eX); }
@ -497,10 +506,18 @@ public:
@return Initial rate of climb in feet/second */
double GetClimbRateFpsIC(void) const
{
const FGMatrix33& Tb2l = orientation.GetTInv();
FGColumnVector3 _vt_NED = Tb2l * Tw2b * FGColumnVector3(vt, 0., 0.);
return _vt_NED(eW);
}
/** Gets the initial body velocity
@return Initial body velocity in feet/second. */
const FGColumnVector3 GetUVWFpsIC(void) const {
const FGMatrix33& Tl2b = orientation.GetT();
return Tl2b * vUVW_NED;
}
/** Gets the initial body axis X velocity.
@return Initial body axis X velocity in feet/second. */
double GetUBodyFpsIC(void) const { return GetBodyVelFpsIC(eU); }
@ -525,17 +542,21 @@ public:
@return Initial local frame Z (Down) axis velocity in feet/second. */
double GetVDownFpsIC(void) const { return vUVW_NED(eW); }
/** Gets the initial body rotation rate
@return Initial body rotation rate in radians/second */
const FGColumnVector3 GetPQRRadpsIC(void) const { return vPQR_body; }
/** Gets the initial body axis roll rate.
@return Initial body axis roll rate in radians/second */
double GetPRadpsIC() const { return p; }
double GetPRadpsIC() const { return vPQR_body(eP); }
/** Gets the initial body axis pitch rate.
@return Initial body axis pitch rate in radians/second */
double GetQRadpsIC() const { return q; }
double GetQRadpsIC() const { return vPQR_body(eQ); }
/** Gets the initial body axis yaw rate.
@return Initial body axis yaw rate in radians/second */
double GetRRadpsIC() const { return r; }
double GetRRadpsIC() const { return vPQR_body(eR); }
/** Sets the initial flight path angle.
@param gamma Initial flight path angle in radians */
@ -546,21 +567,21 @@ public:
@param alpha Initial angle of attack in radians */
void SetAlphaRadIC(double alpha);
/** Sets the initial pitch angle.
@param theta Initial pitch angle in radians */
void SetThetaRadIC(double theta);
/** Sets the initial sideslip angle.
@param beta Initial angle of sideslip in radians. */
void SetBetaRadIC(double beta);
/** Sets the initial roll angle.
@param phi Initial roll angle in radians */
void SetPhiRadIC(double phi);
void SetPhiRadIC(double phi) { SetEulerAngleRadIC(ePhi, phi); }
/** Sets the initial pitch angle.
@param theta Initial pitch angle in radians */
void SetThetaRadIC(double theta) { SetEulerAngleRadIC(eTht, theta); }
/** Sets the initial heading angle.
@param psi Initial heading angle in radians */
void SetPsiRadIC(double psi);
void SetPsiRadIC(double psi) { SetEulerAngleRadIC(ePsi, psi); }
/** Sets the initial latitude.
@param lat Initial latitude in radians */
@ -588,9 +609,9 @@ public:
@return Initial sideslip angle in radians */
double GetBetaRadIC(void) const { return beta; }
/** Gets the initial roll angle.
@return Initial roll angle in radians */
double GetPhiRadIC(void) const { return phi; }
/** Gets the initial position
@return Initial location */
const FGLocation& GetPosition(void) const { return position; }
/** Gets the initial latitude.
@return Initial latitude in radians */
@ -600,13 +621,21 @@ public:
@return Initial longitude in radians */
double GetLongitudeRadIC(void) const { return position.GetLongitude(); }
/** Gets the initial orientation
@return Initial orientation */
const FGQuaternion& GetOrientation(void) const { return orientation; }
/** Gets the initial roll angle.
@return Initial roll angle in radians */
double GetPhiRadIC(void) const { return orientation.GetEuler(ePhi); }
/** Gets the initial pitch angle.
@return Initial pitch angle in radians */
double GetThetaRadIC(void) const { return theta; }
double GetThetaRadIC(void) const { return orientation.GetEuler(eTht); }
/** Gets the initial heading angle.
@return Initial heading angle in radians */
double GetPsiRadIC(void) const { return psi; }
double GetPsiRadIC(void) const { return orientation.GetEuler(ePsi); }
/** Gets the initial speedset.
@return Initial speedset */
@ -632,21 +661,22 @@ public:
private:
FGColumnVector3 vUVW_NED;
FGColumnVector3 vPQR_body;
FGLocation position;
FGQuaternion orientation;
double vt;
double p,q,r;
double sea_level_radius;
double terrain_elevation;
double targetNlfIC;
FGMatrix33 Tw2b, Tb2w;
FGMatrix33 Tl2b, Tb2l;
double alpha, beta, theta, phi, psi;
double alpha, beta;
speedset lastSpeedSet;
FGFDMExec *fdmex;
FGPropertyManager *PropertyManager;
FGAtmosphere* Atmosphere;
bool Load_v1(void);
bool Load_v2(void);
@ -654,13 +684,12 @@ private:
bool Constructing;
void InitializeIC(void);
void SetEulerAngleRadIC(int idx, double angle);
void SetBodyVelFpsIC(int idx, double vel);
void SetNEDVelFpsIC(int idx, double vel);
double GetBodyWindFpsIC(int idx) const;
double GetNEDWindFpsIC(int idx) const;
double GetBodyVelFpsIC(int idx) const;
double getMachFromVcas(double vcas);
double calcVcas(double Mach) const;
void calcAeroAngles(const FGColumnVector3& _vt_BODY);
void calcThetaBeta(double alfa, const FGColumnVector3& _vt_NED);
void bind(void);

View file

@ -1,7 +0,0 @@
noinst_LIBRARIES = libInit.a
libInit_a_SOURCES = FGInitialCondition.cpp FGTrim.cpp FGTrimAxis.cpp
noinst_HEADERS = FGInitialCondition.h FGTrim.h FGTrimAxis.h
INCLUDES = -I$(top_srcdir)/src/FDM/JSBSim

View file

@ -39,34 +39,22 @@ namespace JSBSim {
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGGroundCallback::FGGroundCallback()
FGDefaultGroundCallback::FGDefaultGroundCallback(double referenceRadius)
{
mReferenceRadius = 20925650.0; // Sea level radius
mSeaLevelRadius = referenceRadius; // Sea level radius
mTerrainLevelRadius = mSeaLevelRadius;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGGroundCallback::FGGroundCallback(double ReferenceRadius)
double FGDefaultGroundCallback::GetAltitude(const FGLocation& loc) const
{
mReferenceRadius = ReferenceRadius;
return loc.GetRadius() - mSeaLevelRadius;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGGroundCallback::~FGGroundCallback()
{
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
double FGGroundCallback::GetAltitude(const FGLocation& loc) const
{
return loc.GetRadius() - mReferenceRadius;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
double FGGroundCallback::GetAGLevel(double t, const FGLocation& loc,
double FGDefaultGroundCallback::GetAGLevel(double t, const FGLocation& loc,
FGLocation& contact, FGColumnVector3& normal,
FGColumnVector3& vel, FGColumnVector3& angularVel) const
{
@ -75,9 +63,11 @@ double FGGroundCallback::GetAGLevel(double t, const FGLocation& loc,
normal = FGColumnVector3(loc).Normalize();
double loc_radius = loc.GetRadius(); // Get the radius of the given location
// (e.g. the CG)
double agl = loc_radius - mReferenceRadius;
contact = (mReferenceRadius/loc_radius)*FGColumnVector3(loc);
double agl = loc_radius - mTerrainLevelRadius;
contact = (mTerrainLevelRadius/loc_radius)*FGColumnVector3(loc);
return agl;
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
} // namespace JSBSim

View file

@ -45,7 +45,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_GROUNDCALLBACK "$Id: FGGroundCallback.h,v 1.9 2010/10/07 03:45:40 jberndt Exp $"
#define ID_GROUNDCALLBACK "$Id: FGGroundCallback.h,v 1.12 2011/10/14 22:46:49 bcoconni Exp $"
namespace JSBSim {
@ -53,13 +53,13 @@ namespace JSBSim {
CLASS DOCUMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/** This class provides callback slots to get ground specific data like
ground elevation and such.
There is a default implementation, which returns values for a
ball formed earth.
/** This class provides callback slots to get ground specific data.
The default implementation returns values for a
ball formed earth with an adjustable terrain elevation.
@author Mathias Froehlich
@version $Id: FGGroundCallback.h,v 1.9 2010/10/07 03:45:40 jberndt Exp $
@version $Id: FGGroundCallback.h,v 1.12 2011/10/14 22:46:49 bcoconni Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -69,31 +69,88 @@ CLASS DECLARATION
class FGGroundCallback : public FGJSBBase
{
public:
/** Default constructor.
Within this constructor, the reference radius is set to the WGS84 equatorial
radius. This constructor should really not be called, instead relying on the
constructor that takes reference radius as an argument. */
FGGroundCallback();
/** Constructor
This constructor accepts the reference radius in feet. This is the preferred
constructor. */
FGGroundCallback(double ReferenceRadius);
virtual ~FGGroundCallback();
FGGroundCallback() {}
virtual ~FGGroundCallback() {}
/** Compute the altitude above sealevel
@param l location
*/
virtual double GetAltitude(const FGLocation& l) const = 0;
/** Compute the altitude above ground.
The altitude depends on time t and location l.
@param t simulation time
@param l location
@param contact Contact point location below the location l
@param normal Normal vector at the contact point
@param v Linear velocity at the contact point
@param w Angular velocity at the contact point
@return altitude above ground
*/
virtual double GetAGLevel(double t, const FGLocation& location,
FGLocation& contact,
FGColumnVector3& normal, FGColumnVector3& v,
FGColumnVector3& w) const = 0;
/** Compute the local terrain radius
@param t simulation time
@param location location
*/
virtual double GetTerrainGeoCentRadius(double t, const FGLocation& location) const = 0;
/** Return the sea level radius
@param t simulation time
@param location location
*/
virtual double GetSeaLevelRadius(const FGLocation& location) const = 0;
/** Set the local terrain radius.
Only needs to be implemented if JSBSim should be allowed
to modify the local terrain radius (see the default implementation)
*/
virtual void SetTerrainGeoCentRadius(double radius) { }
/** Set the sea level radius.
Only needs to be implemented if JSBSim should be allowed
to modify the sea level radius (see the default implementation)
*/
virtual void SetSeaLevelRadius(double radius) { }
/** Compute the altitude above sealevel. */
virtual double GetAltitude(const FGLocation& l) const;
/** Compute the altitude above ground. Defaults to sealevel altitude. */
virtual double GetAGLevel(double t, const FGLocation& l, FGLocation& cont,
FGColumnVector3& n, FGColumnVector3& v,
FGColumnVector3& w) const;
virtual void SetTerrainGeoCentRadius(double radius) {mReferenceRadius = radius;}
virtual double GetTerrainGeoCentRadius(void) const {return mReferenceRadius;}
private:
/// Reference radius.
double mReferenceRadius;
};
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// The default sphere earth implementation:
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
class FGDefaultGroundCallback : public FGGroundCallback
{
public:
FGDefaultGroundCallback(double referenceRadius = 20925650.0);
double GetAltitude(const FGLocation& l) const;
double GetAGLevel(double t, const FGLocation& location,
FGLocation& contact,
FGColumnVector3& normal, FGColumnVector3& v,
FGColumnVector3& w) const;
void SetTerrainGeoCentRadius(double radius) { mTerrainLevelRadius = radius;}
double GetTerrainGeoCentRadius(double t, const FGLocation& location) const
{ return mTerrainLevelRadius; }
void SetSeaLevelRadius(double radius) { mSeaLevelRadius = radius; }
double GetSeaLevelRadius(const FGLocation& location) const
{return mSeaLevelRadius; }
private:
double mSeaLevelRadius;
double mTerrainLevelRadius;
};
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#endif

View file

@ -1,7 +0,0 @@
noinst_LIBRARIES = libInputOutput.a
libInputOutput_a_SOURCES = FGGroundCallback.cpp FGPropertyManager.cpp FGScript.cpp FGXMLElement.cpp FGXMLParse.cpp FGfdmSocket.cpp
noinst_HEADERS = FGGroundCallback.h FGPropertyManager.h FGScript.h FGXMLElement.h FGXMLParse.h FGfdmSocket.h FGXMLFileRead.h net_fdm.hxx string_utilities.h
INCLUDES = -I$(top_srcdir)/src/FDM/JSBSim

View file

@ -45,7 +45,7 @@ INCLUDES
namespace JSBSim {
static const char *IdSrc = "$Id: FGLocation.cpp,v 1.23 2010/09/22 11:34:09 jberndt Exp $";
static const char *IdSrc = "$Id: FGLocation.cpp,v 1.25 2011/10/16 00:19:56 bcoconni Exp $";
static const char *IdHdr = ID_LOCATION;
using std::cerr;
using std::endl;
@ -137,6 +137,7 @@ FGLocation::FGLocation(const FGLocation& l)
e = l.e;
eps2 = l.eps2;
f = l.f;
epa = l.epa;
/*ag
* if the cache is not valid, all of the following values are unset.
@ -152,6 +153,10 @@ FGLocation::FGLocation(const FGLocation& l)
mTl2ec = l.mTl2ec;
mTec2l = l.mTec2l;
mTi2ec = l.mTi2ec;
mTec2i = l.mTec2i;
mTi2l = l.mTi2l;
mTl2i = l.mTl2i;
initial_longitude = l.initial_longitude;
mGeodLat = l.mGeodLat;
@ -173,6 +178,7 @@ const FGLocation& FGLocation::operator=(const FGLocation& l)
e = l.e;
eps2 = l.eps2;
f = l.f;
epa = l.epa;
//ag See comment in constructor above
if (!mCacheValid) return *this;
@ -183,6 +189,10 @@ const FGLocation& FGLocation::operator=(const FGLocation& l)
mTl2ec = l.mTl2ec;
mTec2l = l.mTec2l;
mTi2ec = l.mTi2ec;
mTec2i = l.mTec2i;
mTi2l = l.mTi2l;
mTl2i = l.mTl2i;
initial_longitude = l.initial_longitude;
mGeodLat = l.mGeodLat;

View file

@ -1,11 +0,0 @@
noinst_LIBRARIES = libMath.a
libMath_a_SOURCES = FGColumnVector3.cpp FGFunction.cpp FGLocation.cpp FGMatrix33.cpp \
FGPropertyValue.cpp FGQuaternion.cpp FGRealValue.cpp FGTable.cpp \
FGCondition.cpp FGRungeKutta.cpp FGModelFunctions.cpp
noinst_HEADERS = FGColumnVector3.h FGFunction.h FGLocation.h FGMatrix33.h \
FGParameter.h FGPropertyValue.h FGQuaternion.h FGRealValue.h FGTable.h \
FGCondition.h FGRungeKutta.h FGModelFunctions.h LagrangeMultiplier.h
INCLUDES = -I$(top_srcdir)/src/FDM/JSBSim

View file

@ -48,7 +48,7 @@ using namespace std;
namespace JSBSim {
static const char *IdSrc = "$Id: FGAerodynamics.cpp,v 1.41 2011/08/04 12:46:32 jberndt Exp $";
static const char *IdSrc = "$Id: FGAerodynamics.cpp,v 1.44 2011/10/23 14:23:13 jentron Exp $";
static const char *IdHdr = ID_AERODYNAMICS;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -208,13 +208,15 @@ bool FGAerodynamics::Run(bool Holding)
if ( fabs(vFw(eDrag)) > 0.0) lod = fabs( vFw(eLift) / vFw(eDrag) );
// Calculate aerodynamic reference point shift, if any. The shift
// takes place in the body axis. That is, if the shift is negative,
// takes place in the structual axis. That is, if the shift is positive,
// it is towards the back (tail) of the vehicle. The AeroRPShift
// function should be non-dimensionalized by the wing chord. The
// calculated vDeltaRP will be in feet.
if (AeroRPShift) vDeltaRP(eX) = AeroRPShift->GetValue()*in.Wingchord;
vDXYZcg = in.RPBody + vDeltaRP;
vDXYZcg(eX) = in.RPBody(eX) - vDeltaRP(eX); // vDeltaRP is given in the structural frame
vDXYZcg(eY) = in.RPBody(eY) + vDeltaRP(eY);
vDXYZcg(eZ) = in.RPBody(eZ) - vDeltaRP(eZ);
vMoments = vDXYZcg*vForces; // M = r X F
@ -382,7 +384,7 @@ string FGAerodynamics::GetAeroFunctionValues(const string& delimeter) const
for (unsigned int axis = 0; axis < 6; axis++) {
for (unsigned int sd = 0; sd < AeroFunctions[axis].size(); sd++) {
if (buf.tellp() > 0) buf << delimeter;
buf << setw(9) << AeroFunctions[axis][sd]->GetValue();
buf << AeroFunctions[axis][sd]->GetValue();
}
}

View file

@ -77,7 +77,7 @@ using namespace std;
namespace JSBSim {
static const char *IdSrc = "$Id: FGOutput.cpp,v 1.62 2011/09/25 15:38:30 bcoconni Exp $";
static const char *IdSrc = "$Id: FGOutput.cpp,v 1.63 2011/10/10 02:33:34 jentron Exp $";
static const char *IdHdr = ID_OUTPUT;
// (stolen from FGFS native_fdm.cxx)
@ -216,7 +216,7 @@ void FGOutput::SetType(const string& type)
{
if (type == "CSV") {
Type = otCSV;
delimeter = ", ";
delimeter = ",";
} else if (type == "TABULAR") {
Type = otTab;
delimeter = "\t";

View file

@ -68,7 +68,7 @@ using namespace std;
namespace JSBSim {
static const char *IdSrc = "$Id: FGPropagate.cpp,v 1.96 2011/09/17 15:36:35 bcoconni Exp $";
static const char *IdSrc = "$Id: FGPropagate.cpp,v 1.98 2011/10/22 15:11:24 bcoconni Exp $";
static const char *IdHdr = ID_PROPAGATE;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -77,8 +77,6 @@ CLASS IMPLEMENTATION
FGPropagate::FGPropagate(FGFDMExec* fdmex)
: FGModel(fdmex),
LocalTerrainRadius(0),
SeaLevelRadius(0),
VehicleRadius(0)
{
Debug(0);
@ -115,10 +113,9 @@ FGPropagate::~FGPropagate(void)
bool FGPropagate::InitModel(void)
{
// For initialization ONLY:
SeaLevelRadius = LocalTerrainRadius = in.RefRadius;
FDMExec->GetGroundCallback()->SetTerrainGeoCentRadius(LocalTerrainRadius);
VState.vLocation.SetRadius( FDMExec->GetGroundCallback()->
GetTerrainGeoCentRadius(0.0,VState.vLocation) + 4.0 );
VState.vLocation.SetRadius( LocalTerrainRadius + 4.0 );
VState.vLocation.SetEllipse(in.SemiMajor, in.SemiMinor);
vInertialVelocity.InitMatrix();
@ -145,11 +142,7 @@ void FGPropagate::SetInitialState(const FGInitialCondition *FGIC)
// Initialize the State Vector elements and the transformation matrices
// Set the position lat/lon/radius
VState.vLocation.SetPosition( FGIC->GetLongitudeRadIC(),
FGIC->GetLatitudeRadIC(),
FGIC->GetAltitudeASLFtIC() + SeaLevelRadius);
VState.vLocation.SetEarthPositionAngle(0.0);
VState.vLocation = FGIC->GetPosition();
Ti2ec = VState.vLocation.GetTi2ec(); // ECI to ECEF transform
Tec2i = Ti2ec.Transposed(); // ECEF to ECI frame transform
@ -161,31 +154,24 @@ void FGPropagate::SetInitialState(const FGInitialCondition *FGIC)
// Set the orientation from the euler angles (is normalized within the
// constructor). The Euler angles represent the orientation of the body
// frame relative to the local frame.
VState.qAttitudeLocal = FGQuaternion( FGIC->GetPhiRadIC(),
FGIC->GetThetaRadIC(),
FGIC->GetPsiRadIC() );
VState.qAttitudeLocal = FGIC->GetOrientation();
VState.qAttitudeECI = Ti2l.GetQuaternion()*VState.qAttitudeLocal;
UpdateBodyMatrices();
// Set the velocities in the instantaneus body frame
VState.vUVW = FGColumnVector3( FGIC->GetUBodyFpsIC(),
FGIC->GetVBodyFpsIC(),
FGIC->GetWBodyFpsIC() );
VState.vUVW = FGIC->GetUVWFpsIC();
// Compute the local frame ECEF velocity
vVel = Tb2l * VState.vUVW;
// Recompute the LocalTerrainRadius.
RecomputeLocalTerrainRadius();
// Compute local terrain velocity
RecomputeLocalTerrainVelocity();
VehicleRadius = GetRadius();
// Set the angular velocities of the body frame relative to the ECEF frame,
// expressed in the body frame.
VState.vPQR = FGColumnVector3( FGIC->GetPRadpsIC(),
FGIC->GetQRadpsIC(),
FGIC->GetRRadpsIC() );
VState.vPQR = FGIC->GetPQRRadpsIC();
VState.vPQRi = VState.vPQR + Ti2b * in.vOmegaPlanet;
@ -269,8 +255,7 @@ bool FGPropagate::Run(bool Holding)
CalculateUVW();
// Set auxilliary state variables
RecomputeLocalTerrainRadius();
RecomputeLocalTerrainVelocity();
VehicleRadius = GetRadius(); // Calculate current aircraft radius from center of planet
VState.vPQR = VState.vPQRi - Ti2b * in.vOmegaPlanet;
@ -410,39 +395,79 @@ void FGPropagate::SetInertialRates(FGColumnVector3 vRates) {
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGPropagate::RecomputeLocalTerrainRadius(void)
void FGPropagate::RecomputeLocalTerrainVelocity()
{
FGLocation contactloc;
FGColumnVector3 dummy;
double t = FDMExec->GetSimTime();
// Get the LocalTerrain radius.
FDMExec->GetGroundCallback()->GetAGLevel(t, VState.vLocation, contactloc,
dummy, LocalTerrainVelocity, LocalTerrainAngularVelocity);
LocalTerrainRadius = contactloc.GetRadius();
FDMExec->GetGroundCallback()->SetTerrainGeoCentRadius(LocalTerrainRadius);
FGLocation contact;
FGColumnVector3 normal;
FDMExec->GetGroundCallback()->GetAGLevel(FDMExec->GetSimTime(),
VState.vLocation,
contact, normal,
LocalTerrainVelocity,
LocalTerrainAngularVelocity);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGPropagate::SetTerrainElevation(double terrainElev)
{
LocalTerrainRadius = terrainElev + SeaLevelRadius;
FDMExec->GetGroundCallback()->SetTerrainGeoCentRadius(LocalTerrainRadius);
double radius = terrainElev + FDMExec->GetGroundCallback()->GetSeaLevelRadius(VState.vLocation);
FDMExec->GetGroundCallback()->SetTerrainGeoCentRadius(radius);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGPropagate::SetSeaLevelRadius(double tt)
{
FDMExec->GetGroundCallback()->SetSeaLevelRadius(tt);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
double FGPropagate::GetLocalTerrainRadius(void) const
{
return FDMExec->GetGroundCallback()->GetTerrainGeoCentRadius(FDMExec->GetSimTime(),
VState.vLocation);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
double FGPropagate::GetTerrainElevation(void) const
{
return FDMExec->GetGroundCallback()->GetTerrainGeoCentRadius()-SeaLevelRadius;
return GetLocalTerrainRadius()
- FDMExec->GetGroundCallback()->GetSeaLevelRadius(VState.vLocation);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
double FGPropagate::GetDistanceAGL(void) const
{
return VState.vLocation.GetRadius() - LocalTerrainRadius;
FGColumnVector3 dummy;
FGLocation dummyloc;
double t = FDMExec->GetSimTime();
return FDMExec->GetGroundCallback()->GetAGLevel(t, VState.vLocation, dummyloc,
dummy, dummy, dummy);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGPropagate::SetAltitudeASL(double altASL)
{
SetRadius(altASL + FDMExec->GetGroundCallback()->GetSeaLevelRadius(VState.vLocation));
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
double FGPropagate::GetAltitudeASL(void) const
{
return VState.vLocation.GetRadius()
- FDMExec->GetGroundCallback()->GetSeaLevelRadius(VState.vLocation);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGPropagate::SetDistanceAGL(double tt)
{
SetAltitudeASL(tt + GetTerrainElevation());
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -456,7 +481,7 @@ void FGPropagate::SetVState(const VehicleState& vstate)
Tec2i = Ti2ec.Transposed();
UpdateLocationMatrices();
SetInertialOrientation(vstate.qAttitudeECI);
RecomputeLocalTerrainRadius();
RecomputeLocalTerrainVelocity();
VehicleRadius = GetRadius();
VState.vUVW = vstate.vUVW;
vVel = Tb2l * VState.vUVW;
@ -469,7 +494,7 @@ void FGPropagate::SetVState(const VehicleState& vstate)
void FGPropagate::UpdateVehicleState(void)
{
RecomputeLocalTerrainRadius();
RecomputeLocalTerrainVelocity();
VehicleRadius = GetRadius();
VState.vInertialPosition = Tec2i * VState.vLocation;
UpdateLocationMatrices();

View file

@ -49,7 +49,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_PROPAGATE "$Id: FGPropagate.h,v 1.63 2011/08/21 15:35:39 bcoconni Exp $"
#define ID_PROPAGATE "$Id: FGPropagate.h,v 1.64 2011/10/14 22:46:49 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@ -93,7 +93,7 @@ CLASS DOCUMENTATION
@endcode
@author Jon S. Berndt, Mathias Froehlich, Bertrand Coconnier
@version $Id: FGPropagate.h,v 1.63 2011/08/21 15:35:39 bcoconni Exp $
@version $Id: FGPropagate.h,v 1.64 2011/10/14 22:46:49 bcoconni Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -293,7 +293,7 @@ public:
units ft
@return The current altitude above sea level in feet.
*/
double GetAltitudeASL(void) const { return VState.vLocation.GetRadius() - SeaLevelRadius; }
double GetAltitudeASL(void) const;
/** Returns the current altitude above sea level.
This function returns the altitude above sea level.
@ -377,7 +377,7 @@ public:
units feet
@return distance of the local terrain from the center of the earth.
*/
double GetLocalTerrainRadius(void) const { return LocalTerrainRadius; }
double GetLocalTerrainRadius(void) const;
double GetEarthPositionAngle(void) const { return VState.vLocation.GetEPA(); }
@ -385,6 +385,8 @@ public:
const FGColumnVector3& GetTerrainVelocity(void) const { return LocalTerrainVelocity; }
const FGColumnVector3& GetTerrainAngularVelocity(void) const { return LocalTerrainAngularVelocity; }
void RecomputeLocalTerrainVelocity();
double GetTerrainElevation(void) const;
double GetDistanceAGL(void) const;
double GetRadius(void) const {
@ -502,11 +504,14 @@ public:
VehicleRadius = r;
VState.vInertialPosition = Tec2i * VState.vLocation;
}
void SetAltitudeASL(double altASL) { SetRadius(altASL + SeaLevelRadius); }
void SetAltitudeASLmeters(double altASL) { SetRadius(altASL/fttom + SeaLevelRadius); }
void SetSeaLevelRadius(double tt) { SeaLevelRadius = tt; }
void SetAltitudeASL(double altASL);
void SetAltitudeASLmeters(double altASL) { SetAltitudeASL(altASL/fttom); }
void SetSeaLevelRadius(double tt);
void SetTerrainElevation(double tt);
void SetDistanceAGL(double tt) { SetRadius(tt + LocalTerrainRadius); }
void SetDistanceAGL(double tt);
void SetInitialState(const FGInitialCondition *);
void SetLocation(const FGLocation& l);
void SetLocation(const FGColumnVector3& lv)
@ -520,8 +525,6 @@ public:
SetLocation(l);
}
void RecomputeLocalTerrainRadius(void);
void NudgeBodyLocation(FGColumnVector3 deltaLoc) {
VState.vInertialPosition -= Tb2i*deltaLoc;
VState.vLocation -= Tb2ec*deltaLoc;
@ -563,8 +566,9 @@ private:
FGMatrix33 Ti2l;
FGMatrix33 Tl2i;
double LocalTerrainRadius, SeaLevelRadius, VehicleRadius;
double VehicleRadius;
FGColumnVector3 LocalTerrainVelocity, LocalTerrainAngularVelocity;
eIntegrateType integrator_rotational_rate;
eIntegrateType integrator_translational_rate;
eIntegrateType integrator_rotational_position;

View file

@ -1,18 +0,0 @@
SUBDIRS = atmosphere propulsion flight_control
noinst_LIBRARIES = libModels.a
libModels_a_SOURCES = FGAerodynamics.cpp FGAircraft.cpp FGAtmosphere.cpp \
FGAuxiliary.cpp FGFCS.cpp FGGroundReactions.cpp \
FGInertial.cpp FGBuoyantForces.cpp FGExternalForce.cpp \
FGLGear.cpp FGMassBalance.cpp FGModel.cpp FGOutput.cpp \
FGPropagate.cpp FGPropulsion.cpp FGInput.cpp \
FGExternalReactions.cpp FGGasCell.cpp FGAccelerations.cpp
noinst_HEADERS = FGAerodynamics.h FGAircraft.h FGAtmosphere.h FGAuxiliary.h \
FGFCS.h FGGroundReactions.h FGInertial.h FGLGear.h \
FGMassBalance.h FGBuoyantForces.h FGExternalForce.h \
FGModel.h FGOutput.h FGPropagate.h FGPropulsion.h FGInput.h \
FGExternalReactions.h FGGasCell.h FGAccelerations.h
INCLUDES = -I$(top_srcdir)/src/FDM/JSBSim

View file

@ -47,7 +47,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_WINDS "$Id: FGWinds.h,v 1.5 2011/09/07 12:21:45 jberndt Exp $"
#define ID_WINDS "$Id: FGWinds.h,v 1.6 2011/10/22 15:11:24 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@ -150,6 +150,9 @@ public:
/// Sets a wind component in NED frame.
virtual void SetWindNED(int idx, double wind) { vWindNED(idx)=wind;}
/// Sets the wind components in NED frame.
virtual void SetWindNED(const FGColumnVector3& wind) { vWindNED=wind; }
/// Retrieves the wind components in NED frame.
virtual FGColumnVector3& GetWindNED(void) { return vWindNED; }

View file

@ -1,7 +0,0 @@
noinst_LIBRARIES = libAtmosphere.a
libAtmosphere_a_SOURCES = FGMSIS.cpp FGMSISData.cpp FGMars.cpp FGStandardAtmosphere.cpp FGWinds.cpp
noinst_HEADERS = FGMSIS.h FGMars.h FGStandardAtmosphere.h FGWinds.h
INCLUDES = -I$(top_srcdir)/src/FDM/JSBSim

View file

@ -1,15 +0,0 @@
noinst_LIBRARIES = libFlightControl.a
libFlightControl_a_SOURCES = \
FGPID.cpp FGDeadBand.cpp FGFCSComponent.cpp \
FGFilter.cpp FGGain.cpp FGKinemat.cpp \
FGSummer.cpp FGSwitch.cpp FGFCSFunction.cpp FGSensor.cpp \
FGActuator.cpp FGAccelerometer.cpp FGGyro.cpp FGMagnetometer.cpp
noinst_HEADERS = \
FGPID.h FGDeadBand.h FGFCSComponent.h FGFilter.h \
FGGain.h FGKinemat.h FGSummer.h FGSwitch.h FGFCSFunction.h\
FGSensor.h FGActuator.h FGAccelerometer.h FGGyro.h FGMagnetometer.h \
FGSensorOrientation.h
INCLUDES = -I$(top_srcdir)/src/FDM/JSBSim

View file

@ -50,7 +50,7 @@ using namespace std;
namespace JSBSim {
static const char *IdSrc = "$Id: FGPiston.cpp,v 1.67 2011/09/25 23:56:11 jentron Exp $";
static const char *IdSrc = "$Id: FGPiston.cpp,v 1.68 2011/10/11 15:13:34 jentron Exp $";
static const char *IdHdr = ID_PISTON;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -434,6 +434,8 @@ void FGPiston::Calculate(void)
RunPreFunctions();
TotalDeltaT = ( in.TotalDeltaT < 1e-9 ) ? 1.0 : in.TotalDeltaT;
/* The thruster controls the engine RPM because it encapsulates the gear ratio and other transmission variables */
RPM = Thruster->GetEngineRPM();
@ -618,10 +620,7 @@ void FGPiston::doMAP(void)
// Add a one second lag to manifold pressure changes
double dMAP=0;
if (in.TotalDeltaT > 0.0)
dMAP = (TMAP - p_ram * map_coefficient) * in.TotalDeltaT;
else
dMAP = (TMAP - p_ram * map_coefficient) / 120;
dMAP = (TMAP - p_ram * map_coefficient) * TotalDeltaT;
TMAP -=dMAP;
@ -799,10 +798,7 @@ void FGPiston::doEGT(void)
} else { // Drop towards ambient - guess an appropriate time constant for now
combustion_efficiency = 0;
dEGTdt = (RankineToKelvin(in.Temperature) - ExhaustGasTemp_degK) / 100.0;
if (in.TotalDeltaT > 0.0)
delta_T_exhaust = dEGTdt * in.TotalDeltaT;
else
delta_T_exhaust = dEGTdt / 120;
delta_T_exhaust = dEGTdt * TotalDeltaT;
ExhaustGasTemp_degK += delta_T_exhaust;
}
@ -841,12 +837,9 @@ void FGPiston::doCHT(void)
double HeatCapacityCylinderHead = CpCylinderHead * MassCylinderHead;
if (in.TotalDeltaT > 0.0)
CylinderHeadTemp_degK +=
(dqdt_cylinder_head / HeatCapacityCylinderHead) * in.TotalDeltaT;
else
CylinderHeadTemp_degK +=
(dqdt_cylinder_head / HeatCapacityCylinderHead) / 120.0;
CylinderHeadTemp_degK +=
(dqdt_cylinder_head / HeatCapacityCylinderHead) * TotalDeltaT;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -880,10 +873,7 @@ void FGPiston::doOilTemperature(void)
double dOilTempdt = (target_oil_temp - OilTemp_degK) / time_constant;
if (in.TotalDeltaT > 0.0)
OilTemp_degK += (dOilTempdt * in.TotalDeltaT);
else
OilTemp_degK += (dOilTempdt / 120.0);
OilTemp_degK += (dOilTempdt * TotalDeltaT);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -46,7 +46,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_PISTON "$Id: FGPiston.h,v 1.31 2011/08/04 13:45:42 jberndt Exp $";
#define ID_PISTON "$Id: FGPiston.h,v 1.32 2011/10/11 16:16:16 jentron Exp $";
#define FG_MAX_BOOST_SPEEDS 3
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -198,7 +198,7 @@ boostspeed they refer to:
@author David Megginson (initial porting and additional code)
@author Ron Jensen (additional engine code)
@see Taylor, Charles Fayette, "The Internal Combustion Engine in Theory and Practice"
@version $Id: FGPiston.h,v 1.31 2011/08/04 13:45:42 jberndt Exp $
@version $Id: FGPiston.h,v 1.32 2011/10/11 16:16:16 jentron Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -332,6 +332,7 @@ private:
//
// Inputs (in addition to those in FGEngine).
//
double TotalDeltaT; // Time in seconds between calls.
double p_amb; // Pascals
double p_ram; // Pascals
double T_amb; // degrees Kelvin

View file

@ -45,7 +45,7 @@ using namespace std;
namespace JSBSim {
static const char *IdSrc = "$Id: FGPropeller.cpp,v 1.38 2011/09/24 14:26:46 jentron Exp $";
static const char *IdSrc = "$Id: FGPropeller.cpp,v 1.39 2011/10/15 13:00:57 bcoconni Exp $";
static const char *IdHdr = ID_PROPELLER;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -124,7 +124,7 @@ FGPropeller::FGPropeller(FGFDMExec* exec, Element* prop_element, int num)
local_element = prop_element->GetParent()->FindElement("sense");
if (local_element) {
double Sense = local_element->GetDataAsNumber();
SetSense(fabs(Sense)/Sense);
SetSense(Sense >= 0.0 ? 1.0 : -1.0);
}
local_element = prop_element->GetParent()->FindElement("p_factor");
if (local_element) {

View file

@ -47,6 +47,7 @@ INCLUDES
#include "FGRotor.h"
#include "input_output/FGXMLElement.h"
#include "models/FGMassBalance.h"
#include "models/FGPropulsion.h" // to get the GearRatio from a linked rotor
using std::cerr;
using std::endl;
@ -55,7 +56,7 @@ using std::cout;
namespace JSBSim {
static const char *IdSrc = "$Id: FGRotor.cpp,v 1.17 2011/09/24 14:26:46 jentron Exp $";
static const char *IdSrc = "$Id: FGRotor.cpp,v 1.18 2011/10/15 21:30:28 jentron Exp $";
static const char *IdHdr = ID_ROTOR;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -69,6 +70,113 @@ CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Note: The FGTransmission class is currently carried 'pick-a-pack' by
// FGRotor.
FGTransmission::FGTransmission(FGFDMExec *exec, int num) :
FreeWheelTransmission(1.0),
ThrusterMoment(1.0), EngineMoment(1.0), EngineFriction(0.0),
ClutchCtrlNorm(1.0), BrakeCtrlNorm(0.0), MaxBrakePower(0.0),
EngineRPM(0.0), ThrusterRPM(0.0)
{
double dt;
PropertyManager = exec->GetPropertyManager();
dt = exec->GetDeltaT();
// avoid too abrupt changes in transmission
FreeWheelLag = Filter(200.0,dt);
BindModel(num);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGTransmission::~FGTransmission(){
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// basically P = Q*w and Q_Engine + (-Q_Rotor) = J * dw/dt, J = Moment
//
void FGTransmission::Calculate(double EnginePower, double ThrusterTorque, double dt) {
double coupling = 1.0, coupling_sq = 1.0;
double fw_mult = 1.0;
double d_omega = 0.0, engine_d_omega = 0.0, thruster_d_omega = 0.0; // relative changes
double engine_omega = rpm_to_omega(EngineRPM);
double safe_engine_omega = engine_omega < 1e-1 ? 1e-1 : engine_omega;
double engine_torque = EnginePower / safe_engine_omega;
double thruster_omega = rpm_to_omega(ThrusterRPM);
double safe_thruster_omega = thruster_omega < 1e-1 ? 1e-1 : thruster_omega;
engine_torque -= EngineFriction / safe_engine_omega;
ThrusterTorque += Constrain(0.0, BrakeCtrlNorm, 1.0) * MaxBrakePower / safe_thruster_omega;
// would the FWU release ?
engine_d_omega = engine_torque/EngineMoment * dt;
thruster_d_omega = - ThrusterTorque/ThrusterMoment * dt;
if ( thruster_omega+thruster_d_omega > engine_omega+engine_d_omega ) {
// don't drive the engine
FreeWheelTransmission = 0.0;
} else {
FreeWheelTransmission = 1.0;
}
fw_mult = FreeWheelLag.execute(FreeWheelTransmission);
coupling = fw_mult * Constrain(0.0, ClutchCtrlNorm, 1.0);
if (coupling < 0.999999) { // are the separate calculations needed ?
// assume linear transfer
engine_d_omega =
(engine_torque - ThrusterTorque*coupling)/(ThrusterMoment*coupling + EngineMoment) * dt;
thruster_d_omega =
(engine_torque*coupling - ThrusterTorque)/(ThrusterMoment + EngineMoment*coupling) * dt;
EngineRPM += omega_to_rpm(engine_d_omega);
ThrusterRPM += omega_to_rpm(thruster_d_omega);
// simulate friction in clutch
coupling_sq = coupling*coupling;
EngineRPM = (1.0-coupling_sq) * EngineRPM + coupling_sq * 0.02 * (49.0*EngineRPM + ThrusterRPM);
ThrusterRPM = (1.0-coupling_sq) * ThrusterRPM + coupling_sq * 0.02 * (EngineRPM + 49.0*ThrusterRPM);
// enforce equal rpm
if ( fabs(EngineRPM-ThrusterRPM) < 1e-3 ) {
EngineRPM = ThrusterRPM = 0.5 * (EngineRPM+ThrusterRPM);
}
} else {
d_omega = (engine_torque - ThrusterTorque)/(ThrusterMoment + EngineMoment) * dt;
EngineRPM = ThrusterRPM += omega_to_rpm(d_omega);
}
// nothing will turn backward
if (EngineRPM < 0.0 ) EngineRPM = 0.0;
if (ThrusterRPM < 0.0 ) ThrusterRPM = 0.0;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bool FGTransmission::BindModel(int num)
{
string property_name, base_property_name;
base_property_name = CreateIndexedPropertyName("propulsion/engine", num);
property_name = base_property_name + "/brake-ctrl-norm";
PropertyManager->Tie( property_name.c_str(), this, &FGTransmission::GetBrakeCtrl, &FGTransmission::SetBrakeCtrl);
property_name = base_property_name + "/free-wheel-transmission";
PropertyManager->Tie( property_name.c_str(), this, &FGTransmission::GetFreeWheelTransmission);
return true;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Constructor
@ -78,7 +186,7 @@ FGRotor::FGRotor(FGFDMExec *exec, Element* rotor_element, int num)
rho(0.002356), // environment
Radius(0.0), BladeNum(0), // configuration parameters
Sense(1.0), NominalRPM(0.0), MinimalRPM(0.0), MaximalRPM(0.0),
ExternalRPM(0), RPMdefinition(0), ExtRPMsource(NULL),
ExternalRPM(0), RPMdefinition(0), ExtRPMsource(NULL), SourceGearRatio(1.0),
BladeChord(0.0), LiftCurveSlope(0.0), BladeTwist(0.0), HingeOffset(0.0),
BladeFlappingMoment(0.0), BladeMassMoment(0.0), PolarMoment(0.0),
InflowLag(0.0), TipLossB(0.0),
@ -93,9 +201,8 @@ FGRotor::FGRotor(FGFDMExec *exec, Element* rotor_element, int num)
theta_downwash(0.0), phi_downwash(0.0),
ControlMap(eMainCtrl), // control
CollectiveCtrl(0.0), LateralCtrl(0.0), LongitudinalCtrl(0.0),
BrakeCtrlNorm(0.0), MaxBrakePower(0.0),
FreeWheelPresent(0), FreeWheelThresh(0.0), // free-wheeling-unit (FWU)
FreeWheelTransmission(0.0)
Transmission(NULL), // interaction with engine
EngineRPM(0.0), MaxBrakePower(0.0), GearLoss(0.0), GearMoment(0.0)
{
FGColumnVector3 location(0.0, 0.0, 0.0), orientation(0.0, 0.0, 0.0);
Element *thruster_element;
@ -158,12 +265,58 @@ FGRotor::FGRotor(FGFDMExec *exec, Element* rotor_element, int num)
// ExternalRPM -- is the RPM dictated ?
if (rotor_element->FindElement("ExternalRPM")) {
ExternalRPM = 1;
SourceGearRatio = 1.0;
RPMdefinition = (int) rotor_element->FindElementValueAsNumber("ExternalRPM");
int rdef = RPMdefinition;
if (RPMdefinition>=0) {
// avoid ourself and (still) unknown engines.
if (!exec->GetPropulsion()->GetEngine(RPMdefinition) || RPMdefinition==num) {
RPMdefinition = -1;
} else {
FGThruster *tr = exec->GetPropulsion()->GetEngine(RPMdefinition)->GetThruster();
SourceGearRatio = tr->GetGearRatio();
// cout << "# got sources' GearRatio: " << SourceGearRatio << endl;
}
}
if (RPMdefinition != rdef) {
cerr << "# discarded given RPM source (" << rdef << ") and switched to external control (-1)." << endl;
}
}
// configure the rotor parameters
Configure(rotor_element);
// configure the transmission parameters
if (!ExternalRPM) {
Transmission = new FGTransmission(exec, num);
Transmission->SetMaxBrakePower(MaxBrakePower);
if (rotor_element->FindElement("gearloss")) {
GearLoss = rotor_element->FindElementValueAsNumberConvertTo("gearloss","HP");
GearLoss *= hptoftlbssec;
}
if (GearLoss<1e-6) { // TODO, allow 0 ?
double ehp = 0.5 * BladeNum*BladeChord*Radius*Radius; // guess engine power
//cout << "# guessed engine power: " << ehp << endl;
GearLoss = 0.0025 * ehp * hptoftlbssec;
}
Transmission->SetEngineFriction(GearLoss);
// The MOI sensed behind the gear ( MOI_engine*sqr(GearRatio) ).
if (rotor_element->FindElement("gearmoment")) {
GearMoment = rotor_element->FindElementValueAsNumberConvertTo("gearmoment","SLUG*FT2");
}
if (GearMoment<1e-2) { // TODO, need better check for lower limit
GearMoment = 0.1*PolarMoment;
}
Transmission->SetEngineMoment(GearMoment);
Transmission->SetThrusterMoment(PolarMoment);
}
// shaft representation - a rather simple transform,
// but using a matrix is safer.
TboToHsr.InitMatrix( 0.0, 0.0, 1.0,
@ -175,9 +328,6 @@ FGRotor::FGRotor(FGFDMExec *exec, Element* rotor_element, int num)
// calculation would cause jumps too. 1Hz seems sufficient.
damp_hagl = Filter(1.0, dt);
// avoid too abrupt changes in power transmission
FreeWheelLag = Filter(200.0,dt);
// enable import-export
BindModel();
@ -188,6 +338,7 @@ FGRotor::FGRotor(FGFDMExec *exec, Element* rotor_element, int num)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGRotor::~FGRotor(){
if (Transmission) delete Transmission;
Debug(1);
}
@ -306,17 +457,6 @@ void FGRotor::Configure(Element* rotor_element)
GroundEffectExp = ConfigValue(rotor_element, "groundeffectexp", 0.0);
GroundEffectShift = ConfigValueConv(rotor_element, "groundeffectshift", 0.0, "FT");
// handle optional free-wheeling-unit (FWU)
FreeWheelPresent = 0;
FreeWheelTransmission = 1.0;
if (rotor_element->FindElement("freewheelthresh")) {
FreeWheelThresh = rotor_element->FindElementValueAsNumber("freewheelthresh");
if (FreeWheelThresh > 1.0) {
FreeWheelPresent = 1;
FreeWheelTransmission = 0.0;
}
}
// precalc often used powers
R[0]=1.0; R[1]=Radius; R[2]=R[1]*R[1]; R[3]=R[2]*R[1]; R[4]=R[3]*R[1];
B[0]=1.0; B[1]=TipLossB; B[2]=B[1]*B[1]; B[3]=B[2]*B[1]; B[4]=B[3]*B[1];
@ -564,7 +704,7 @@ FGColumnVector3 FGRotor::body_moments(double a_ic, double b_ic)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGRotor::CalcStatePart1(void)
void FGRotor::CalcRotorState(void)
{
double A_IC; // lateral (roll) control in radians
double B_IC; // longitudinal (pitch) control in radians
@ -583,7 +723,7 @@ void FGRotor::CalcStatePart1(void)
// handle RPM requirements, calc omega.
if (ExternalRPM && ExtRPMsource) {
RPM = ExtRPMsource->getDoubleValue() / GearRatio;
RPM = ExtRPMsource->getDoubleValue() * ( SourceGearRatio / GearRatio );
}
// MinimalRPM is always >= 1. MaximalRPM is always >= NominalRPM
@ -632,64 +772,24 @@ void FGRotor::CalcStatePart1(void)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGRotor::CalcStatePart2(double PowerAvailable)
{
if (! ExternalRPM) {
// calculate new RPM
double ExcessTorque = PowerAvailable / Omega;
double deltaOmega = ExcessTorque / PolarMoment * in.TotalDeltaT;
RPM += deltaOmega/(2.0*M_PI) * 60.0;
}
RPM = Constrain(MinimalRPM, RPM, MaximalRPM); // trim again
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Simulation of a free-wheeling-unit (FWU). Might need improvements.
void FGRotor::calc_freewheel_state(double p_source, double p_load) {
// engine is off/detached, release.
if (p_source<1e-3) {
FreeWheelTransmission = 0.0;
return;
}
// engine is driving the rotor, engage.
if (p_source >= p_load) {
FreeWheelTransmission = 1.0;
return;
}
// releases if engine is detached, but stays calm if
// the load changes due to rotor dynamics.
if (p_source > 0.0 && p_load/(p_source+0.1) > FreeWheelThresh ) {
FreeWheelTransmission = 0.0;
return;
}
return;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
double FGRotor::Calculate(double EnginePower)
{
double FWmult = 1.0;
double DeltaPower;
CalcStatePart1();
CalcRotorState();
PowerRequired = Torque * Omega + BrakeCtrlNorm * MaxBrakePower;
if (! ExternalRPM) {
Transmission->SetClutchCtrlNorm(ClutchCtrlNorm);
if (FreeWheelPresent) {
calc_freewheel_state(EnginePower * ClutchCtrlNorm, PowerRequired);
FWmult = FreeWheelLag.execute(FreeWheelTransmission);
// the RPM values are handled inside Transmission
Transmission->Calculate(EnginePower, Torque, in.TotalDeltaT);
EngineRPM = Transmission->GetEngineRPM() * GearRatio;
RPM = Transmission->GetThrusterRPM();
} else {
EngineRPM = RPM * GearRatio;
}
DeltaPower = EnginePower * ClutchCtrlNorm * FWmult - PowerRequired;
CalcStatePart2(DeltaPower);
RPM = Constrain(MinimalRPM, RPM, MaximalRPM); // trim again
return Thrust;
}
@ -767,22 +867,17 @@ bool FGRotor::BindModel(void)
PropertyManager->Tie( property_name.c_str(), this, &FGRotor::GetLongitudinalCtrl, &FGRotor::SetLongitudinalCtrl);
}
property_name = base_property_name + "/brake-ctrl-norm";
PropertyManager->Tie( property_name.c_str(), this, &FGRotor::GetBrakeCtrl, &FGRotor::SetBrakeCtrl);
property_name = base_property_name + "/free-wheel-transmission";
PropertyManager->Tie( property_name.c_str(), this, &FGRotor::GetFreeWheelTransmission);
if (ExternalRPM) {
if (RPMdefinition == -1) {
property_name = base_property_name + "/x-rpm-dict";
ExtRPMsource = PropertyManager->GetNode(property_name, true);
} else if (RPMdefinition >= 0 && RPMdefinition != EngineNum) {
string ipn = CreateIndexedPropertyName("propulsion/engine", RPMdefinition);
property_name = ipn + "/engine-rpm";
property_name = ipn + "/rotor-rpm";
ExtRPMsource = PropertyManager->GetNode(property_name, false);
if (! ExtRPMsource) {
cerr << "# Warning: Engine number " << EngineNum << "." << endl;
cerr << "# No 'engine-rpm' property found for engine " << RPMdefinition << "." << endl;
cerr << "# No 'rotor-rpm' property found for engine " << RPMdefinition << "." << endl;
cerr << "# Please check order of engine definitons." << endl;
}
} else {
@ -860,7 +955,7 @@ void FGRotor::Debug(int from)
if (RPMdefinition == -1) {
cout << " RPM is controlled externally" << endl;
} else {
cout << " RPM source set to engine " << RPMdefinition << endl;
cout << " RPM source set to thruster " << RPMdefinition << endl;
}
}
@ -876,6 +971,8 @@ void FGRotor::Debug(int from)
cout << " Lock Number = " << LockNumberByRho * 0.002356 << " (SL)" << endl;
cout << " Solidity = " << Solidity << endl;
cout << " Max Brake Power = " << MaxBrakePower/hptoftlbssec << " HP" << endl;
cout << " Gear Loss = " << GearLoss/hptoftlbssec << " HP" << endl;
cout << " Gear Moment = " << GearMoment << endl;
switch (ControlMap) {
case eTailCtrl: ControlMapName = "Tail Rotor"; break;
@ -884,12 +981,6 @@ void FGRotor::Debug(int from)
}
cout << " Control Mapping = " << ControlMapName << endl;
if (FreeWheelPresent) {
cout << " Free Wheel Threshold = " << FreeWheelThresh << endl;
} else {
cout << " No FWU present" << endl;
}
}
}
if (debug_lvl & 2 ) { // Instantiation/Destruction notification

View file

@ -46,7 +46,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_ROTOR "$Id: FGRotor.h,v 1.11 2011/09/24 14:26:46 jentron Exp $"
#define ID_ROTOR "$Id: FGRotor.h,v 1.12 2011/10/15 21:30:28 jentron Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@ -80,6 +80,8 @@ CLASS DOCUMENTATION
<inflowlag> {number} </inflowlag>
<tiplossfactor> {number} </tiplossfactor>
<maxbrakepower unit="{POWER}"> {number} </maxbrakepower>
<gearloss unit="{POWER}"> {number} </gearloss>
<gearmoment unit="{MOMENT}"> {number} </gearmoment>
<controlmap> {MAIN|TAIL|TANDEM} </controlmap>
<ExternalRPM> {number} </ExternalRPM>
@ -120,13 +122,18 @@ CLASS DOCUMENTATION
responses (typical values for main rotor: 0.1 - 0.2 s).
\<tiplossfactor> - Tip-loss factor. The Blade fraction that produces lift.
Value usually ranges between 0.95 - 1.0, optional (B).
\<maxbrakepower> - Rotor brake, 20-30 hp should work for a mid size helicopter.
\<gearloss> - Friction in gear, 0.2% to 3% of the engine power, optional (see notes).
\<gearmoment> - Approximation for the moment of inertia of the gear (and engine),
defaults to 0.1 * polarmoment, optional.
\<controlmap> - Defines the control inputs used (see notes).
\<ExternalRPM> - Links the rotor to another rotor, or an user controllable property.
Experimental properties
\<groundeffectexp> - Exponent for ground effect approximation. Values usually range from 0.04
for large rotors to 0.1 for smaller ones. As a rule of thumb the effect
vanishes at a height 2-3 times the rotor diameter.
@ -134,10 +141,6 @@ CLASS DOCUMENTATION
Omitting or setting to 0.0 disables the effect calculation.
\<groundeffectshift> - Further adjustment of ground effect, approx. hub height or slightly above.
\<freewheelthresh> - Ratio of thruster power to engine power. The FWU will release when above
the threshold. The value shouldn't be too close to 1.0, 1.5 seems ok.
0 disables this feature, which is also the default.
</pre>
<h3>Notes:</h3>
@ -154,7 +157,7 @@ CLASS DOCUMENTATION
<tt>propulsion/engine[x]/longitudinal-ctrl-rad</tt>.</li>
<li> The tail collective (aka antitorque, aka pedal) control input. Read from
<tt>propulsion/engine[x]/antitorque-ctrl-rad</tt> or
<tt>propulsion/engine[x]/tail-collective-ctrl-rad</tt>.</li>
<tt>propulsion/engine[x]/tail-collective-ctrl-rad</tt>.</li>
</ul>
@ -178,9 +181,23 @@ CLASS DOCUMENTATION
<h4>- Engine issues -</h4>
In order to keep the rotor speed constant, use of a RPM-Governor system is
In order to keep the rotor/engine speed constant, use of a RPM-Governor system is
encouraged (see examples).
In case the model requires the manual use of a clutch the <tt>\<gearloss\></tt>
property might need attention.<ul>
<li> Electrical: here the gear-loss should be rather large to keep the engine
controllable when the clutch is open (although full throttle might still make it
spin away).</li>
<li> Piston: this engine model already has some internal friction loss and also
looses power if it spins too high. Here the gear-loss could be set to 0.25%
of the engine power (which is also the approximated default).</li>
<li> Turboprop: Here the default value might be a bit too small. Also it's advisable
to adjust the power table for rpm values that are far beyond the nominal value.</li>
</ul>
<h4>- Development hints -</h4>
Setting <tt>\<ExternalRPM> -1 \</ExternalRPM></tt> the rotor's RPM is controlled by
@ -205,7 +222,7 @@ CLASS DOCUMENTATION
</dl>
@author Thomas Kreitler
@version $Id: FGRotor.h,v 1.11 2011/09/24 14:26:46 jentron Exp $
@version $Id: FGRotor.h,v 1.12 2011/10/15 21:30:28 jentron Exp $
*/
@ -214,6 +231,57 @@ CLASS DOCUMENTATION
CLASS DECLARATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
class FGTransmission : public FGJSBBase {
public:
FGTransmission(FGFDMExec *exec, int num);
~FGTransmission();
void Calculate(double EnginePower, double ThrusterTorque, double dt);
void SetMaxBrakePower(double x) {MaxBrakePower=x;}
double GetMaxBrakePower() const {return MaxBrakePower;}
void SetEngineFriction(double x) {EngineFriction=x;}
double GetEngineFriction() const {return EngineFriction;}
void SetEngineMoment(double x) {EngineMoment=x;}
double GetEngineMoment() const {return EngineMoment;}
void SetThrusterMoment(double x) {ThrusterMoment=x;}
double GetThrusterMoment() const {return ThrusterMoment;}
double GetFreeWheelTransmission() const {return FreeWheelTransmission;}
double GetEngineRPM() {return EngineRPM;}
double GetThrusterRPM() {return ThrusterRPM;}
double GetBrakeCtrl() const {return BrakeCtrlNorm;}
void SetBrakeCtrl(double x) {BrakeCtrlNorm=x;}
void SetClutchCtrlNorm(double x) {ClutchCtrlNorm=x;}
private:
bool BindModel(int num);
// void Debug(int from);
inline double omega_to_rpm(double w) {return w * 9.54929658551372014613302580235;} // omega/(2.0*PI) * 60.0
inline double rpm_to_omega(double r) {return r * .104719755119659774615421446109;} // (rpm/60.0)*2.0*PI
Filter FreeWheelLag;
double FreeWheelTransmission; // state, 0: free, 1:locked
double ThrusterMoment;
double EngineMoment; // estimated MOI of gear and engine, influences acceleration
double EngineFriction; // estimated friction in gear and possibly engine
double ClutchCtrlNorm; // also in FGThruster.h
double BrakeCtrlNorm;
double MaxBrakePower;
double EngineRPM;
double ThrusterRPM;
FGPropertyManager* PropertyManager;
};
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
class FGRotor : public FGThruster {
enum eCtrlMapping {eMainCtrl=0, eTailCtrl, eTandemCtrl};
@ -241,8 +309,8 @@ public:
void SetRPM(double rpm) { RPM = rpm; }
/// Retrieves the RPMs of the Engine, as seen from this rotor.
double GetEngineRPM(void) const { return GearRatio*RPM; } // bit of a hack.
void SetEngineRPM(double rpm) { RPM = rpm/GearRatio; } // bit of a hack.
double GetEngineRPM(void) const {return EngineRPM;} //{ return GearRatio*RPM; }
void SetEngineRPM(double rpm) {EngineRPM = rpm;} //{ RPM = rpm/GearRatio; }
/// Tells the rotor's gear ratio, usually the engine asks for this.
double GetGearRatio(void) { return GearRatio; }
/// Retrieves the thrust of the rotor.
@ -267,8 +335,6 @@ public:
double GetCT(void) const { return C_T; }
/// Retrieves the torque
double GetTorque(void) const { return Torque; }
/// Retrieves the state of the free-wheeling-unit (FWU).
double GetFreeWheelTransmission(void) const { return FreeWheelTransmission; }
/// Downwash angle - currently only valid for a rotor that spins horizontally
double GetThetaDW(void) const { return theta_downwash; }
@ -281,8 +347,6 @@ public:
double GetLateralCtrl(void) const { return LateralCtrl; }
/// Retrieves the longitudinal control input in radians.
double GetLongitudinalCtrl(void) const { return LongitudinalCtrl; }
/// Retrieves the normalized brake control input.
double GetBrakeCtrl(void) const { return BrakeCtrlNorm; }
/// Sets the collective control input in radians.
void SetCollectiveCtrl(double c) { CollectiveCtrl = c; }
@ -290,8 +354,6 @@ public:
void SetLateralCtrl(double c) { LateralCtrl = c; }
/// Sets the longitudinal control input in radians.
void SetLongitudinalCtrl(double c) { LongitudinalCtrl = c; }
/// Sets the normalized brake control input.
void SetBrakeCtrl(double c) { BrakeCtrlNorm = c; }
// Stubs. Only main rotor RPM is returned
string GetThrusterLabels(int id, string delimeter);
@ -308,9 +370,7 @@ private:
void Configure(Element* rotor_element);
// true entry points
void CalcStatePart1(void);
void CalcStatePart2(double PowerAvailable);
void CalcRotorState(void);
// rotor dynamics
void calc_flow_and_thrust(double theta_0, double Uw, double Ww, double flow_scale = 1.0);
@ -319,8 +379,6 @@ private:
void calc_drag_and_side_forces(double theta_0);
void calc_torque(double theta_0);
void calc_freewheel_state(double pwr_in, double pwr_out);
// transformations
FGColumnVector3 hub_vel_body2ca( const FGColumnVector3 &uvw, const FGColumnVector3 &pqr,
double a_ic = 0.0 , double b_ic = 0.0 );
@ -341,6 +399,7 @@ private:
double Radius;
int BladeNum;
// rpm control
double Sense;
double NominalRPM;
double MinimalRPM;
@ -348,6 +407,7 @@ private:
int ExternalRPM;
int RPMdefinition;
FGPropertyManager* ExtRPMsource;
double SourceGearRatio;
double BladeChord;
double LiftCurveSlope;
@ -400,14 +460,12 @@ private:
double LateralCtrl;
double LongitudinalCtrl;
double BrakeCtrlNorm, MaxBrakePower;
// free-wheeling-unit (FWU)
int FreeWheelPresent; // 'installed' or not
double FreeWheelThresh; // when to release
Filter FreeWheelLag;
double FreeWheelTransmission; // state, 0: free, 1:locked
// interaction with engine
FGTransmission *Transmission;
double EngineRPM;
double MaxBrakePower;
double GearLoss;
double GearMoment;
};

View file

@ -1,12 +0,0 @@
noinst_LIBRARIES = libPropulsion.a
libPropulsion_a_SOURCES = \
FGElectric.cpp FGEngine.cpp FGForce.cpp FGNozzle.cpp \
FGPiston.cpp FGPropeller.cpp FGRocket.cpp FGRotor.cpp \
FGTank.cpp FGThruster.cpp FGTurbine.cpp FGTurboProp.cpp
noinst_HEADERS = FGElectric.h FGEngine.h FGForce.h FGNozzle.h FGPiston.h \
FGPropeller.h FGRocket.h FGRotor.h FGTank.h FGThruster.h \
FGTurbine.h FGTurboProp.h
INCLUDES = -I$(top_srcdir)/src/FDM/JSBSim

View file

@ -1,40 +0,0 @@
EXTRA_DIST = \
c172_aero.c c172_aero.h \
c172_engine.c \
c172_gear.c \
c172_init.c \
ls_trim.c \
navion_init.h \
basic_init.c basic_init.h basic_aero.c basic_aero.h basic_engine.c basic_gear.c \
uiuc_aero.c
AIRCRAFT_MODEL = c172_aero.c c172_engine.c c172_gear.c c172_init.c \
basic_init.c basic_init.h basic_aero.c basic_aero.h basic_engine.c basic_gear.c \
navion_init.h navion_aero.c navion_engine.c \
navion_gear.c navion_init.c uiuc_aero.c \
cherokee_aero.c cherokee_engine.c cherokee_gear.c \
cherokee_init.c
noinst_LIBRARIES = libLaRCsim.a
libLaRCsim_a_SOURCES = \
LaRCsim.cxx LaRCsim.hxx \
LaRCsimIC.cxx LaRCsimIC.hxx \
IO360.cxx IO360.hxx \
atmos_62.c atmos_62.h \
default_model_routines.c default_model_routines.h \
ls_accel.c ls_accel.h \
ls_aux.c ls_aux.h \
ls_cockpit.h ls_constants.h ls_generic.h \
ls_geodesy.c ls_geodesy.h \
ls_gravity.c ls_gravity.h \
ls_init.c ls_init.h \
ls_matrix.c ls_matrix.h \
ls_model.c ls_model.h \
ls_sim_control.h \
ls_step.c ls_step.h \
ls_sym.h ls_types.h \
$(AIRCRAFT_MODEL) \
ls_interface.c ls_interface.h
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src

View file

@ -1,21 +0,0 @@
if ENABLE_SP_FDM
SP_DIR = SP
else
SP_DIR =
endif
SUBDIRS = JSBSim LaRCsim UIUCModel YASim \
$(SP_DIR) ExternalNet ExternalPipe
noinst_LIBRARIES = libFlight.a
libFlight_a_SOURCES = \
flight.cxx flight.hxx \
fdm_shell.cxx fdm_shell.hxx \
flightProperties.cxx flightProperties.hxx \
TankProperties.cxx TankProperties.hxx \
groundcache.cxx groundcache.hxx \
UFO.cxx UFO.hxx \
NullFDM.cxx NullFDM.hxx
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src -I$(top_srcdir)/src/FDM/JSBSim

View file

@ -1,11 +0,0 @@
noinst_LIBRARIES = libSPFDM.a
libSPFDM_a_SOURCES = \
ADA.cxx ADA.hxx \
ACMS.cxx ACMS.hxx \
Balloon.cxx Balloon.h \
BalloonSim.cpp BalloonSim.h \
MagicCarpet.cxx MagicCarpet.hxx
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src

View file

@ -1,85 +0,0 @@
noinst_LIBRARIES = libUIUCModel.a
libUIUCModel_a_SOURCES = \
uiuc_1DdataFileReader.cpp uiuc_1DdataFileReader.h \
uiuc_1Dinterpolation.cpp uiuc_1Dinterpolation.h \
uiuc_2DdataFileReader.cpp uiuc_2DdataFileReader.h \
uiuc_2Dinterpolation.cpp uiuc_2Dinterpolation.h \
uiuc_3Dinterpolation.cpp uiuc_3Dinterpolation.h \
uiuc_aerodeflections.cpp uiuc_aerodeflections.h \
uiuc_aircraft.h \
uiuc_alh_ap.cpp uiuc_alh_ap.h \
uiuc_auto_pilot.cpp uiuc_auto_pilot.h \
uiuc_betaprobe.cpp uiuc_betaprobe.h \
uiuc_coef_drag.cpp uiuc_coef_drag.h \
uiuc_coef_lift.cpp uiuc_coef_lift.h \
uiuc_coef_pitch.cpp uiuc_coef_pitch.h \
uiuc_coef_roll.cpp uiuc_coef_roll.h \
uiuc_coef_sideforce.cpp uiuc_coef_sideforce.h \
uiuc_coef_yaw.cpp uiuc_coef_yaw.h \
uiuc_coefficients.cpp uiuc_coefficients.h \
uiuc_controlInput.cpp uiuc_controlInput.h \
uiuc_convert.cpp uiuc_convert.h \
uiuc_engine.cpp uiuc_engine.h \
uiuc_flapdata.cpp uiuc_flapdata.h \
uiuc_find_position.cpp uiuc_find_position.h \
uiuc_fog.cpp uiuc_fog.h \
uiuc_gear.cpp uiuc_gear.h\
uiuc_get_flapper.cpp uiuc_get_flapper.h \
uiuc_getwind.cpp uiuc_getwind.h \
uiuc_hh_ap.cpp uiuc_hh_ap.h \
uiuc_ice.cpp uiuc_ice.h \
uiuc_iceboot.cpp uiuc_iceboot.h \
uiuc_iced_nonlin.cpp uiuc_iced_nonlin.h \
uiuc_icing_demo.cpp uiuc_icing_demo.h \
uiuc_initializemaps.cpp uiuc_initializemaps.h \
uiuc_map_CD.cpp uiuc_map_CD.h \
uiuc_map_CL.cpp uiuc_map_CL.h \
uiuc_map_CY.cpp uiuc_map_CY.h \
uiuc_map_Cm.cpp uiuc_map_Cm.h \
uiuc_map_Cn.cpp uiuc_map_Cn.h \
uiuc_map_Croll.cpp uiuc_map_Croll.h \
uiuc_map_controlSurface.cpp uiuc_map_controlSurface.h \
uiuc_map_engine.cpp uiuc_map_engine.h \
uiuc_map_fog.cpp uiuc_map_fog.h \
uiuc_map_geometry.cpp uiuc_map_geometry.h \
uiuc_map_ice.cpp uiuc_map_ice.h \
uiuc_map_gear.cpp uiuc_map_gear.h \
uiuc_map_init.cpp uiuc_map_init.h \
uiuc_map_keyword.cpp uiuc_map_keyword.h \
uiuc_map_mass.cpp uiuc_map_mass.h \
uiuc_map_misc.cpp uiuc_map_misc.h \
uiuc_map_record1.cpp uiuc_map_record1.h \
uiuc_map_record2.cpp uiuc_map_record2.h \
uiuc_map_record3.cpp uiuc_map_record3.h \
uiuc_map_record4.cpp uiuc_map_record4.h \
uiuc_map_record5.cpp uiuc_map_record5.h \
uiuc_map_record6.cpp uiuc_map_record6.h \
uiuc_menu.cpp uiuc_menu.h \
uiuc_menu_init.cpp uiuc_menu_init.h \
uiuc_menu_geometry.cpp uiuc_menu_geometry.h \
uiuc_menu_controlSurface.cpp uiuc_menu_controlSurface.h \
uiuc_menu_mass.cpp uiuc_menu_mass.h \
uiuc_menu_engine.cpp uiuc_menu_engine.h \
uiuc_menu_CD.cpp uiuc_menu_CD.h \
uiuc_menu_CL.cpp uiuc_menu_CL.h \
uiuc_menu_Cm.cpp uiuc_menu_Cm.h \
uiuc_menu_CY.cpp uiuc_menu_CY.h \
uiuc_menu_Croll.cpp uiuc_menu_Croll.h \
uiuc_menu_Cn.cpp uiuc_menu_Cn.h \
uiuc_menu_gear.cpp uiuc_menu_gear.h \
uiuc_menu_ice.cpp uiuc_menu_ice.h \
uiuc_menu_fog.cpp uiuc_menu_fog.h \
uiuc_menu_record.cpp uiuc_menu_record.h \
uiuc_menu_misc.cpp uiuc_menu_misc.h \
uiuc_menu_functions.cpp uiuc_menu_functions.h \
uiuc_pah_ap.cpp uiuc_pah_ap.h \
uiuc_parsefile.cpp uiuc_parsefile.h \
uiuc_rah_ap.cpp uiuc_rah_ap.h \
uiuc_recorder.cpp uiuc_recorder.h \
uiuc_warnings_errors.cpp uiuc_warnings_errors.h \
uiuc_wrapper.cpp uiuc_wrapper.h
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src

View file

@ -1,3 +1,8 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "Math.hpp"
#include "BodyEnvironment.hpp"
#include "RigidBody.hpp"

View file

@ -1,62 +0,0 @@
# Link the yasim executable against the individual object files rather
# than libYASim. The library references other stuff in FlightGear,
# and some linkers (Irix) do dependency checks per-library instead of
# per-object.
#
# I think that it's permissible to list the same source files more
# than once in a Makefile.am. Hopefully this doesn't break anything.
SHARED_SOURCE_FILES = \
Airplane.cpp Airplane.hpp \
Atmosphere.cpp Atmosphere.hpp \
BodyEnvironment.hpp \
ControlMap.cpp ControlMap.hpp \
FGFDM.cpp FGFDM.hpp \
Gear.cpp Gear.hpp \
Glue.cpp Glue.hpp \
Ground.cpp Ground.hpp \
Hitch.cpp Hitch.hpp \
Hook.cpp Hook.hpp \
Launchbar.cpp Launchbar.hpp \
Integrator.cpp Integrator.hpp \
Jet.cpp Jet.hpp \
Math.cpp Math.hpp \
Model.cpp Model.hpp \
PropEngine.cpp PropEngine.hpp \
Propeller.cpp Propeller.hpp \
Engine.hpp \
PistonEngine.cpp PistonEngine.hpp \
TurbineEngine.cpp TurbineEngine.hpp \
RigidBody.cpp RigidBody.hpp \
Rotor.cpp Rotor.hpp \
Rotorpart.cpp Rotorpart.hpp \
SimpleJet.cpp SimpleJet.hpp \
Surface.cpp Surface.hpp \
Thruster.cpp Thruster.hpp \
Vector.hpp \
Wing.cpp Wing.hpp \
Turbulence.cpp Turbulence.hpp
noinst_LIBRARIES = libYASim.a
libYASim_a_SOURCES = YASim.cxx YASim.hxx FGGround.cpp FGGround.hpp $(SHARED_SOURCE_FILES)
bin_PROGRAMS = yasim
noinst_PROGRAMS = proptest
yasim_SOURCES = yasim-test.cpp $(SHARED_SOURCE_FILES)
yasim_LDADD = -lsgxml -lsgprops -lsgdebug -lsgmisc -lsgstructure -lsgtiming $(base_LIBS)
proptest_SOURCES = proptest.cpp $(SHARED_SOURCE_FILES)
proptest_LDADD = -lsgxml -lsgprops -lsgdebug -lsgmisc -lsgstructure -lsgtiming $(base_LIBS)
if HAVE_FRAMEWORK_OSG
yasim_LDFLAGS = $(openthreads_FRAMEWORKS)
proptest_LDFLAGS = $(openthreads_FRAMEWORKS)
else
yasim_LDFLAGS = $(openthreads_LIBS)
proptest_LDFLAGS = $(openthreads_LIBS)
endif
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src

View file

@ -1,3 +1,8 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <simgear/debug/logstream.hxx>
#include "Math.hpp"

View file

@ -139,7 +139,14 @@ void YASim::init()
SGPath f(fgGetString("/sim/aircraft-dir"));
f.append(fgGetString("/sim/aero"));
f.concat(".xml");
readXML(f.str(), *_fdm);
try {
readXML(f.str(), *_fdm);
} catch (const sg_exception &e) {
SG_LOG(SG_GENERAL, SG_ALERT,
"Error reading YASim FDM: '" << f.str() << "'" << std::endl
<< e.getFormattedMessage());
throw e;
}
// Compile it into a real airplane, and tell the user what they got
a->compile();

View file

@ -43,12 +43,21 @@
#endif
#include <FDM/ExternalNet/ExternalNet.hxx>
#include <FDM/ExternalPipe/ExternalPipe.hxx>
#ifdef ENABLE_JSBSIM
#include <FDM/JSBSim/JSBSim.hxx>
#endif
#ifdef ENABLE_LARCSIM
#include <FDM/LaRCsim/LaRCsim.hxx>
#endif
#include <FDM/UFO.hxx>
#include <FDM/NullFDM.hxx>
#include <FDM/YASim/YASim.hxx>
#ifdef ENABLE_YASIM
#include <FDM/YASim/YASim.hxx>
#endif
/*
* Evil global variable required by Network/FGNative,
@ -194,12 +203,77 @@ void FDMShell::createImplementation()
double dt = 1.0 / fgGetInt("/sim/model-hz");
string model = fgGetString("/sim/flight-model");
if ( model == "larcsim" ) {
if ( model == "ufo" ) {
_impl = new FGUFO( dt );
} else if ( model == "external" ) {
// external is a synonym for "--fdm=null" and is
// maintained here for backwards compatibility
_impl = new FGNullFDM( dt );
} else if ( model.find("network") == 0 ) {
string host = "localhost";
int port1 = 5501;
int port2 = 5502;
int port3 = 5503;
string net_options = model.substr(8);
string::size_type begin, end;
begin = 0;
// host
end = net_options.find( ",", begin );
if ( end != string::npos ) {
host = net_options.substr(begin, end - begin);
begin = end + 1;
}
// port1
end = net_options.find( ",", begin );
if ( end != string::npos ) {
port1 = atoi( net_options.substr(begin, end - begin).c_str() );
begin = end + 1;
}
// port2
end = net_options.find( ",", begin );
if ( end != string::npos ) {
port2 = atoi( net_options.substr(begin, end - begin).c_str() );
begin = end + 1;
}
// port3
end = net_options.find( ",", begin );
if ( end != string::npos ) {
port3 = atoi( net_options.substr(begin, end - begin).c_str() );
begin = end + 1;
}
_impl = new FGExternalNet( dt, host, port1, port2, port3 );
} else if ( model.find("pipe") == 0 ) {
// /* old */ string pipe_path = model.substr(5);
// /* old */ _impl = new FGExternalPipe( dt, pipe_path );
string pipe_path = "";
string pipe_protocol = "";
string pipe_options = model.substr(5);
string::size_type begin, end;
begin = 0;
// pipe file path
end = pipe_options.find( ",", begin );
if ( end != string::npos ) {
pipe_path = pipe_options.substr(begin, end - begin);
begin = end + 1;
}
// protocol (last option)
pipe_protocol = pipe_options.substr(begin);
_impl = new FGExternalPipe( dt, pipe_path, pipe_protocol );
} else if ( model == "null" ) {
_impl = new FGNullFDM( dt );
}
#ifdef ENABLE_LARCSIM
else if ( model == "larcsim" ) {
_impl = new FGLaRCsim( dt );
} else if ( model == "jsb" ) {
}
#endif
#ifdef ENABLE_JSBSIM
else if ( model == "jsb" ) {
_impl = new FGJSBsim( dt );
}
#endif
#ifdef ENABLE_SP_FDM
} else if ( model == "ada" ) {
else if ( model == "ada" ) {
_impl = new FGADA( dt );
} else if ( model == "acms" ) {
_impl = new FGACMS( dt );
@ -207,68 +281,14 @@ void FDMShell::createImplementation()
_impl = new FGBalloonSim( dt );
} else if ( model == "magic" ) {
_impl = new FGMagicCarpet( dt );
}
#endif
} else if ( model == "ufo" ) {
_impl = new FGUFO( dt );
} else if ( model == "external" ) {
// external is a synonym for "--fdm=null" and is
// maintained here for backwards compatibility
_impl = new FGNullFDM( dt );
} else if ( model.find("network") == 0 ) {
string host = "localhost";
int port1 = 5501;
int port2 = 5502;
int port3 = 5503;
string net_options = model.substr(8);
string::size_type begin, end;
begin = 0;
// host
end = net_options.find( ",", begin );
if ( end != string::npos ) {
host = net_options.substr(begin, end - begin);
begin = end + 1;
}
// port1
end = net_options.find( ",", begin );
if ( end != string::npos ) {
port1 = atoi( net_options.substr(begin, end - begin).c_str() );
begin = end + 1;
}
// port2
end = net_options.find( ",", begin );
if ( end != string::npos ) {
port2 = atoi( net_options.substr(begin, end - begin).c_str() );
begin = end + 1;
}
// port3
end = net_options.find( ",", begin );
if ( end != string::npos ) {
port3 = atoi( net_options.substr(begin, end - begin).c_str() );
begin = end + 1;
}
_impl = new FGExternalNet( dt, host, port1, port2, port3 );
} else if ( model.find("pipe") == 0 ) {
// /* old */ string pipe_path = model.substr(5);
// /* old */ _impl = new FGExternalPipe( dt, pipe_path );
string pipe_path = "";
string pipe_protocol = "";
string pipe_options = model.substr(5);
string::size_type begin, end;
begin = 0;
// pipe file path
end = pipe_options.find( ",", begin );
if ( end != string::npos ) {
pipe_path = pipe_options.substr(begin, end - begin);
begin = end + 1;
}
// protocol (last option)
pipe_protocol = pipe_options.substr(begin);
_impl = new FGExternalPipe( dt, pipe_path, pipe_protocol );
} else if ( model == "null" ) {
_impl = new FGNullFDM( dt );
} else if ( model == "yasim" ) {
#ifdef ENABLE_YASIM
else if ( model == "yasim" ) {
_impl = new YASim( dt );
} else {
}
#endif
else {
throw sg_exception(string("Unrecognized flight model '") + model
+ "', cannot init flight dynamics model.");
}

View file

@ -1,38 +0,0 @@
noinst_LIBRARIES = libGUI.a
noinst_PROGRAMS = layout-test
if HAVE_FRAMEWORK_PLIB
layout_test_PLIB_FW = $(plib_FRAMEWORK)
else
layout_test_PLIB_LIBS = -lplibpw -lplibpu -lplibfnt -lplibul
endif
if HAVE_FRAMEWORK_OSG
layout_test_OSG_LIBS = $(openthreads_FRAMEWORK)
else
layout_test_OSG_LIBS = $(openthreads_LIBS)
endif
libGUI_a_SOURCES = \
new_gui.cxx new_gui.hxx \
dialog.cxx dialog.hxx \
menubar.cxx menubar.hxx \
gui.cxx gui.h gui_funcs.cxx \
fonts.cxx \
AirportList.cxx AirportList.hxx \
property_list.cxx property_list.hxx \
layout.cxx layout-props.cxx layout.hxx \
SafeTexFont.cxx SafeTexFont.hxx \
WaypointList.cxx WaypointList.hxx \
MapWidget.cxx MapWidget.hxx
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src
layout_test_SOURCES = layout-test.cxx
layout_test_LDADD = libGUI.a \
-lsgprops -lsgdebug -lsgstructure -lsgmisc -lsgxml -lsgtiming \
$(layout_test_PLIB_LIBS) $(opengl_LIBS)
# mainly for Macs
layout_test_LDFLAGS = $(layout_test_PLIB_FW) $(layout_test_OSG_LIBS)

View file

@ -374,7 +374,7 @@ int MapData::_fontDescender = 0;
///////////////////////////////////////////////////////////////////////////
const int MAX_ZOOM = 16;
const int MAX_ZOOM = 12;
const int SHOW_DETAIL_ZOOM = 8;
const int CURSOR_PAN_STEP = 32;
@ -403,11 +403,13 @@ MapWidget::~MapWidget()
void MapWidget::setProperty(SGPropertyNode_ptr prop)
{
_root = prop;
int zoom = _root->getBoolValue("zoom", -1);
int zoom = _root->getIntValue("zoom", -1);
if (zoom < 0) {
_root->setIntValue("zoom", 6); // default zoom
}
// expose MAX_ZOOM to the UI
_root->setIntValue("max-zoom", MAX_ZOOM);
_root->setBoolValue("centre-on-aircraft", true);
_root->setBoolValue("draw-data", false);
_root->setBoolValue("magnetic-headings", true);
@ -515,15 +517,6 @@ int MapWidget::zoom() const
}
void MapWidget::zoomIn()
{
if (zoom() <= 0) {
return;
}
_root->setIntValue("zoom", zoom() - 1);
}
void MapWidget::zoomOut()
{
if (zoom() >= MAX_ZOOM) {
return;
@ -532,6 +525,15 @@ void MapWidget::zoomOut()
_root->setIntValue("zoom", zoom() + 1);
}
void MapWidget::zoomOut()
{
if (zoom() <= 0) {
return;
}
_root->setIntValue("zoom", zoom() - 1);
}
void MapWidget::draw(int dx, int dy)
{
_aircraft = SGGeod::fromDeg(fgGetDouble("/position/longitude-deg"),
@ -561,7 +563,7 @@ void MapWidget::draw(int dx, int dy)
_upHeading = 0.0;
}
_cachedZoom = zoom();
_cachedZoom = MAX_ZOOM - zoom();
SGGeod topLeft = unproject(SGVec2d(_width/2, _height/2));
// compute draw range, including a fudge factor for ILSs and other 'long'
// symbols

Some files were not shown because too many files have changed in this diff Show more