4VehicleDistanceSensorFactGroup::VehicleDistanceSensorFactGroup(QObject *parent)
5 :
FactGroup(1000, QStringLiteral(
":/json/Vehicle/DistanceSensorFact.json"), parent)
7 _addFact(&_rotationNoneFact);
8 _addFact(&_rotationYaw45Fact);
9 _addFact(&_rotationYaw90Fact);
10 _addFact(&_rotationYaw135Fact);
11 _addFact(&_rotationYaw180Fact);
12 _addFact(&_rotationYaw225Fact);
13 _addFact(&_rotationYaw270Fact);
14 _addFact(&_rotationYaw315Fact);
15 _addFact(&_rotationPitch90Fact);
16 _addFact(&_rotationPitch270Fact);
17 _addFact(&_minDistanceFact);
18 _addFact(&_maxDistanceFact);
25 if (message.msgid != MAVLINK_MSG_ID_DISTANCE_SENSOR) {
29 mavlink_distance_sensor_t distanceSensor{};
30 mavlink_msg_distance_sensor_decode(&message, &distanceSensor);
32 struct orientation2Fact_s {
33 const MAV_SENSOR_ORIENTATION orientation;
37 const orientation2Fact_s rgOrientation2Fact[] = {
38 { MAV_SENSOR_ROTATION_NONE, rotationNone() },
39 { MAV_SENSOR_ROTATION_YAW_45, rotationYaw45() },
40 { MAV_SENSOR_ROTATION_YAW_90, rotationYaw90() },
41 { MAV_SENSOR_ROTATION_YAW_135, rotationYaw135() },
42 { MAV_SENSOR_ROTATION_YAW_180, rotationYaw180() },
43 { MAV_SENSOR_ROTATION_YAW_225, rotationYaw225() },
44 { MAV_SENSOR_ROTATION_YAW_270, rotationYaw270() },
45 { MAV_SENSOR_ROTATION_YAW_315, rotationYaw315() },
46 { MAV_SENSOR_ROTATION_PITCH_90, rotationPitch90() },
47 { MAV_SENSOR_ROTATION_PITCH_270, rotationPitch270() },
50 for (
const orientation2Fact_s &orientation2Fact : rgOrientation2Fact) {
51 if (orientation2Fact.orientation == distanceSensor.orientation) {
52 orientation2Fact.fact->setRawValue(distanceSensor.current_distance / 100.0);
57 minDistance()->setRawValue(distanceSensor.min_distance / 100.0);
58 maxDistance()->setRawValue(distanceSensor.max_distance / 100.0);
struct __mavlink_message mavlink_message_t
Used to group Facts together into an object hierarachy.
void _setTelemetryAvailable(bool telemetryAvailable)
A Fact is used to hold a single value within the system.