diff --git a/src/comm/QGCXPlaneLink.cc b/src/comm/QGCXPlaneLink.cc index b96046b5a82ce06b0ed37635c6b6ee668b733ec7..5ae7b592cf3df01f984bd1e88735d2106c21ec8d 100644 --- a/src/comm/QGCXPlaneLink.cc +++ b/src/comm/QGCXPlaneLink.cc @@ -292,15 +292,6 @@ void QGCXPlaneLink::updateActuators(uint64_t time, float act1, float act2, float void QGCXPlaneLink::updateControls(uint64_t time, float rollAilerons, float pitchElevator, float yawRudder, float throttle, uint8_t systemMode, uint8_t navMode) { - // Do not update this control type for - // all multirotors - if (mav->getSystemType() == MAV_TYPE_QUADROTOR || - mav->getSystemType() == MAV_TYPE_HEXAROTOR || - mav->getSystemType() == MAV_TYPE_OCTOROTOR) - { - return; - } - #pragma pack(push, 1) struct payload { char b[5]; @@ -315,7 +306,11 @@ void QGCXPlaneLink::updateControls(uint64_t time, float rollAilerons, float pitc p.b[3] = 'A'; p.b[4] = '\0'; - p.index = 12; + Q_UNUSED(time); + Q_UNUSED(systemMode); + Q_UNUSED(navMode); + + bool isFixedWing = true; if (mav->getAirframe() == UASInterface::QGC_AIRFRAME_X8 || mav->getAirframe() == UASInterface::QGC_AIRFRAME_VIPER_2_0 || @@ -329,31 +324,59 @@ void QGCXPlaneLink::updateControls(uint64_t time, float rollAilerons, float pitc // yaw p.f[2] = 0.0f; } + else if (mav->getSystemType() == MAV_TYPE_QUADROTOR) + { + qDebug() << "MAV_TYPE_QUADROTOR"; + + // Individual effort will be provided directly to the actuators on Xplane quadrotor. +#if 1 + p.f[0] = rollAilerons; + p.f[1] = pitchElevator; + p.f[2] = yawRudder; + p.f[3] = throttle; +#endif +#if 0 + p.f[0] = throttle; + p.f[1] = rollAilerons; + p.f[2] = pitchElevator; + p.f[3] = yawRudder; +#endif + isFixedWing = false; + } else { - // direct pass-through + // direct pass-through, normal fixed-wing. p.f[0] = -pitchElevator; p.f[1] = rollAilerons; p.f[2] = yawRudder; } - Q_UNUSED(time); - Q_UNUSED(systemMode); - Q_UNUSED(navMode); + if(isFixedWing) + { + // Ail / Elevon / Rudder + p.index = 12; // XPlane, wing sweep + writeBytes((const char*)&p, sizeof(p)); + + p.index = 8; // XPlane, joystick? why? + writeBytes((const char*)&p, sizeof(p)); + + p.index = 25; // Thrust + memset(p.f, 0, sizeof(p.f)); + p.f[0] = throttle; + p.f[1] = throttle; + p.f[2] = throttle; + p.f[3] = throttle; + + // Throttle + writeBytes((const char*)&p, sizeof(p)); + } + else + { + qDebug() << "Transmitting p.index = 25"; + p.index = 25; // XPlane, throttle command. + writeBytes((const char*)&p, sizeof(p)); + } - // Ail / Elevon / Rudder - writeBytes((const char*)&p, sizeof(p)); - p.index = 8; - writeBytes((const char*)&p, sizeof(p)); - - p.index = 25; - memset(p.f, 0, sizeof(p.f)); - p.f[0] = throttle; - p.f[1] = throttle; - p.f[2] = throttle; - p.f[3] = throttle; - // Throttle - writeBytes((const char*)&p, sizeof(p)); } Eigen::Matrix3f euler_to_wRo(double yaw, double pitch, double roll) { diff --git a/src/uas/UAS.cc b/src/uas/UAS.cc index 8c47c2acd2c3cc0f63217523ea8cc1af2b46854b..ac1f6895e549555b77e2bd3b531631ff897fae84 100644 --- a/src/uas/UAS.cc +++ b/src/uas/UAS.cc @@ -1326,6 +1326,7 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) } } break; +#if 0 case MAVLINK_MSG_ID_SERVO_OUTPUT_RAW: { mavlink_servo_output_raw_t raw; @@ -1340,6 +1341,7 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) } } break; +#endif #ifdef MAVLINK_ENABLED_PIXHAWK case MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE: {