Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
2899fc5f
Commit
2899fc5f
authored
Oct 15, 2011
by
lm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed flightgear HIL
parent
7dba86d0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
159 additions
and
94 deletions
+159
-94
qgroundcontrol.xml
files/flightgear/qgroundcontrol.xml
+87
-48
MAVLinkSimulationMAV.cc
src/comm/MAVLinkSimulationMAV.cc
+13
-0
QGCFlightGearLink.cc
src/comm/QGCFlightGearLink.cc
+59
-44
UAS.cc
src/uas/UAS.cc
+0
-2
No files found.
files/flightgear/qgroundcontrol.xml
View file @
2899fc5f
...
...
@@ -5,118 +5,150 @@
<output>
<line_separator>
newline
</line_separator>
<var_separator>
,
</var_separator>
<var_separator>
tab
</var_separator>
<chunk>
<name>
time (sec)
</name>
<type>
float
</type>
<format>
%.4f
</format>
<node>
/sim/time/elapsed-sec
</node>
</chunk>
<!-- Position -->
<chunk>
<name>
latitude-deg
</name>
<type>
float
</type>
<format>
%f
</format>
<type>
double
</type>
<format>
%
.18
f
</format>
<node>
/position/latitude-deg
</node>
</chunk>
<chunk>
<name>
longitude-deg
</name>
<type>
float
</type>
<format>
%f
</format>
<type>
double
</type>
<format>
%
.18
f
</format>
<node>
/position/longitude-deg
</node>
</chunk>
<chunk>
<name>
altit
ude-ft
</name>
<type>
float
</type>
<format>
%f
</format>
<name>
altit
iude (m)
</name>
<type>
double
</type>
<format>
%
.5
f
</format>
<node>
/position/altitude-ft
</node>
<factor>
0.3048
</factor>
<!-- feet to meter -->
</chunk>
<!-- Orientation -->
<chunk>
<name>
roll
-deg
</name>
<name>
roll
angle
</name>
<type>
float
</type>
<format>
%f
</format>
<format>
%
.5
f
</format>
<node>
/orientation/roll-deg
</node>
<factor>
0.01745329251994329576
</factor>
<!-- degrees to radians -->
</chunk>
<chunk>
<name>
pitch
-deg
</name>
<name>
pitch
angle (rad)
</name>
<type>
float
</type>
<format>
%f
</format>
<format>
%
.5
f
</format>
<node>
/orientation/pitch-deg
</node>
<factor>
0.01745329251994329576
</factor>
<!-- degrees to radians -->
</chunk>
<chunk>
<name>
heading-deg
</name>
<name>
yaw angle
</name>
<type>
float
</type>
<format>
%f
</format>
<format>
%
.5
f
</format>
<node>
/orientation/heading-deg
</node>
<factor>
0.01745329251994329576
</factor>
<!-- degrees to radians -->
</chunk>
<!-- Velocities -->
<chunk>
<name>
v_n
</name>
<name>
roll rate ("p" rad/sec)
</name>
<type>
float
</type>
<format>
%
2.3
f
</format>
<node>
/
velocities/speed-north-fps
</node>
<format>
%
.6
f
</format>
<node>
/
fdm/jsbsim/velocities/pi-rad_sec
</node>
</chunk>
<chunk>
<name>
v_e
</name>
<name>
pitch rate ("q" rad/sec)
</name>
<type>
float
</type>
<format>
%
2.3
f
</format>
<node>
/
velocities/speed-east-fps
</node>
<format>
%
.6
f
</format>
<node>
/
fdm/jsbsim/velocities/qi-rad_sec
</node>
</chunk>
<chunk>
<name>
v_d
</name>
<name>
yaw rate ("r" rad/sec)
</name>
<type>
float
</type>
<format>
%
2.3
f
</format>
<node>
/
velocities/speed-down-fps
</node>
<format>
%
.6
f
</format>
<node>
/
fdm/jsbsim/velocities/ri-rad_sec
</node>
</chunk>
<chunk>
<name>
rate_roll
</name>
<name>
X accel (body axis) (mps)
</name>
<type>
float
</type>
<format>
%2.3f
</format>
<node>
/orientation/roll-rate-degps
</node>
<format>
%.5f
</format>
<node>
/accelerations/pilot/x-accel-fps_sec
</node>
<factor>
0.3048
</factor>
<!-- feet to meter -->
</chunk>
<chunk>
<name>
rate_pitch
</name>
<name>
Y accel (body axis) (mps)
</name>
<type>
float
</type>
<format>
%2.3f
</format>
<node>
/orientation/pitch-rate-degps
</node>
<format>
%.5f
</format>
<node>
/accelerations/pilot/y-accel-fps_sec
</node>
<factor>
0.3048
</factor>
<!-- feet to meter -->
</chunk>
<chunk>
<name>
rate_yaw
</name>
<name>
Z accel (body axis) (mps)
</name>
<type>
float
</type>
<format>
%2.3f
</format>
<node>
/orientation/yaw-rate-degps
</node>
<format>
%.5f
</format>
<node>
/accelerations/pilot/z-accel-fps_sec
</node>
<factor>
0.3048
</factor>
<!-- feet to meter -->
</chunk>
<!-- Velocities -->
<chunk>
<name>
airspeed-kt
</name>
<name>
Velocity North ("vn" mps)
</name>
<type>
float
</type>
<format>
%.8f
</format>
<node>
/velocities/speed-north-fps
</node>
<factor>
0.3048
</factor>
<!-- fps to mps -->
</chunk>
<chunk>
<name>
Velocity East ("ve" mps)
</name>
<type>
float
</type>
<format>
%.8f
</format>
<node>
/velocities/speed-east-fps
</node>
<factor>
0.3048
</factor>
<!-- fps to mps -->
</chunk>
<chunk>
<name>
Velocity Down ("vd" mps)
</name>
<type>
float
</type>
<format>
%.8f
</format>
<node>
/velocities/speed-down-fps
</node>
<factor>
0.3048
</factor>
<!-- fps to mps -->
</chunk>
<chunk>
<name>
airspeed-mps
</name>
<type>
float
</type>
<format>
%f
</format>
<format>
%
.8
f
</format>
<node>
/velocities/airspeed-kt
</node>
<factor>
0.514444444444444
</factor>
<!-- knots to mps -->
</chunk>
</output>
<input>
<line_separator>
newline
</line_separator>
<var_separator>
,
</var_separator>
<var_separator>
tab
</var_separator>
<!-- Controls -->
<chunk>
<name>
magnetos
</name>
<type>
float
</type>
<format>
%f
</format>
<node>
/controls/engines/engine[0]/magnetos
</node>
</chunk>
<chunk>
<name>
aileron
</name>
<type>
float
</type>
...
...
@@ -134,12 +166,19 @@
<type>
float
</type>
<node>
/controls/flight/rudder
</node>
</chunk>
<chunk>
<name>
running
</name>
<type>
bool
</type>
<node>
/engines/engine/running
</node>
</chunk>
<chunk>
<name>
throttle
</name>
<type>
float
</type>
<node>
/controls/engines/engine/throttle
</node>
</chunk>
</input>
...
...
src/comm/MAVLinkSimulationMAV.cc
View file @
2899fc5f
...
...
@@ -207,6 +207,19 @@ void MAVLinkSimulationMAV::mainloop()
// The message container to be used for sending
mavlink_message_t
ret
;
if
(
sys_mode
&
MAV_MODE_FLAG_DECODE_POSITION_HIL
)
{
mavlink_hil_controls_t
hil
;
hil
.
roll_ailerons
=
0.0
;
hil
.
pitch_elevator
=
0.0
;
hil
.
yaw_rudder
=
0.05
;
hil
.
throttle
=
0.6
;
// Encode the data (adding header and checksums, etc.)
mavlink_msg_hil_controls_encode
(
systemid
,
MAV_COMP_ID_IMU
,
&
ret
,
&
hil
);
// And send it
link
->
sendMAVLinkMessage
(
&
ret
);
}
// Send actual controller outputs
// This message just shows the direction
// and magnitude of the control output
...
...
src/comm/QGCFlightGearLink.cc
View file @
2899fc5f
...
...
@@ -139,13 +139,13 @@ void QGCFlightGearLink::updateControls(uint64_t time, float rollAilerons, float
{
// magnetos,aileron,elevator,rudder,throttle\n
float
magnetos
=
3.0
f
;
//
float magnetos = 3.0f;
Q_UNUSED
(
time
);
Q_UNUSED
(
systemMode
);
Q_UNUSED
(
navMode
);
QString
state
(
"%1
,%2,%3,%4,
%5
\n
"
);
state
=
state
.
arg
(
magnetos
).
arg
(
rollAilerons
).
arg
(
pitchElevator
).
arg
(
yawRudder
).
arg
(
throttle
);
QString
state
(
"%1
\t
%2
\t
%3
\t
%4
\t
%5
\n
"
);
state
=
state
.
arg
(
rollAilerons
).
arg
(
pitchElevator
).
arg
(
yawRudder
).
arg
(
true
).
arg
(
throttle
);
writeBytes
(
state
.
toAscii
().
constData
(),
state
.
length
());
//qDebug() << "Updated controls" << state;
}
...
...
@@ -199,29 +199,43 @@ void QGCFlightGearLink::readBytes()
QString
state
(
b
);
//qDebug() << "FG LINK GOT:" << state;
QStringList
values
=
state
.
split
(
","
);
QStringList
values
=
state
.
split
(
"
\t
"
);
// Check length
if
(
values
.
size
()
!=
17
)
{
qDebug
()
<<
"RETURN LENGTH MISMATCHING EXPECTED"
<<
17
<<
"BUT GOT"
<<
values
.
size
();
qDebug
()
<<
state
;
return
;
}
// Parse string
double
time
;
float
roll
,
pitch
,
yaw
,
rollspeed
,
pitchspeed
,
yawspeed
;
int32_t
lat
,
lon
,
alt
;
int16_t
vx
,
vy
,
vz
,
xacc
,
yacc
,
zacc
;
lat
=
values
.
at
(
0
).
toDouble
();
lon
=
values
.
at
(
1
).
toDouble
();
alt
=
values
.
at
(
2
).
toDouble
();
roll
=
values
.
at
(
3
).
toDouble
();
pitch
=
values
.
at
(
4
).
toDouble
();
yaw
=
values
.
at
(
5
).
toDouble
();
vx
=
values
.
at
(
6
).
toDouble
();
vy
=
values
.
at
(
7
).
toDouble
();
vz
=
values
.
at
(
8
).
toDouble
();
// FIXME Accelerations missing
xacc
=
0
;
yacc
=
0
;
zacc
=
1.0
;
double
lat
,
lon
,
alt
;
double
vx
,
vy
,
vz
,
xacc
,
yacc
,
zacc
;
double
airspeed
;
time
=
values
.
at
(
0
).
toDouble
();
lat
=
values
.
at
(
1
).
toDouble
();
lon
=
values
.
at
(
2
).
toDouble
();
alt
=
values
.
at
(
3
).
toDouble
();
roll
=
values
.
at
(
4
).
toDouble
();
pitch
=
values
.
at
(
5
).
toDouble
();
yaw
=
values
.
at
(
6
).
toDouble
();
rollspeed
=
values
.
at
(
7
).
toDouble
();
pitchspeed
=
values
.
at
(
8
).
toDouble
();
yawspeed
=
values
.
at
(
9
).
toDouble
();
xacc
=
values
.
at
(
10
).
toDouble
();
yacc
=
values
.
at
(
11
).
toDouble
();
zacc
=
values
.
at
(
12
).
toDouble
();
vx
=
values
.
at
(
13
).
toDouble
();
vy
=
values
.
at
(
14
).
toDouble
();
vz
=
values
.
at
(
15
).
toDouble
();
airspeed
=
values
.
at
(
16
).
toDouble
();
// Send updated state
emit
hilStateChanged
(
QGC
::
groundTimeUsecs
(),
roll
,
pitch
,
yaw
,
rollspeed
,
...
...
@@ -294,15 +308,15 @@ bool QGCFlightGearLink::connectSimulation()
QObject
::
connect
(
socket
,
SIGNAL
(
readyRead
()),
this
,
SLOT
(
readBytes
()));
//
process = new QProcess(this);
process
=
new
QProcess
(
this
);
//
connect(mav, SIGNAL(hilControlsChanged(uint64_t, float, float, float, float, uint8_t, uint8_t)), this, SLOT(updateControls(uint64_t,float,float,float,float,uint8_t,uint8_t)));
//
connect(this, SIGNAL(hilStateChanged(uint64_t,float,float,float,float,float,float,int32_t,int32_t,int32_t,int16_t,int16_t,int16_t,int16_t,int16_t,int16_t)), mav, SLOT(sendHilState(uint64_t,float,float,float,float,float,float,int32_t,int32_t,int32_t,int16_t,int16_t,int16_t,int16_t,int16_t,int16_t)));
connect
(
mav
,
SIGNAL
(
hilControlsChanged
(
uint64_t
,
float
,
float
,
float
,
float
,
uint8_t
,
uint8_t
)),
this
,
SLOT
(
updateControls
(
uint64_t
,
float
,
float
,
float
,
float
,
uint8_t
,
uint8_t
)));
connect
(
this
,
SIGNAL
(
hilStateChanged
(
uint64_t
,
float
,
float
,
float
,
float
,
float
,
float
,
int32_t
,
int32_t
,
int32_t
,
int16_t
,
int16_t
,
int16_t
,
int16_t
,
int16_t
,
int16_t
)),
mav
,
SLOT
(
sendHilState
(
uint64_t
,
float
,
float
,
float
,
float
,
float
,
float
,
int32_t
,
int32_t
,
int32_t
,
int16_t
,
int16_t
,
int16_t
,
int16_t
,
int16_t
,
int16_t
)));
//
//connect(&refreshTimer, SIGNAL(timeout()), this, SLOT(sendUAVUpdate()));
//
// Catch process error
//
QObject::connect( process, SIGNAL(error(QProcess::ProcessError)),
//
this, SLOT(processError(QProcess::ProcessError)));
//connect(&refreshTimer, SIGNAL(timeout()), this, SLOT(sendUAVUpdate()));
// Catch process error
QObject
::
connect
(
process
,
SIGNAL
(
error
(
QProcess
::
ProcessError
)),
this
,
SLOT
(
processError
(
QProcess
::
ProcessError
)));
// Start Flightgear
QStringList
processCall
;
QString
processFgfs
;
...
...
@@ -340,11 +354,12 @@ bool QGCFlightGearLink::connectSimulation()
processCall
<<
"--disable-sound"
;
processCall
<<
"--disable-anti-alias-hud"
;
processCall
<<
"--disable-fullscreen"
;
processCall
<<
"--disable-random-objects"
;
processCall
<<
"--disable-ai-models"
;
processCall
<<
"--wind=0@0"
;
//
processCall << "--disable-random-objects";
//
processCall << "--disable-ai-models";
//
processCall << "--wind=0@0";
processCall
<<
"--fdm=jsb"
;
processCall
<<
"--prop:/engines/engine[0]/running=true"
;
processCall
<<
"--prop:/engines/engine/running=true"
;
processCall
<<
"--units-meters"
;
if
(
mav
->
getSystemType
()
==
MAV_TYPE_QUADROTOR
)
{
// Start the remaining three motors of the quad
...
...
@@ -352,22 +367,22 @@ bool QGCFlightGearLink::connectSimulation()
processCall
<<
"--prop:/engines/engine[2]/running=true"
;
processCall
<<
"--prop:/engines/engine[3]/running=true"
;
}
processCall
<<
QString
(
"--lat=%1"
).
arg
(
UASManager
::
instance
()
->
getHomeLatitude
());
processCall
<<
QString
(
"--lon=%1"
).
arg
(
UASManager
::
instance
()
->
getHomeLongitude
());
processCall
<<
QString
(
"--altitude=%1"
).
arg
(
UASManager
::
instance
()
->
getHomeAltitude
());
//
processCall << QString("--lat=%1").arg(UASManager::instance()->getHomeLatitude());
//
processCall << QString("--lon=%1").arg(UASManager::instance()->getHomeLongitude());
//
processCall << QString("--altitude=%1").arg(UASManager::instance()->getHomeAltitude());
// Add new argument with this: processCall << "";
processCall
<<
QString
(
"--aircraft=%2"
).
arg
(
aircraft
);
//
process->start(processFgfs, processCall);
process
->
start
(
processFgfs
,
processCall
);
//
emit flightGearConnected(connectState);
//
if (connectState) {
//
emit flightGearConnected();
//
connectionStartTime = QGC::groundTimeUsecs()/1000;
//
}
//
qDebug() << "STARTING SIM";
emit
flightGearConnected
(
connectState
);
if
(
connectState
)
{
emit
flightGearConnected
();
connectionStartTime
=
QGC
::
groundTimeUsecs
()
/
1000
;
}
qDebug
()
<<
"STARTING SIM"
;
qDebug
()
<<
"STARTING: "
<<
processFgfs
<<
processCall
;
...
...
src/uas/UAS.cc
View file @
2899fc5f
...
...
@@ -343,8 +343,6 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
currentVoltage
=
state
.
voltage_battery
/
1000.0
f
;
lpVoltage
=
filterVoltage
(
currentVoltage
);
qDebug
()
<<
"BATT VOLTAGE:"
<<
currentVoltage
<<
"RAW"
<<
state
.
voltage_battery
;
if
(
startVoltage
==
0
)
startVoltage
=
currentVoltage
;
timeRemaining
=
calculateTimeRemaining
();
if
(
!
batteryRemainingEstimateEnabled
&&
chargeLevel
!=
-
1
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment