JSBSim does have an integrator component, as you may know. This is the kind of thing (INS) that the JSBSim components were designed to support, and I'd like to see an INS inj our systems/ folder.
Jon
<inslist><!-- inslist needed because without it there's an error -->
<ins name="left">
<drift-rate>1.7</drift-rate>
</ins>
<ins name="center">
<drift-rate>1.7</drift-rate>
</ins>
<ins name="right">
<drift-rate>1.7</drift-rate>
</ins>
</inslist>
flameout wrote:multiple unit and mixing support, radio updating (various types, such as DME/DME and radial/DME,)
/instrumentation/in-range-dme-stations
/instrumentation/in-range-vor-stations
/instrumentation/in-range-vortac-stations
/instrumentation/in-range-ndb-stations
inslist needed because without it there's an error
<?xml version="1.0"?>
<PropertyList>
<ins>
<name>left</name>
<drift-rate>1.7</drift-rate>
</ins>
<ins>
<name>center</name>
<drift-rate>1.7</drift-rate>
</ins>
<ins>
<name>right</name>
<drift-rate>1.7</drift-rate>
</ins>
</PropertyList>
flameout wrote:For now, I will probably change it to the format you gave, but I don't understand the FlightGear command that reads that format (fgcommand("loadxml", node???)).
Also, can anyone explain fgcommand("loadxml", node) -- particularly the node part. Is that to read the XML directly into the property tree?
<?xml version="1.0"?>
<PropertyList>
<test>
<enabled type="bool">false</enabled>
<range-nm type="double">55.5</range-nm>
</test>
</PropertyList>
loadxml - load XML file into property tree
filename: the path & filename of the file to load
targetnode: the target node within the property tree where to store the XML
file's structure. If targetnode isn't defined, then the data will be stored
in a node "data" under the argument branch.
# Load XML file in FlightGear's native <PropertyList> format.
# If the second, optional target parameter is set, then the properties
# are loaded to this node in the global property tree. Otherwise they
# are returned as a separate props.Node tree. Returns the data as a
# props.Node on success or nil on error.
#
# Usage: io.read_properties(<filename> [, <props.Node or property-path>]);
#
# Examples:
#
# var target = props.globals.getNode("/sim/model");
# io.read_properties("/tmp/foo.xml", target);
#
# var data = io.read_properties("/tmp/foo.xml", "/sim/model");
# var data = io.read_properties("/tmp/foo.xml");
#
var read_properties = func(path, target = nil) {
var args = props.Node.new({ filename: path });
if (target == nil) {
var ret = args.getNode("data", 1);
} elsif (isa(target, props.Node)) {
args.getNode("targetnode", 1).setValue(target.getPath());
var ret = target;
} else {
args.getNode("targetnode", 1).setValue(target);
var ret = props.globals.getNode(target, 1);
}
return fgcommand("loadxml", args) ? ret : nil;
}
flameout wrote:Also, my very quick search online didn't reveal how to iterate through the property tree, so how is that done?
flameout wrote:I mean, once I have all these properties defined after reading the XML file, how do I find all the properties for the inses?
<?xml version="1.0"?>
<PropertyList>
<test>
<enabled type="bool">false</enabled>
<range-nm type="double">55.5</range-nm>
</test>
</PropertyList>
<?xml version="1.0"?>
<PropertyList>
<foo>
<test>
<enabled type="bool">false</enabled>
<range-nm type="double">55.5</range-nm>
</test>
</foo>
</PropertyList>
<?xml version="1.0"?>
<PropertyList>
<foo>
<test>
<even-deeper>
<enabled type="bool">false</enabled>
<range-nm type="double">55.5</range-nm>
<even-deeper>
</test>
</foo>
</PropertyList>
var enabled_node = "/ins/foo/test/even-deeper/enabled";
var value="true";
setprop(enabled_node,value);
(I hope I'm clear enough.)
Internals
---------
The core of FlightGear is the property system. This is a tree like internal
representation of global variables. The property system is explained more
in detail later on.
FlightGear' way of doing things is breaking it up into small pieces. There is
(for example) animation code that reacts on property changes. There is also a
Flight Dynamics model (FDM) that (amongst other things) updates properties.
There is a menu system that can display and alter properties. Then we have
sound code that plays sound based on ... properties.
Maybe you see a pattern evolve by now.
All subsystems are almost self containing. Most of the time they only read the
values of some properties, and sometimes they alter other properties. This is
the basic way of communicating between subsystems.
Property System
---------------
The property system is best described as an in-memory LDAP database which holds
the state of global variables. The system has a tree like hierarchy (like a
file system) and has a root node, sub nodes (like subdirectories) and end-nodes
(variables).
All variables are kept internally as raw values and can be converted to any
other supported type (boolean, int, float double and string).
Like a file system, every node can be accessed relative to the current node, or
absolute to the root node.
The property system also allows aliasing nodes to other nodes (like symbolic
linking files or directories to other files or directories) and may be assigned
read-only or read-write.
If necessary it would be possible for parts of the program to hold it's own
property tree, which is inaccessible from the global property tree, by keeping
track of it's own root-node.
Property I/O code allows one to easily read the tree from, or write the tree to
an XML file.
vspeed += vaccel * deltatime;
flameout wrote:I still don't understand what you mean by integrating analytically. The only way I know is just to repeatedly add up the steps, to keep a cumulative state.
Here is pseudocode for what I am doing: (calculating vertical speed)
- Code: Select all
vspeed += vaccel * deltatime;
If there is a more accurate way to do this, please tell me or provide a link to somewhere where I can find it. The only way I can think of doing integrations on paper is getting the exact value of the integral given the integrand, but in this case I do not know the integrand. However, I do know some information about it -- do you mean using the model to somehow more accurately integrate?
Although I'm aiming to keep track of altitude, I wanted to keep track of vertical speed, because I know some instantaneous VSI's use INS information for their vertical speed. However, with the high change in vertical acceleration (vertical jerk?) it is very inaccurate, so for now I am just outputting the actual vertical speed.
Thank you very much.
estlat+=(truelat-oldlat)+latdrift
oldlat = truelat
same for longitude
Users browsing this forum: No registered users and 8 guests