Commit 91c1b826 authored by pixhawk's avatar pixhawk

merged

parent cf76aee3
...@@ -379,6 +379,15 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) ...@@ -379,6 +379,15 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
waypointManager.handleWaypoint(message.sysid, message.compid, &wp); waypointManager.handleWaypoint(message.sysid, message.compid, &wp);
} }
break; break;
case MAVLINK_MSG_ID_WAYPOINT_REQUEST:
{
mavlink_waypoint_request_t wpr;
mavlink_msg_waypoint_request_decode(&message, &wpr);
waypointManager.handleWaypointRequest(message.sysid, message.compid, &wpr);
}
break;
case MAVLINK_MSG_ID_WAYPOINT_REACHED: case MAVLINK_MSG_ID_WAYPOINT_REACHED:
{ {
// mavlink_waypoint_reached_t wp; // mavlink_waypoint_reached_t wp;
......
...@@ -11,39 +11,6 @@ UASWaypointManager::UASWaypointManager(UAS &_uas) ...@@ -11,39 +11,6 @@ UASWaypointManager::UASWaypointManager(UAS &_uas)
{ {
} }
void UASWaypointManager::waypointChanged(Waypoint*)
{
}
void UASWaypointManager::currentWaypointChanged(int)
{
}
void UASWaypointManager::removeWaypointId(int)
{
}
void UASWaypointManager::requestWaypoints()
{
if(current_state == WP_IDLE)
{
qDebug() << "handleWaypointCount";
mavlink_message_t message;
mavlink_waypoint_request_list_t wprl;
wprl.target_system = uas.getUASID();
wprl.target_component = MAV_COMP_ID_WAYPOINTPLANNER;
current_state = WP_GETLIST;
current_wp_id = 0;
current_partner_systemid = uas.getUASID();
current_partner_compid = MAV_COMP_ID_WAYPOINTPLANNER;
mavlink_msg_waypoint_request_list_encode(uas.mavlink->getSystemId(), uas.mavlink->getComponentId(), &message, &wprl);
uas.sendMessage(message);
}
}
void UASWaypointManager::handleWaypointCount(quint8 systemId, quint8 compId, quint16 count) void UASWaypointManager::handleWaypointCount(quint8 systemId, quint8 compId, quint16 count)
{ {
if (current_state == WP_GETLIST && systemId == current_partner_systemid && compId == current_partner_compid) if (current_state == WP_GETLIST && systemId == current_partner_systemid && compId == current_partner_compid)
...@@ -95,6 +62,7 @@ void UASWaypointManager::handleWaypoint(quint8 systemId, quint8 compId, mavlink_ ...@@ -95,6 +62,7 @@ void UASWaypointManager::handleWaypoint(quint8 systemId, quint8 compId, mavlink_
} }
else else
{ {
// all waypoints retrieved, change state to idle
current_state = WP_IDLE; current_state = WP_IDLE;
current_count = 0; current_count = 0;
current_wp_id = 0; current_wp_id = 0;
...@@ -104,16 +72,75 @@ void UASWaypointManager::handleWaypoint(quint8 systemId, quint8 compId, mavlink_ ...@@ -104,16 +72,75 @@ void UASWaypointManager::handleWaypoint(quint8 systemId, quint8 compId, mavlink_
} }
else else
{ {
//FIXME error handling //TODO: error handling
} }
} }
} }
void UASWaypointManager::getWaypoint(quint16 seq) void UASWaypointManager::handleWaypointRequest(quint8 systemId, quint8 compId, mavlink_waypoint_request_t *wpr)
{ {
if (systemId == current_partner_systemid && compId == current_partner_compid && current_state == WP_SENDLIST && wpr->seq == current_wp_id)
{
qDebug() << "handleWaypointRequest";
if (wpr->seq < 0)
{
//TODO: send waypoint
}
else
{
//TODO: Error message or something
}
}
} }
void UASWaypointManager::clearWaypointList() void UASWaypointManager::clearWaypointList()
{ {
}
void UASWaypointManager::currentWaypointChanged(int)
{
}
void UASWaypointManager::removeWaypointId(int)
{
}
void UASWaypointManager::requestWaypoints()
{
if(current_state == WP_IDLE)
{
qDebug() << "requestWaypoints";
mavlink_message_t message;
mavlink_waypoint_request_list_t wprl;
wprl.target_system = uas.getUASID();
wprl.target_component = MAV_COMP_ID_WAYPOINTPLANNER;
current_state = WP_GETLIST;
current_wp_id = 0;
current_partner_systemid = uas.getUASID();
current_partner_compid = MAV_COMP_ID_WAYPOINTPLANNER;
mavlink_msg_waypoint_request_list_encode(uas.mavlink->getSystemId(), uas.mavlink->getComponentId(), &message, &wprl);
uas.sendMessage(message);
}
}
void UASWaypointManager::sendWaypoints(void)
{
}
void UASWaypointManager::getWaypoint(quint16 seq)
{
}
void UASWaypointManager::waypointChanged(Waypoint*)
{
} }
...@@ -23,16 +23,18 @@ public: ...@@ -23,16 +23,18 @@ public:
void handleWaypointCount(quint8 systemId, quint8 compId, quint16 count); void handleWaypointCount(quint8 systemId, quint8 compId, quint16 count);
void handleWaypoint(quint8 systemId, quint8 compId, mavlink_waypoint_t *wp); void handleWaypoint(quint8 systemId, quint8 compId, mavlink_waypoint_t *wp);
void handleWaypointRequest(quint8 systemId, quint8 compId, mavlink_waypoint_request_t *wpr);
private: private:
void getWaypoint(quint16 seq); void getWaypoint(quint16 seq);
public slots: public slots:
void waypointChanged(Waypoint*); void clearWaypointList();
void currentWaypointChanged(int); void currentWaypointChanged(int);
void removeWaypointId(int); void removeWaypointId(int);
void requestWaypoints(); void requestWaypoints();
void clearWaypointList(); void sendWaypoints(void);
void waypointChanged(Waypoint*);
signals: signals:
void waypointUpdated(int,int,double,double,double,double,bool,bool); void waypointUpdated(int,int,double,double,double,double,bool,bool);
......
...@@ -89,9 +89,11 @@ void WaypointList::setUAS(UASInterface* uas) ...@@ -89,9 +89,11 @@ void WaypointList::setUAS(UASInterface* uas)
connect(&uas->getWaypointManager(), SIGNAL(waypointReached(UASInterface*,int)), this, SLOT(waypointReached(UASInterface*,int))); connect(&uas->getWaypointManager(), SIGNAL(waypointReached(UASInterface*,int)), this, SLOT(waypointReached(UASInterface*,int)));
connect(this, SIGNAL(waypointChanged(Waypoint*)), &uas->getWaypointManager(), SLOT(setWaypoint(Waypoint*))); connect(this, SIGNAL(waypointChanged(Waypoint*)), &uas->getWaypointManager(), SLOT(setWaypoint(Waypoint*)));
connect(this, SIGNAL(currentWaypointChanged(int)), &uas->getWaypointManager(), SLOT(setWaypointActive(int))); connect(this, SIGNAL(currentWaypointChanged(int)), &uas->getWaypointManager(), SLOT(setWaypointActive(int)));
// This slot is not implemented in UAS: connect(this, SIGNAL(removeWaypointId(int)), uas, SLOT(removeWaypoint(Waypoint*)));
connect(this, SIGNAL(requestWaypoints()), &uas->getWaypointManager(), SLOT(requestWaypoints())); connect(this, SIGNAL(requestWaypoints()), &uas->getWaypointManager(), SLOT(requestWaypoints()));
connect(this, SIGNAL(clearWaypointList()), &uas->getWaypointManager(), SLOT(clearWaypointList())); connect(this, SIGNAL(clearWaypointList()), &uas->getWaypointManager(), SLOT(clearWaypointList()));
// This slot is not implemented in UAS: connect(this, SIGNAL(removeWaypointId(int)), uas, SLOT(removeWaypoint(Waypoint*)));
qDebug() << "Requesting waypoints"; qDebug() << "Requesting waypoints";
emit requestWaypoints(); emit requestWaypoints();
} }
......
...@@ -53,30 +53,35 @@ class WaypointList : public QWidget { ...@@ -53,30 +53,35 @@ class WaypointList : public QWidget {
virtual ~WaypointList(); virtual ~WaypointList();
public slots: public slots:
void transmit();
void add();
void setWaypoint(int uasId, int id, double x, double y, double z, double yaw, bool autocontinue, bool current);
void setUAS(UASInterface* uas); void setUAS(UASInterface* uas);
void addWaypoint(Waypoint* wp);
void removeWaypointAndName(Waypoint* wp);
void redrawList(); void redrawList();
void moveUp(Waypoint* wp);
void moveDown(Waypoint* wp);
void setCurrentWaypoint(Waypoint* wp);
void reenableTransmit(); void reenableTransmit();
//UI Buttons
void saveWaypoints(); void saveWaypoints();
void loadWaypoints(); void loadWaypoints();
void transmit();
void add();
void moveUp(Waypoint* wp);
void moveDown(Waypoint* wp);
void setCurrentWaypoint(Waypoint* wp);
//To be moved to UASWaypointManager (?)
void setWaypoint(int uasId, int id, double x, double y, double z, double yaw, bool autocontinue, bool current);
void addWaypoint(Waypoint* wp);
void removeWaypointAndName(Waypoint* wp);
void waypointReached(UASInterface* uas, int waypointId); void waypointReached(UASInterface* uas, int waypointId);
protected: protected:
virtual void changeEvent(QEvent *e); virtual void changeEvent(QEvent *e);
void debugOutputWaypoints();
QVector<Waypoint*> waypoints; QVector<Waypoint*> waypoints;
QMap<int, QString> waypointNames; QMap<int, QString> waypointNames;
QMap<Waypoint*, WaypointView*> wpViews; QMap<Waypoint*, WaypointView*> wpViews;
QVBoxLayout* listLayout; QVBoxLayout* listLayout;
QTimer* transmitDelay; QTimer* transmitDelay;
UASInterface* uas; UASInterface* uas;
void debugOutputWaypoints();
private: private:
Ui::WaypointList *m_ui; Ui::WaypointList *m_ui;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment