mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
Flight battery to AerosimRC, needs option flag, currently linked to baroaltitude option
This commit is contained in:
parent
e43e5c5028
commit
4240cc9670
@ -87,7 +87,7 @@ void UdpSender::sendDatagram(const simToPlugin *stp)
|
||||
// attitude
|
||||
out << stp->heading << stp->pitch << stp->roll;
|
||||
// electric
|
||||
out << stp->voltage << stp->current;
|
||||
out << stp->voltage << stp->current << stp->consumedCharge;
|
||||
// matrix
|
||||
out << stp->axisXx << stp->axisXy << stp->axisXz;
|
||||
out << stp->axisYx << stp->axisYy << stp->axisYz;
|
||||
|
@ -143,7 +143,7 @@ void AeroSimRCSimulator::transmitUpdate()
|
||||
void AeroSimRCSimulator::processUpdate(const QByteArray &data)
|
||||
{
|
||||
// check size
|
||||
if (data.size() > 188) {
|
||||
if (data.size() > 192) {
|
||||
qDebug() << "!!! big datagram: " << data.size();
|
||||
return;
|
||||
}
|
||||
@ -171,7 +171,7 @@ void AeroSimRCSimulator::processUpdate(const QByteArray &data)
|
||||
qreal lat, lon;
|
||||
float agl, // world
|
||||
yaw, pitch, roll, // model
|
||||
volt, curr,
|
||||
volt, curr, cons,
|
||||
rx, ry, rz, fx, fy, fz, ux, uy, uz, // matrix
|
||||
ch[AEROSIM_RCCHANNEL_NUMELEM];
|
||||
|
||||
@ -184,7 +184,7 @@ void AeroSimRCSimulator::processUpdate(const QByteArray &data)
|
||||
stream >> accX >> accY >> accZ;
|
||||
stream >> lat >> lon >> agl;
|
||||
stream >> yaw >> pitch >> roll;
|
||||
stream >> volt >> curr;
|
||||
stream >> volt >> curr >> cons;
|
||||
stream >> rx >> ry >> rz >> fx >> fy >> fz >> ux >> uy >> uz;
|
||||
stream >> ch[0] >> ch[1] >> ch[2] >> ch[3] >> ch[4] >> ch[5] >> ch[6] >> ch[7];
|
||||
stream >> udpCounterASrecv;
|
||||
@ -253,6 +253,11 @@ void AeroSimRCSimulator::processUpdate(const QByteArray &data)
|
||||
out.velEast = velX * 1;
|
||||
out.velDown = velZ * -1;
|
||||
|
||||
out.voltage = volt;
|
||||
out.current = curr;
|
||||
out.consumption = cons*1000.0;
|
||||
|
||||
|
||||
updateUAVOs(out);
|
||||
|
||||
|
||||
|
@ -69,6 +69,7 @@ Simulator::Simulator(const SimulatorSettings& params) :
|
||||
gcsRcvrTime = currentTime;
|
||||
attRawTime = currentTime;
|
||||
baroAltTime = currentTime;
|
||||
battTime = currentTime;
|
||||
airspeedActualTime=currentTime;
|
||||
|
||||
//Define standard atmospheric constants
|
||||
@ -153,6 +154,7 @@ void Simulator::onStart()
|
||||
velActual = VelocityActual::GetInstance(objManager);
|
||||
posActual = PositionActual::GetInstance(objManager);
|
||||
baroAlt = BaroAltitude::GetInstance(objManager);
|
||||
flightBatt = FlightBatteryState::GetInstance(objManager);
|
||||
airspeedActual = AirspeedActual::GetInstance(objManager);
|
||||
attActual = AttitudeActual::GetInstance(objManager);
|
||||
attSettings = AttitudeSettings::GetInstance(objManager);
|
||||
@ -284,7 +286,10 @@ void Simulator::setupObjects()
|
||||
setupOutputObject(airspeedActual, settings.airspeedActualRate);
|
||||
|
||||
if(settings.baroAltitudeEnabled)
|
||||
{
|
||||
setupOutputObject(baroAlt, settings.baroAltRate);
|
||||
setupOutputObject(flightBatt, settings.baroAltRate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -726,6 +731,21 @@ void Simulator::updateUAVOs(Output2Hardware out){
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************/
|
||||
// Update FlightBatteryState object
|
||||
if (settings.baroAltitudeEnabled){
|
||||
if (battTime.msecsTo(currentTime) >= settings.baroAltRate) {
|
||||
FlightBatteryState::DataFields batteryData;
|
||||
memset(&batteryData, 0, sizeof(FlightBatteryState::DataFields));
|
||||
batteryData.Voltage = out.voltage;
|
||||
batteryData.Current = out.current;
|
||||
batteryData.ConsumedEnergy = out.consumption;
|
||||
flightBatt->setData(batteryData);
|
||||
|
||||
battTime=battTime.addMSecs(settings.baroAltRate);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************/
|
||||
// Update AirspeedActual object
|
||||
if (settings.airspeedActualEnabled){
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "attitudeactual.h"
|
||||
#include "attitudesettings.h"
|
||||
#include "baroaltitude.h"
|
||||
#include "flightbatterystate.h"
|
||||
#include "flightstatus.h"
|
||||
#include "gcsreceiver.h"
|
||||
#include "gcstelemetrystats.h"
|
||||
@ -194,6 +195,10 @@ struct Output2Hardware{
|
||||
float pitchDesired;
|
||||
float yawDesired;
|
||||
float throttleDesired;
|
||||
|
||||
float voltage;
|
||||
float current;
|
||||
float consumption;
|
||||
};
|
||||
|
||||
//struct Output2Simulator{
|
||||
@ -285,6 +290,7 @@ protected:
|
||||
ActuatorDesired* actDesired;
|
||||
ManualControlCommand* manCtrlCommand;
|
||||
FlightStatus* flightStatus;
|
||||
FlightBatteryState* flightBatt;
|
||||
BaroAltitude* baroAlt;
|
||||
AirspeedActual* airspeedActual;
|
||||
AttitudeActual* attActual;
|
||||
@ -323,6 +329,7 @@ private:
|
||||
QTime gpsPosTime;
|
||||
QTime groundTruthTime;
|
||||
QTime baroAltTime;
|
||||
QTime battTime;
|
||||
QTime gcsRcvrTime;
|
||||
QTime airspeedActualTime;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user