2014-11-17 01:33:23 -04:00
|
|
|
/*
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* IRLock.h - IRLock Base Class for Ardupilot
|
|
|
|
*
|
|
|
|
* Created on: Nov 10, 2014
|
|
|
|
* Author: MLandes
|
|
|
|
*/
|
2016-02-17 21:25:31 -04:00
|
|
|
#pragma once
|
2014-11-17 01:33:23 -04:00
|
|
|
|
2015-08-28 05:12:27 -03:00
|
|
|
#include <AP_AHRS/AP_AHRS.h>
|
2014-11-17 01:33:23 -04:00
|
|
|
|
|
|
|
class IRLock
|
|
|
|
{
|
|
|
|
public:
|
2015-08-31 02:17:20 -03:00
|
|
|
// init - initialize sensor library
|
|
|
|
// library won't be useable unless this is first called
|
|
|
|
virtual void init() = 0;
|
2014-11-17 01:33:23 -04:00
|
|
|
|
2015-08-31 02:17:20 -03:00
|
|
|
// true if irlock sensor is online and healthy
|
|
|
|
bool healthy() const { return _flags.healthy; }
|
2014-11-17 01:33:23 -04:00
|
|
|
|
2015-08-31 02:17:20 -03:00
|
|
|
// timestamp of most recent data read from the sensor
|
2016-07-05 16:20:35 -03:00
|
|
|
uint32_t last_update_ms() const { return _last_update_ms; }
|
2014-11-17 01:33:23 -04:00
|
|
|
|
2015-08-31 02:17:20 -03:00
|
|
|
// returns the number of blocks in the current frame
|
2016-11-26 01:22:18 -04:00
|
|
|
size_t num_targets() const { return _flags.healthy?1:0; }
|
2014-11-17 01:33:23 -04:00
|
|
|
|
2015-08-31 02:17:20 -03:00
|
|
|
// retrieve latest sensor data - returns true if new data is available
|
|
|
|
virtual bool update() = 0;
|
2014-11-17 01:33:23 -04:00
|
|
|
|
2016-07-05 16:20:35 -03:00
|
|
|
// retrieve body frame x and y angles (in radians) to target
|
|
|
|
// returns true if data is available
|
|
|
|
bool get_angle_to_target_rad(float &x_angle_rad, float &y_angle_rad) const;
|
|
|
|
|
|
|
|
// retrieve body frame unit vector in direction of target
|
|
|
|
// returns true if data is available
|
|
|
|
bool get_unit_vector_body(Vector3f& ret) const;
|
|
|
|
|
2014-11-17 01:33:23 -04:00
|
|
|
|
|
|
|
protected:
|
2015-08-31 02:17:20 -03:00
|
|
|
struct AP_IRLock_Flags {
|
|
|
|
uint8_t healthy : 1; // true if sensor is healthy
|
|
|
|
} _flags;
|
|
|
|
|
|
|
|
// internals
|
2016-07-05 16:20:35 -03:00
|
|
|
uint32_t _last_update_ms;
|
2015-08-31 02:17:20 -03:00
|
|
|
|
|
|
|
// irlock_target_info is a duplicate of the PX4Firmware irlock_s structure
|
|
|
|
typedef struct {
|
2016-11-26 01:22:18 -04:00
|
|
|
uint32_t timestamp; // milliseconds since system start
|
2016-07-05 16:20:35 -03:00
|
|
|
float pos_x; // x-axis distance from center of image to center of target in units of tan(theta)
|
|
|
|
float pos_y; // y-axis distance from center of image to center of target in units of tan(theta)
|
|
|
|
float size_x; // size of target along x-axis in units of tan(theta)
|
|
|
|
float size_y; // size of target along y-axis in units of tan(theta)
|
2015-08-31 02:17:20 -03:00
|
|
|
} irlock_target_info;
|
|
|
|
|
2016-11-26 01:22:18 -04:00
|
|
|
irlock_target_info _target_info;
|
2014-11-17 01:33:23 -04:00
|
|
|
};
|