MAVLinkSimulationMAV.cc 937 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <QDebug>

#include "MAVLinkSimulationMAV.h"

MAVLinkSimulationMAV::MAVLinkSimulationMAV(MAVLinkSimulationLink *parent, int systemid) :
    QObject(parent),
    link(parent),
    planner(parent, systemid),
    systemid(systemid)
{
    connect(&mainloopTimer, SIGNAL(timeout()), this, SLOT(mainloop()));
    mainloopTimer.start(1000);
    connect(link, SIGNAL(messageReceived(mavlink_message_t)), this, SLOT(handleMessage(mavlink_message_t)));
    mainloop();
}

void MAVLinkSimulationMAV::mainloop()
{
    mavlink_message_t msg;
20
    mavlink_msg_heartbeat_pack(systemid, MAV_COMP_ID_IMU, &msg, MAV_FIXED_WING, MAV_AUTOPILOT_SLUGS);
21 22 23 24 25 26 27 28 29 30 31 32 33
    link->sendMAVLinkMessage(&msg);
}

void MAVLinkSimulationMAV::handleMessage(const mavlink_message_t& msg)
{
    qDebug() << "MAV:" << systemid << "RECEIVED MESSAGE FROM" << msg.sysid << "COMP" << msg.compid;

    switch(msg.msgid)
    {
    case MAVLINK_MSG_ID_ATTITUDE:
        break;
    }
}