Commit 76c8b7cf authored by oberion's avatar oberion

Merge remote-tracking branch 'remotes/pixhawk/master' into dev_sensSoarNew

Conflicts:
	images/earth.html
	thirdParty/mavlink/include/common/common.h
	thirdParty/mavlink/include/common/mavlink.h
parents 64627ffd 8bd61d71
......@@ -8,6 +8,7 @@ Info.plist
obj
*.log
*~
*~.skp
bin/*.exe
bin/*.txt
bin/mac
......
......@@ -78,11 +78,39 @@ Done.
Windows
=======
DETAILED STEPS BELOW THE VISUAL STUDIO 2010 NOTES.
GNU GCC / MINGW IS UNTESTED, COULD WORK
VISUAL STUDIO 2008 / 2010 EXPRESS EDITION IS FREE!
-------------------------------------------------------------------------------------
VISUAL STUDIO 2010 NOTES (VS 2008 runs out-of-the-box, just follow the steps below):
For use of Qt 4x with Visual Studio 2010 Add-in.
Visual studio adds automatically certain defines that are wrong and cause errors.
To resolve this, execute these steps:
In the projects properties -> C/C++ ->preprocessor change:
in DEBUG:
delete QT_NO_DEBUG
in both (DEBUG / RELEASE):
delete QT_NO_DYNAMIC_CAST
-------------------------------------------------------------------------------------
Steps for Visual Studio 2008 / 2010. (VS 2008 is easier, VS 2010 only recommended for
expert developers)
Windows XP/7:
1) Download and install the QT SDK for Windows from http://qt.nokia.com/downloads/ (Visual Studio 2008 version)
1) Download and install the Qt SDK for Windows from http://qt.nokia.com/downloads/ (Visual Studio 2008 version) OR download Qt source and compile with VS 2010
2) Download and install Visual Studio 2008 Express Edition (free)
2) Download and install Visual Studio 2008 Express Edition (free) OR VS 2010 Express Edition
3) Go to the QGroundControl folder and then to thirdParty -> libxbee
......
<PropertyList>
<generic>
<output>
<line_separator>newline</line_separator>
<var_separator>,</var_separator>
<chunk>
<name>lat</name>
<type>float</type>
<format>%+1.8f</format>
<node>/position/latitude-deg</node>
</chunk>
<chunk>
<name>lon</name>
<type>float</type>
<format>%+1.8f</format>
<node>/position/longitude-deg</node>
</chunk>
<chunk>
<name>alt</name>
<type>float</type>
<format>%+1.4f</format>
<node>/position/altitude-ft</node>
</chunk>
<chunk>
<name>speed</name>
<type>float</type>
<format>%2.3f</format>
<node>/velocities/groundspeed-kt</node>
</chunk>
<chunk>
<name>airspeed</name>
<type>float</type>
<format>%2.3f</format>
<node>/velocities/airspeed-kt</node>
</chunk>
<chunk>
<name>pitch</name>
<type>float</type>
<format>%+1.3f</format>
<node>/orientation/pitch-deg</node>
</chunk>
<chunk>
<name>roll</name>
<type>float</type>
<format>%+1.3f</format>
<node>/orientation/roll-deg</node>
</chunk>
<chunk>
<name>heading</name>
<type>float</type>
<format>%+1.3f</format>
<node>/orientation/heading-deg</node>
</chunk>
<chunk>
<name>v_n</name>
<type>float</type>
<format>%2.3f</format>
<node>/velocities/speed-north-fps</node>
</chunk>
<chunk>
<name>v_e</name>
<type>float</type>
<format>%2.3f</format>
<node>/velocities/speed-east-fps</node>
</chunk>
<chunk>
<name>v_d</name>
<type>float</type>
<format>%2.3f</format>
<node>/velocities/speed-down-fps</node>
</chunk>
<chunk>
<name>rate_phi</name>
<type>float</type>
<format>%2.3f</format>
<node>/orientation/roll-rate-degps</node>
</chunk>
<chunk>
<name>rate_theta</name>
<type>float</type>
<format>%2.3f</format>
<node>/orientation/pitch-rate-degps</node>
</chunk>
<chunk>
<name>rate_psi</name>
<type>float</type>
<format>%2.3f</format>
<node>/orientation/yaw-rate-degps</node>
</chunk>
</output>
<input>
<line_separator>newline</line_separator>
<var_separator>,</var_separator>
<chunk>
<name>pitch</name>
<type>float</type>
<format>%+1.3f</format>
<node>/autopilot/settings/target-pitch-deg</node>
</chunk>
<chunk>
<name>roll</name>
<type>float</type>
<format>%+1.3f</format>
<node>/autopilot/settings/target-roll-deg</node>
</chunk>
<chunk>
<name>throttle</name>
<type>float</type>
<format>%+1.3f</format>
<node>/controls/engines/engine/throttle</node>
</chunk>
<chunk>
<name>lat</name>
<type>float</type>
<format>%+1.8f</format>
<node>/sim/view/target/latitude-deg</node>
</chunk>
<chunk>
<name>lon</name>
<type>float</type>
<format>%+1.8f</format>
<node>/sim/view/target/longitude-deg</node>
</chunk>
<chunk>
<name>alt</name>
<type>float</type>
<format>%+1.4f</format>
<node>/sim/view/target/alt</node>
</chunk>
</input>
</generic>
</PropertyList>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
......@@ -16,6 +16,7 @@ var ge = null;
var initialized = false;
var currAircraft = 0;
var followEnabled = false;
var lineAltitudeOffset = 0.5; ///< 0.5 m higher than waypoint, prevents the line from entering the ground
var lastLat = 0;
var lastLon = 0;
......@@ -211,7 +212,8 @@ google.earth.addEventListener(ge.getGlobe(), 'mousemove', function(event)
{
if (draggingAllowed && (clickMode == 0))
{
if (dragInfo) {
if (dragInfo)
{
event.preventDefault();
var point = dragInfo.placemark.getGeometry();
point.setLatitude(event.getLatitude());
......@@ -349,6 +351,8 @@ function updateWaypointListLength(id, len)
{
var placemark = waypoints.pop();
ge.getFeatures().removeChild(placemark);
var line = waypointLines[id].pop();
ge.getFeatures().removeChild(line);
}
}
}
......@@ -366,6 +370,9 @@ function updateWaypoint(id, index, lat, lon, alt, action)
location.setAltitude(alt);
waypoints[index].setGeometry(location);
waypoints[index].setDescription(index+"");
// Set the WP line location
waypointLines[id].getCoordinates().setLatLngAlt(index, lat, lon, alt);
}
else
{
......@@ -386,34 +393,16 @@ function updateWaypoint(id, index, lat, lon, alt, action)
var location = ge.createPoint('');
location.setLatitude(lat);
location.setLongitude(lon);
location.setAltitude(alt);
location.setAltitude(alt+lineAltitudeOffset);
placemark.setGeometry(location);
// Add the placemark to Earth.
ge.getFeatures().appendChild(placemark);
waypoints[index] = placemark;
}
// Add waypoint line
waypointLines[id].setExtrude(false);
waypointLines[id].setAltitudeMode(ge.ALTITUDE_ABSOLUTE);
// Add LineString points
waypointLines[id].getCoordinates().pushLatLngAlt(lat, lon, alt);
// Create a style and set width and color of line
waypointLinePlacemarks[id].setStyleSelector(ge.createStyle(''));
lineStyle = waypointLinePlacemarks[id].getStyleSelector().getLineStyle();
lineStyle.setWidth(5);
lineStyle.getColor().set(waypointLineColors[id]);  // aabbggrr format
//lineStyle.getColor().set(color);  // aabbggrr format
// Add the feature to Earth
//if (waypointLinesVisible[id] == true)
//ge.getFeatures().replaceChild(waypointLinePlacemarks[id], waypointLinePlacemarks[id]); // does not work
// Add connecting line
}
}
function createAircraft(id, type, color)
......@@ -428,7 +417,7 @@ function createAircraft(id, type, color)
planeOrient = ge.createOrientation('');
planeModel.setOrientation(planeOrient);
planeLink.setHref('http://qgroundcontrol.org/_media/users/models/multiplex-twinstar.dae');
planeLink.setHref('http://qgroundcontrol.org/_media/users/models/ascent-park-glider.dae');
planeModel.setLink(planeLink);
planeModel.setAltitudeMode (ge.ALTITUDE_ABSOLUTE);
......@@ -443,65 +432,69 @@ function createAircraft(id, type, color)
attitudes[id] = planeOrient;
aircraftLocations[id] = planeLoc;
aircraftLastLocations[id] = ge.createLocation('');
//planeColor = color;
createTrail(id, color);
createWaypointLine(id, color);
//console.log(color);
}
function createTrail(id, color)
{
trailPlacemarks[id] = ge.createPlacemark('');
// Create the placemark
// Create the LineString; set it to extend down to the ground
// and set the altitude mode
trails[id] = ge.createLineString('');
trailPlacemarks[id].setGeometry(trails[id]);
trails[id].setExtrude(false);
trails[id].setAltitudeMode(ge.ALTITUDE_ABSOLUTE);
// Add LineString points
//lineString.getCoordinates().pushLatLngAlt(48.754, -121.835, 700);
// Create a style and set width and color of line
trailPlacemarks[id].setStyleSelector(ge.createStyle(''));
lineStyle = trailPlacemarks[id].getStyleSelector().getLineStyle();
lineStyle.setWidth(5);
trailColors[id] = color;
lineStyle.getColor().set('00000000');  // aabbggrr format
trailsVisible[id] = false;
// Create the LineString; set it to extend down to the ground
// and set the altitude mode
trails[id] = ge.createLineString('');
trailPlacemarks[id].setGeometry(trails[id]);
trails[id].setExtrude(false);
trails[id].setAltitudeMode(ge.ALTITUDE_ABSOLUTE);
// Add the feature to Earth
//ge.getFeatures().appendChild(trailPlacemarks[id]);
// Create a style and set width and color of line
trailPlacemarks[id].setStyleSelector(ge.createStyle(''));
lineStyle = trailPlacemarks[id].getStyleSelector().getLineStyle();
lineStyle.setWidth(5);
trailColors[id] = color;
lineStyle.getColor().set('00000000');  // aabbggrr format
trailsVisible[id] = false;
}
function createWaypointLine(id, color)
{
waypointLinePlacemarks[id] = ge.createPlacemark('');
// Create the placemark
// Create the LineString; set it to extend down to the ground
// and set the altitude mode
waypointLines[id] = ge.createLineString('');
waypointLinePlacemarks[id].setGeometry(waypointLines[id]);
waypointLines[id].setExtrude(false);
waypointLines[id].setAltitudeMode(ge.ALTITUDE_ABSOLUTE);
waypointLinePlacemarks[id] = ge.createPlacemark('');
// Create the LineString; set it to extend down to the ground
// and set the altitude mode
waypointLines[id] = ge.createLineString('');
waypointLinePlacemarks[id].setGeometry(waypointLines[id]);
waypointLines[id].setExtrude(false);
waypointLines[id].setAltitudeMode(ge.ALTITUDE_ABSOLUTE);
// Add LineString points
//lineString.getCoordinates().pushLatLngAlt(48.754, -121.835, 700);
// Create a style and set width and color of line
waypointLinePlacemarks[id].setStyleSelector(ge.createStyle(''));
lineStyle = waypointLinePlacemarks[id].getStyleSelector().getLineStyle();
lineStyle.setWidth(15);
waypointLineColors[id] = color;
lineStyle.getColor().set(color);  // aabbggrr format
// Add LineString points
//lineString.getCoordinates().pushLatLngAlt(48.754, -121.835, 700);
// Create a style and set width and color of line
waypointLinePlacemarks[id].setStyleSelector(ge.createStyle(''));
lineStyle = waypointLinePlacemarks[id].getStyleSelector().getLineStyle();
lineStyle.setWidth(10);
waypointLineColors[id] = color;
lineStyle.getColor().set('00000000');  // aabbggrr format
// Add waypoint line
//waypointLines[id].setExtrude(false);
//waypointLines[id].setAltitudeMode(ge.ALTITUDE_ABSOLUTE);
// Add the feature to Earth
//ge.getFeatures().appendChild(trailPlacemarks[id]);
// Create a style and set width and color of line
//waypointLinePlacemarks[id].setStyleSelector(ge.createStyle(''));
//lineStyle = waypointLinePlacemarks[id].getStyleSelector().getLineStyle();
//lineStyle.setWidth(15);
//lineStyle.getColor().set(waypointLineColors[id]);  // aabbggrr format
//lineStyle.getColor().set(color);  // aabbggrr format
// Add the feature to Earth
ge.getFeatures().appendChild(waypointLinePlacemarks[id]);
}
function clearTrail(id)
......@@ -535,8 +528,8 @@ function setViewRange(dist)
function addTrailPosition(id, lat, lon, alt)
{
trails[id].setExtrude(false);
trails[id].setAltitudeMode(ge.ALTITUDE_ABSOLUTE);
//trails[id].setExtrude(false);
//trails[id].setAltitudeMode(ge.ALTITUDE_ABSOLUTE);
// Add LineString points
trails[id].getCoordinates().pushLatLngAlt(lat, lon, alt);
......@@ -546,10 +539,6 @@ function addTrailPosition(id, lat, lon, alt)
lineStyle = trailPlacemarks[id].getStyleSelector().getLineStyle();
lineStyle.setWidth(5);
lineStyle.getColor().set(trailColors[id]);  // aabbggrr format
//lineStyle.getColor().set(color);  // aabbggrr format
// Add the feature to Earth
if (trailsVisible[id] == true) ge.getFeatures().replaceChild(trailPlacemarks[id], trailPlacemarks[id]);
}
function initCallback(object)
......@@ -581,6 +570,7 @@ function setAircraftPositionAttitude(id, lat, lon, alt, roll, pitch, yaw)
lastLat = currLat;
lastLon = currLon;
}
currLat = lat;
currLon = lon;
var trueGroundAlt = ge.getGlobe().getGroundAltitude(lat, lon);
......@@ -661,6 +651,7 @@ function setViewMode(mode)
currView.setTilt(lastTilt);
currView.setHeading(lastHeading);
}
if (mode == 1 && viewMode != mode)
{
lastTilt = currView.getTilt();
......
B໿SketchUp Model૿{8.0.4810}Ƕ『時҆✱闊ÿ主乁￿ 噃牥楳湯慍ー￾䌉䄀爀挀䌀甀爀瘀攀Ā＀￾䌊䄀琀琀爀椀戀甀琀攀＀￾䌓䄀琀琀爀椀戀甀琀攀䌀漀渀琀愀椀渀攀爀＀￾䌏䄀琀琀爀椀戀甀琀攀一愀洀攀搀Ā＀￾䌐䈀愀挀欀最爀漀甀渀搀䤀洀愀最攀਀＀￾䌇䌀愀洀攀爀愀Ԁ＀￾䌊䌀漀洀瀀漀渀攀渀琀଀＀￾䌒䌀漀洀瀀漀渀攀渀琀䈀攀栀愀瘀椀漀爀Ԁ＀￾䌔䌀漀洀瀀漀渀攀渀琀䐀攀昀椀渀椀琀椀漀渀਀＀￾䌒䌀漀洀瀀漀渀攀渀琀䤀渀猀琀愀渀挀攀Ѐ＀￾䌕䌀漀渀猀琀爀甀挀琀椀漀渀䜀攀漀洀攀琀爀礀＀￾䌑䌀漀渀猀琀爀甀挀琀椀漀渀䰀椀渀攀Ā＀￾䌒䌀漀渀猀琀爀甀挀琀椀漀渀倀漀椀渀琀＀￾䌆䌀甀爀瘀攀Ѐ＀￾䌏䐀攀昀椀渀椀琀椀漀渀䰀椀猀琀＀￾䌄䐀椀戀̀＀￾䌊䐀椀洀攀渀猀椀漀渀Ā＀￾䌐䐀椀洀攀渀猀椀漀渀䰀椀渀攀愀爀؀＀￾䌐䐀椀洀攀渀猀椀漀渀刀愀搀椀愀氀Ȁ＀￾䌏䐀椀洀攀渀猀椀漀渀匀琀礀氀攀Ѐ＀￾䌏䐀爀愀眀椀渀最䔀氀攀洀攀渀琀ऀ＀￾䌅䔀搀最攀Ȁ＀￾䌈䔀搀最攀唀猀攀Ā＀￾䌇䔀渀琀椀琀礀̀＀￾䌅䘀愀挀攀̀＀￾䌒䘀愀挀攀吀攀砀琀甀爀攀䌀漀漀爀搀猀Ѐ＀￾䌌䘀漀渀琀䴀愀渀愀最攀爀＀￾䌆䜀爀漀甀瀀Ā＀￾䌆䤀洀愀最攀Ā＀￾䌆䰀愀礀攀爀Ȁ＀￾䌍䰀愀礀攀爀䴀愀渀愀最攀爀Ѐ＀￾䌅䰀漀漀瀀Ā＀￾䌉䴀愀琀攀爀椀愀氀ఀ＀￾䌐䴀愀琀攀爀椀愀氀䴀愀渀愀最攀爀Ѐ＀￾䌉倀愀最攀䰀椀猀琀Ā＀￾䌋倀漀氀礀氀椀渀攀㌀搀＀￾䌍刀攀氀愀琀椀漀渀猀栀椀瀀＀￾䌐刀攀氀愀琀椀漀渀猀栀椀瀀䴀愀瀀＀￾䌑刀攀渀搀攀爀椀渀最伀瀀琀椀漀渀猀␀＀￾䌍匀攀挀琀椀漀渀倀氀愀渀攀Ȁ＀￾䌋匀栀愀搀漀眀䤀渀昀漀܀＀￾䌇匀欀䘀漀渀琀Ā＀￾䌉匀欀攀琀挀栀䌀匀＀￾䌎匀欀攀琀挀栀唀瀀䴀漀搀攀氀ᘀ＀￾䌍匀欀攀琀挀栀唀瀀倀愀最攀Ā＀￾䌉匀欀瀀匀琀礀氀攀Ā＀￾䌐匀欀瀀匀琀礀氀攀䴀愀渀愀最攀爀Ȁ＀￾䌅吀攀砀琀ऀ＀￾䌊吀攀砀琀匀琀礀氀攀Ԁ＀￾䌈吀攀砀琀甀爀攀؀＀￾䌊吀栀甀洀戀渀愀椀氀Ā＀￾䌇嘀攀爀琀攀砀＀￾䌉嘀椀攀眀倀愀最攀ఀ＀￾䌊圀愀琀攀爀洀愀爀欀Ā＀￾䌑圀愀琀攀爀洀愀爀欀䴀愀渀愀最攀爀Ȁ＀￾䔒渀搀ⴀ伀昀ⴀ嘀攀爀猀椀漀渀ⴀ䴀愀瀀Ȁ뀀Ā＀ϿЀ䌀楄Ѣꨀ褀乐േᨊ
......
B໿SketchUp Model૿{8.0.4810}∳꛺䧕灁骨鎠讠ÿ侘乁￿ 噃牥楳湯慍ー￾䌉䄀爀挀䌀甀爀瘀攀Ā＀￾䌊䄀琀琀爀椀戀甀琀攀＀￾䌓䄀琀琀爀椀戀甀琀攀䌀漀渀琀愀椀渀攀爀＀￾䌏䄀琀琀爀椀戀甀琀攀一愀洀攀搀Ā＀￾䌐䈀愀挀欀最爀漀甀渀搀䤀洀愀最攀਀＀￾䌇䌀愀洀攀爀愀Ԁ＀￾䌊䌀漀洀瀀漀渀攀渀琀଀＀￾䌒䌀漀洀瀀漀渀攀渀琀䈀攀栀愀瘀椀漀爀Ԁ＀￾䌔䌀漀洀瀀漀渀攀渀琀䐀攀昀椀渀椀琀椀漀渀਀＀￾䌒䌀漀洀瀀漀渀攀渀琀䤀渀猀琀愀渀挀攀Ѐ＀￾䌕䌀漀渀猀琀爀甀挀琀椀漀渀䜀攀漀洀攀琀爀礀＀￾䌑䌀漀渀猀琀爀甀挀琀椀漀渀䰀椀渀攀Ā＀￾䌒䌀漀渀猀琀爀甀挀琀椀漀渀倀漀椀渀琀＀￾䌆䌀甀爀瘀攀Ѐ＀￾䌏䐀攀昀椀渀椀琀椀漀渀䰀椀猀琀＀￾䌄䐀椀戀̀＀￾䌊䐀椀洀攀渀猀椀漀渀Ā＀￾䌐䐀椀洀攀渀猀椀漀渀䰀椀渀攀愀爀؀＀￾䌐䐀椀洀攀渀猀椀漀渀刀愀搀椀愀氀Ȁ＀￾䌏䐀椀洀攀渀猀椀漀渀匀琀礀氀攀Ѐ＀￾䌏䐀爀愀眀椀渀最䔀氀攀洀攀渀琀ऀ＀￾䌅䔀搀最攀Ȁ＀￾䌈䔀搀最攀唀猀攀Ā＀￾䌇䔀渀琀椀琀礀̀＀￾䌅䘀愀挀攀̀＀￾䌒䘀愀挀攀吀攀砀琀甀爀攀䌀漀漀爀搀猀Ѐ＀￾䌌䘀漀渀琀䴀愀渀愀最攀爀＀￾䌆䜀爀漀甀瀀Ā＀￾䌆䤀洀愀最攀Ā＀￾䌆䰀愀礀攀爀Ȁ＀￾䌍䰀愀礀攀爀䴀愀渀愀最攀爀Ѐ＀￾䌅䰀漀漀瀀Ā＀￾䌉䴀愀琀攀爀椀愀氀ఀ＀￾䌐䴀愀琀攀爀椀愀氀䴀愀渀愀最攀爀Ѐ＀￾䌉倀愀最攀䰀椀猀琀Ā＀￾䌋倀漀氀礀氀椀渀攀㌀搀＀￾䌍刀攀氀愀琀椀漀渀猀栀椀瀀＀￾䌐刀攀氀愀琀椀漀渀猀栀椀瀀䴀愀瀀＀￾䌑刀攀渀搀攀爀椀渀最伀瀀琀椀漀渀猀␀＀￾䌍匀攀挀琀椀漀渀倀氀愀渀攀Ȁ＀￾䌋匀栀愀搀漀眀䤀渀昀漀܀＀￾䌇匀欀䘀漀渀琀Ā＀￾䌉匀欀攀琀挀栀䌀匀＀￾䌎匀欀攀琀挀栀唀瀀䴀漀搀攀氀ᘀ＀￾䌍匀欀攀琀挀栀唀瀀倀愀最攀Ā＀￾䌉匀欀瀀匀琀礀氀攀Ā＀￾䌐匀欀瀀匀琀礀氀攀䴀愀渀愀最攀爀Ȁ＀￾䌅吀攀砀琀ऀ＀￾䌊吀攀砀琀匀琀礀氀攀Ԁ＀￾䌈吀攀砀琀甀爀攀؀＀￾䌊吀栀甀洀戀渀愀椀氀Ā＀￾䌇嘀攀爀琀攀砀＀￾䌉嘀椀攀眀倀愀最攀ఀ＀￾䌊圀愀琀攀爀洀愀爀欀Ā＀￾䌑圀愀琀攀爀洀愀爀欀䴀愀渀愀最攀爀Ȁ＀￾䔒渀搀ⴀ伀昀ⴀ嘀攀爀猀椀漀渀ⴀ䴀愀瀀Ȁ뀀Ā＀ϿЀ䌀楄Ѣ⼀褀乐േᨊ
price quantity
210 81
250 73
280 64
300 61
320 50
340 46
360 45
380 44
400 43
420 39
440 36
......@@ -246,6 +246,7 @@ HEADERS += src/MG.h \
src/comm/ProtocolInterface.h \
src/comm/MAVLinkProtocol.h \
src/comm/AS4Protocol.h \
src/comm/QGCFlightGearLink.h \
src/ui/CommConfigurationWindow.h \
src/ui/SerialConfigurationWindow.h \
src/ui/MainWindow.h \
......@@ -376,6 +377,7 @@ SOURCES += src/main.cc \
src/comm/SerialSimulationLink.cc \
src/comm/MAVLinkProtocol.cc \
src/comm/AS4Protocol.cc \
src/comm/QGCFlightGearLink.cc \
src/ui/CommConfigurationWindow.cc \
src/ui/SerialConfigurationWindow.cc \
src/ui/MainWindow.cc \
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2011 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL 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 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
......@@ -29,7 +49,8 @@ MAVLinkXMLParser::MAVLinkXMLParser(QString document, QString outputDirectory, QO
{
doc = new QDomDocument();
QFile file(document);
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
{
const QString instanceText(QString::fromUtf8(file.readAll()));
doc->setContent(instanceText);
}
......@@ -50,7 +71,8 @@ bool MAVLinkXMLParser::generate()
bool success = true;
// Only generate if output dir is correctly set
if (outputDirName == "") {
if (outputDirName == "")
{
emit parseState(tr("<font color=\"red\">ERROR: No output directory given.\nAbort.</font>"));
return false;
}
......@@ -96,7 +118,7 @@ bool MAVLinkXMLParser::generate()
static int highest_message_id;
static int recursion_level;
if (recursion_level == 0) {
if (recursion_level == 0){
highest_message_id = 0;
memset(message_lengths, 0, sizeof(message_lengths));
}
......@@ -113,18 +135,24 @@ bool MAVLinkXMLParser::generate()
// Run through root children
while(!n.isNull()) {
while(!n.isNull())
{
// Each child is a message
QDomElement e = n.toElement(); // try to convert the node to an element.
if(!e.isNull()) {
if (e.tagName() == "mavlink") {
if(!e.isNull())
{
if (e.tagName() == "mavlink")
{
p = n;
n = n.firstChild();
while (!n.isNull()) {
while (!n.isNull())
{
e = n.toElement();
if (!e.isNull()) {
if (!e.isNull())
{
// Handle all include tags
if (e.tagName() == "include") {
if (e.tagName() == "include")
{
QString incFileName = e.text();
// Load file
//QDomDocument includeDoc = QDomDocument();
......@@ -134,14 +162,16 @@ bool MAVLinkXMLParser::generate()
QFileInfo fInfo(incFileName);
QString incFilePath;
if (fInfo.isRelative()) {
if (fInfo.isRelative())
{
QFileInfo rInfo(this->fileName);
incFilePath = rInfo.absoluteDir().canonicalPath() + "/" + incFileName;
pureIncludeFileName = fInfo.baseName().split(".", QString::SkipEmptyParts).first();
}
QFile file(incFilePath);
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
{
emit parseState(QString("<font color=\"green\">Included messages from file: %1</font>").arg(incFileName));
// NEW MODE: CREATE INDIVIDUAL FOLDERS
// Create new output directory, parse included XML and generate C-code
......@@ -175,7 +205,9 @@ bool MAVLinkXMLParser::generate()
// }
emit parseState(QString("<font color=\"green\">End of inclusion from file: %1</font>").arg(incFileName));
} else {
}
else
{
// Include file could not be opened
emit parseState(QString("<font color=\"red\">ERROR: Failed including file: %1, file is not readable. Wrong/misspelled filename?\nAbort.</font>").arg(fileName));
return false;
......@@ -183,33 +215,40 @@ bool MAVLinkXMLParser::generate()
}
// Handle all enum tags
else if (e.tagName() == "version") {
else if (e.tagName() == "version")
{
//QString fieldType = e.attribute("type", "");
//QString fieldName = e.attribute("name", "");
QString fieldText = e.text();
// Check if version has been previously set
if (mavlinkVersion != 0) {
if (mavlinkVersion != 0)
{
emit parseState(QString("<font color=\"red\">ERROR: Protocol version tag set twice, please use it only once. First version was %1, second version is %2.\nAbort.</font>").arg(mavlinkVersion).arg(fieldText));
return false;
}
bool ok;
int version = fieldText.toInt(&ok);
if (ok && (version > 0) && (version < 256)) {
if (ok && (version > 0) && (version < 256))
{
// Set MAVLink version
mavlinkVersion = version;
} else {
}
else
{
emit parseState(QString("<font color=\"red\">ERROR: Reading version string failed: %1, string is not an integer number between 1 and 255.\nAbort.</font>").arg(fieldText));
return false;
}
}
// Handle all enum tags
else if (e.tagName() == "enums") {
else if (e.tagName() == "enums")
{
// One down into the enums list
p = n;
n = n.firstChild();
while (!n.isNull()) {
while (!n.isNull())
{
e = n.toElement();
QString currEnum;
......@@ -217,18 +256,25 @@ bool MAVLinkXMLParser::generate()
// Comment
QString comment;
if(!e.isNull() && e.tagName() == "enum") {
if(!e.isNull() && e.tagName() == "enum")
{
// Get enum name
QString enumName = e.attribute("name", "").toLower();
if (enumName.size() == 0) {
if (enumName.size() == 0)
{
emit parseState(tr("<font color=\"red\">ERROR: Missing required name=\"\" attribute for tag %2 near line %1\nAbort.</font>").arg(QString::number(e.lineNumber()), e.tagName()));
return false;
} else {
}
else
{
// Sanity check: Accept only enum names not used previously
if (usedEnumNames->contains(enumName)) {
if (usedEnumNames->contains(enumName))
{
emit parseState(tr("<font color=\"red\">ERROR: Enum name %1 used twice, second occurence near line %2 of file %3\nAbort.</font>").arg(enumName, QString::number(e.lineNumber()), fileName));
return false;
} else {
}
else
{
usedEnumNames->insert(enumName, QString::number(e.lineNumber()));
}
......@@ -240,22 +286,28 @@ bool MAVLinkXMLParser::generate()
// Get the enum fields
QDomNode f = e.firstChild();
while (!f.isNull()) {
while (!f.isNull())
{
QDomElement e2 = f.toElement();
if (!e2.isNull() && e2.tagName() == "entry") {
if (!e2.isNull() && e2.tagName() == "entry")
{
QString fieldValue = e2.attribute("value", "");
// If value was given, use it, if not, use the enum iterator
// value. The iterator value gets reset by manual values
QString fieldName = e2.attribute("name", "");
if (fieldValue.length() == 0) {
if (fieldValue.length() == 0)
{
fieldValue = QString::number(nextEnumValue);
nextEnumValue++;
} else {
}
else
{
bool ok;
nextEnumValue = fieldValue.toInt(&ok) + 1;
if (!ok) {
if (!ok)