Issue #95 [XPlane] Get velocity data from xswiftbus in fast update timer timeout

This commit is contained in:
Mat Sutcliffe
2021-10-11 18:26:05 +01:00
parent 0faa7ed8fc
commit 3f57c66784
7 changed files with 233 additions and 0 deletions

View File

@@ -22,6 +22,14 @@ R"XML(<node>
<arg name="trueHeading" type="d" direction="out"/>
<arg name="qnh" type="d" direction="out"/>
</method>
<method name="getOwnAircraftVelocityData">
<arg name="x" type="d" direction="out"/>
<arg name="y" type="d" direction="out"/>
<arg name="z" type="d" direction="out"/>
<arg name="pitch" type="d" direction="out"/>
<arg name="roll" type="d" direction="out"/>
<arg name="heading" type="d" direction="out"/>
</method>
<method name="getOwnAircraftCom1Data">
<arg name="actv" type="i" direction="out"/>
<arg name="stby" type="i" direction="out"/>
@@ -137,6 +145,24 @@ R"XML(<node>
<method name="getTrueHeadingDeg">
<arg type="d" direction="out"/>
</method>
<method name="getLocalXVelocityMps">
<arg type="d" direction="out"/>
</method>
<method name="getLocalYVelocityMps">
<arg type="d" direction="out"/>
</method>
<method name="getLocalZVelocityMps">
<arg type="d" direction="out"/>
</method>
<method name="getPitchRadPerSec">
<arg type="d" direction="out"/>
</method>
<method name="getRollRadPerSec">
<arg type="d" direction="out"/>
</method>
<method name="getHeadingRadPerSec">
<arg type="d" direction="out"/>
</method>
<method name="getAnyWheelOnGround">
<arg type="b" direction="out"/>
</method>

View File

@@ -396,6 +396,27 @@ namespace XSwiftBus
sendDBusMessage(reply);
});
}
else if (message.getMethodName() == "getOwnAircraftVelocityData")
{
queueDBusCall([ = ]()
{
const double velocityX = m_velocityX.get();
const double velocityY = m_velocityY.get();
const double velocityZ = m_velocityZ.get();
const double pitchVelocity = m_pitchVelocity.get();
const double rollVelocity = m_rollVelocity.get();
const double headingVelocity = m_headingVelocity.get();
CDBusMessage reply = CDBusMessage::createReply(sender, serial);
reply.beginArgumentWrite();
reply.appendArgument(velocityX);
reply.appendArgument(velocityY);
reply.appendArgument(velocityZ);
reply.appendArgument(pitchVelocity);
reply.appendArgument(rollVelocity);
reply.appendArgument(headingVelocity);
sendDBusMessage(reply);
});
}
else if (message.getMethodName() == "getOwnAircraftCom1Data")
{
queueDBusCall([ = ]()
@@ -689,6 +710,48 @@ namespace XSwiftBus
sendDBusReply(sender, serial, getTrueHeadingDeg());
});
}
else if (message.getMethodName() == "getLocalXVelocityXMps")
{
queueDBusCall([ = ]()
{
sendDBusReply(sender, serial, getLocalXVelocityMps());
});
}
else if (message.getMethodName() == "getLocalYVelocityYMps")
{
queueDBusCall([ = ]()
{
sendDBusReply(sender, serial, getLocalYVelocityMps());
});
}
else if (message.getMethodName() == "getLocalZVelocityZMps")
{
queueDBusCall([ = ]()
{
sendDBusReply(sender, serial, getLocalZVelocityMps());
});
}
else if (message.getMethodName() == "getPitchRadPerSec")
{
queueDBusCall([ = ]()
{
sendDBusReply(sender, serial, getPitchRadPerSec());
});
}
else if (message.getMethodName() == "getRollRadPerSec")
{
queueDBusCall([ = ]()
{
sendDBusReply(sender, serial, getRollRadPerSec());
});
}
else if (message.getMethodName() == "getHeadingRadPerSec")
{
queueDBusCall([ = ]()
{
sendDBusReply(sender, serial, getHeadingRadPerSec());
});
}
else if (message.getMethodName() == "getAnyWheelOnGround")
{
queueDBusCall([ = ]()

View File

@@ -154,6 +154,20 @@ namespace XSwiftBus
//! Get aircraft true heading in degrees
double getTrueHeadingDeg() const { return m_heading.get(); }
//! Get aircraft local velocity in world coordinates meters per second
//! @{
double getLocalXVelocityMps() const { return m_velocityX.get(); }
double getLocalYVelocityMps() const { return m_velocityY.get(); }
double getLocalZVelocityMps() const { return m_velocityZ.get(); }
//! @}
//! Get aircraft angular velocity in radians per second
//! @{
double getPitchRadPerSec() const { return m_pitchVelocity.get(); }
double getRollRadPerSec() const { return m_rollVelocity.get(); }
double getHeadingRadPerSec() const { return m_headingVelocity.get(); }
//! @}
//! Get whether any wheel is on the ground
bool getAnyWheelOnGround() const { return m_onGroundAny.get(); }
@@ -347,6 +361,12 @@ namespace XSwiftBus
DataRef<xplane::data::sim::flightmodel::position::theta> m_pitch;
DataRef<xplane::data::sim::flightmodel::position::phi> m_roll;
DataRef<xplane::data::sim::flightmodel::position::psi> m_heading;
DataRef<xplane::data::sim::flightmodel::position::local_vx> m_velocityX;
DataRef<xplane::data::sim::flightmodel::position::local_vy> m_velocityY;
DataRef<xplane::data::sim::flightmodel::position::local_vz> m_velocityZ;
DataRef<xplane::data::sim::flightmodel::position::Prad> m_rollVelocity;
DataRef<xplane::data::sim::flightmodel::position::Qrad> m_pitchVelocity;
DataRef<xplane::data::sim::flightmodel::position::Rrad> m_headingVelocity;
DataRef<xplane::data::sim::flightmodel::failures::onground_any> m_onGroundAny;
DataRef<xplane::data::sim::flightmodel::failures::onground_all> m_onGroundAll;
DataRef<xplane::data::sim::cockpit2::radios::actuators::com1_frequency_hz_833> m_com1Active;