Add a GPS shim class that lets an external agent update the pseudo-GPS properties.

This should obsolete AP_GPS_HIL as it's a little more versatile (and it will generate cheaper code).


git-svn-id: https://arducopter.googlecode.com/svn/trunk@1336 f9c3cf11-9bcb-44bc-f272-b75c42450872
This commit is contained in:
DrZiplok 2010-12-28 23:27:12 +00:00
parent efd0f2dc57
commit 981c3e7570
2 changed files with 30 additions and 0 deletions

View File

@ -12,3 +12,4 @@
#include "AP_GPS_None.h"
#include "AP_GPS_Auto.h"
#include "AP_GPS_HIL.h"
#include "AP_GPS_Shim.h" // obsoletes AP_GPS_HIL, use in preference

View File

@ -0,0 +1,29 @@
// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: t -*-
//
// Shim GPS driver, for use when the actual GPS data is coming from somewhere else.
// Code by Mike Smith
//
// This library is free software; you can redistribute it and / or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
//
#ifndef AP_GPS_Shim_h
#define AP_GPS_Shim_h
#include <GPS.h>
class AP_GPS_Shim : public GPS {
public:
AP_GPS_Shim() : GPS(NULL) {}
virtual void init(void) {};
virtual bool read(void) { bool updated = _updated; _updated = false; return _updated };
/// Set-and-mark-updated macro for the public member variables; each instance
/// defines a member function set_<variable>(<type>)
/// #define __GPS_SHIM_SET(__name) void set_##__name(typeof(GPS::__name) v) { __name = v; _updated = true; } __GPS_SHIM_SET(time); __GPS_SHIM_SET(latitude); __GPS_SHIM_SET(longitude); __GPS_SHIM_SET(altitude); __GPS_SHIM_SET(ground_speed); __GPS_SHIM_SET(ground_course); __GPS_SHIM_SET(speed_3d); __GPS_SHIM_SET(hdop); #undef __GPS_SHIM_SET private:
bool _updated; ///< set anytime a member is updated, cleared when read() returns true
};
#endif // AP_GPS_HIL_H