@@ -39,38 +39,59 @@ This file is part of the PIXHAWK project
#include <mavlink.h>
classUAS;
/**
* @brief Implementation of the MAVLINK waypoint protocol
*
* This class handles the communication with a waypoint manager on the MAV.
* All waypoints are stored in the QVector waypoints, modifications can be done with the WaypointList widget.
* Notice that currently the access to the internal waypoint storage is not guarded nor thread-safe. This works as long as no other widget alters the data.
*
* See http://qgroundcontrol.org/waypoint_protocol for more information about the protocol and the states.
*/
classUASWaypointManager:publicQObject
{
Q_OBJECT
private:
enumWaypointState{
WP_IDLE=0,
WP_SENDLIST,
WP_SENDLIST_SENDWPS,
WP_GETLIST,
WP_GETLIST_GETWPS
WP_IDLE=0,///< Waiting for commands
WP_SENDLIST,///< Initial state for sending waypoints to the MAV
WP_SENDLIST_SENDWPS,///< Sending waypoints
WP_GETLIST,///< Initial state for retrieving wayppoints from the MAV
WP_GETLIST_GETWPS,///< Receiving waypoints
WP_CLEARLIST,///< Clearing waypoint list on the MAV
WP_SETCURRENT///< Setting new current waypoint on the MAV
};///< The possible states for the waypoint protocol
public:
UASWaypointManager(UAS&);
UASWaypointManager(UAS&);///< Standard constructor.
QVector<Waypoint*>&getWaypointList(void){returnwaypoints;}///< Returns a reference to the local waypoint list. Gives full access to the internal data structure - Subject to change: Public const access and friend access for the waypoint list widget.
private:
voidsendWaypointRequest(quint16seq);
voidsendWaypoint(quint16seq);
voidsendWaypointClearAll();
voidsendWaypointSetCurrent(quint16seq);
voidsendWaypointCount();
voidsendWaypointRequestList();
voidsendWaypointRequest(quint16seq);///< Requests a waypoint with sequence number seq
voidsendWaypoint(quint16seq);///< Sends a waypoint with sequence number seq
voidsendWaypointAck(quint8type);///< Sends a waypoint ack
publicslots:
voidtimeout();
voidclearWaypointList();
voidrequestWaypoints();
voidsendWaypoints();
voidtimeout();///< Called by the timer if a response times out. Handles send retries.
voidsetCurrent(quint16seq);///< Sends the sequence number of the waypoint that should get the new target waypoint
voidclearWaypointList();///< Sends the waypoint clear all message to the MAV
voidreadWaypoints();///< Requests the MAV's current waypoint list
voidwriteWaypoints();///< Sends the local waypoint list to the MAV
signals:
voidwaypointUpdated(quint16,double,double,double,double,bool,bool,double,int);///< Adds a waypoint to the waypoint list widget
...
...
@@ -79,6 +100,7 @@ signals:
private:
UAS&uas;///< Reference to the corresponding UAS
quint32current_retries;///< The current number of retries left
quint16current_wp_id;///< The last used waypoint ID in the current protocol transaction
quint16current_count;///< The number of waypoints in the current protocol transaction
WaypointStatecurrent_state;///< The current protocol state