diff --git a/src/comm/MAVLinkSimulationMAV.cc b/src/comm/MAVLinkSimulationMAV.cc index b054e26bf4cc6dd44914723553c3d352406583c0..b6e762966d59ba6bfe46c5685dd71f5d02b8d027 100644 --- a/src/comm/MAVLinkSimulationMAV.cc +++ b/src/comm/MAVLinkSimulationMAV.cc @@ -158,6 +158,61 @@ void MAVLinkSimulationMAV::mainloop() // 25 Hz execution if (timer25Hz <= 0) { + + // Send a named value with name "FLOAT" and 0.5f as value + + // The message container to be used for sending + mavlink_message_t ret; + // The C-struct holding the data to be sent + mavlink_named_value_float_t val; + + // Fill in the data + // Name of the value, maximum 10 characters + // see full message specs at: + // http://pixhawk.ethz.ch/wiki/mavlink/ + strcpy(val.name, "FLOAT"); + // Value, in this case 0.5 + val.value = 0.5f; + + // Encode the data (adding header and checksums, etc.) + mavlink_msg_named_value_float_encode(systemid, MAV_COMP_ID_IMU, &ret, &val); + // And send it + link->sendMAVLinkMessage(&ret); + + // MICROCONTROLLER SEND CODE: + + // uint8_t buf[MAVLINK_MAX_PACKET_LEN]; + // int16_t len = mavlink_msg_to_send_buffer(buf, &ret); + // uart0_transmit(buf, len); + + + // SEND INTEGER VALUE + + // We are reusing the "mavlink_message_t ret" + // message buffer + + // The C-struct holding the data to be sent + mavlink_named_value_int_t valint; + + // Fill in the data + // Name of the value, maximum 10 characters + // see full message specs at: + // http://pixhawk.ethz.ch/wiki/mavlink/ + strcpy(valint.name, "INTEGER"); + // Value, in this case 18000 + valint.value = 18000; + + // Encode the data (adding header and checksums, etc.) + mavlink_msg_named_value_int_encode(systemid, MAV_COMP_ID_IMU, &ret, &valint); + // And send it + link->sendMAVLinkMessage(&ret); + + // MICROCONTROLLER SEND CODE: + + // uint8_t buf[MAVLINK_MAX_PACKET_LEN]; + // int16_t len = mavlink_msg_to_send_buffer(buf, &ret); + // uart0_transmit(buf, len); + timer25Hz = 2; } diff --git a/src/comm/MAVLinkSimulationWaypointPlanner.cc b/src/comm/MAVLinkSimulationWaypointPlanner.cc index c4e5f33f8f367184b9348370afed761318a003a0..645096b60abf00934f473ea4e619d5fcf402603b 100644 --- a/src/comm/MAVLinkSimulationWaypointPlanner.cc +++ b/src/comm/MAVLinkSimulationWaypointPlanner.cc @@ -563,7 +563,6 @@ void MAVLinkSimulationWaypointPlanner::mavlink_handler (const mavlink_message_t* case MAVLINK_MSG_ID_GLOBAL_POSITION_INT: { - qDebug() << "GOT GLOBAL POS" << "sys:" << msg->sysid << "wpid" << current_active_wp_id << "wpsize" << waypoints->size(); if(msg->sysid == systemid && current_active_wp_id < waypoints->size()) { mavlink_waypoint_t *wp = waypoints->at(current_active_wp_id); diff --git a/src/uas/UAS.cc b/src/uas/UAS.cc index 563bb86507d92280298c5285b9a70ff581cf2a1d..e5b78009b8771893ae2daa301c0b7d412c922148 100644 --- a/src/uas/UAS.cc +++ b/src/uas/UAS.cc @@ -162,11 +162,15 @@ void UAS::receiveMessageNamedValue(const mavlink_message_t& message) { if (message.msgid == MAVLINK_MSG_ID_NAMED_VALUE_FLOAT) { - + mavlink_named_value_float_t val; + mavlink_msg_named_value_float_decode(&message, &val); + emit valueChanged(this->getUASID(), QString(val.name), tr("raw"), val.value, getUnixTime(0)); } else if (message.msgid == MAVLINK_MSG_ID_NAMED_VALUE_INT) { - + mavlink_named_value_int_t val; + mavlink_msg_named_value_int_decode(&message, &val); + emit valueChanged(this->getUASID(), QString(val.name), tr("raw"), (float)val.value, getUnixTime(0)); } } @@ -190,6 +194,10 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) QString uasState; QString stateDescription; QString patternPath; + + // Receive named value message + receiveMessageNamedValue(message); + switch (message.msgid) { case MAVLINK_MSG_ID_HEARTBEAT: