I have decoded few custom messages in the MAVLinkProtocol.cc class in QGC and i want them to be printed on the MainToolBar.qml file
Can anyone guide as if my connection is done correctly in MultiVehicleManager.cc class
MAVLinkProtocol.cc class
else if (_message.msgid == MAVLINK_MSG_ID_DATA96) {
// Handle data96 message
mavlink_data96_t camData;
memset(camData.data, 0, sizeof(camData.data));
// camData.data[96]={0};
camData.len=96;
camData.type=1;
mavlink_msg_data96_decode(&_message, &camData);
memcpy(&zoomIndex16, camData.data + 7, sizeof(uint16_t));
zoomIndex = zoomIndex16 / 64;
// if (zoom <= 30 && zoom >= 1)
// cam_Zoom = convertToZoomLevel(zoomIndex);
// convertToFOV(zoomIndex);
memcpy(&camPitch, camData.data + 13, sizeof(float));
camPitch = camPitch * 180 / M_PI;
if (camPitch >= -180 && camPitch <= 180) {
cam_Pitch = -1 * camPitch;
}
memcpy(&camYaw, camData.data + 17, sizeof(float));
camYaw = camYaw * 180 / M_PI;
if (camYaw >= -180 && camYaw < 180){}
cam_Yaw = camYaw;
memcpy(&tgtDist, camData.data + 21, sizeof(float));
if (tgtDist > 0 && tgtDist <= 2000){}
tgt_Dist = tgtDist;
memcpy(&camTgtLat, camData.data + 57, sizeof(double));
camTgtLat = camTgtLat * 180 / M_PI;
if (camTgtLat >= -180 && camTgtLat <= 180){}
cam_Tgt_Lat = camTgtLat;
// qDebug() << "cam_Tgt_Lat: " << cam_Tgt_Lat;
memcpy(&camTgtLon, camData.data + 65, sizeof(double));
camTgtLon = camTgtLon * 180 / M_PI;
if (camTgtLon >= -180 && camTgtLon <= 180){}
cam_Tgt_Lon = camTgtLon;
// Emit a signal with the extracted values
emit data96Received(zoomIndex, cam_Pitch, cam_Yaw, tgt_Dist, cam_Tgt_Lat, cam_Tgt_Lon);
msgBox.exec();
}
and this is how i am connecting this in MultiVehicleManager.cc class
void MultiVehicleManager::onData96Received(int zoomIndex, float cam_Pitch, float cam_Yaw, float tgt_Dist, double cam_Tgt_Lat, double cam_Tgt_Lon)
{
if (qmlRootObject) {
QQmlContext* context = QQmlEngine::contextForObject(qmlRootObject);
if (context) {
QQmlEngine* engine = context->engine();
// Check if the engine is valid before proceeding
if (engine) {
// Update the visibility of the data in QML
QMetaObject::invokeMethod(qmlRootObject, "updateDataVisibility", Q_ARG(QVariant, true));
// Pass the data to QML (you need to define these properties in MainToolBar.qml)
QMetaObject::invokeMethod(qmlRootObject, "setData",
Q_ARG(QVariant, QVariant::fromValue(zoomIndex)),
Q_ARG(QVariant, QVariant::fromValue(cam_Pitch)),
Q_ARG(QVariant, QVariant::fromValue(cam_Yaw)),
Q_ARG(QVariant, QVariant::fromValue(tgt_Dist)),
Q_ARG(QVariant, QVariant::fromValue(cam_Tgt_Lat)),
Q_ARG(QVariant, QVariant::fromValue(cam_Tgt_Lon)));
}
}
}
}
could anyone please guide in this regard