2014-11-17 01:33:23 -04:00
|
|
|
/*
|
2025-02-06 03:00:13 -04:00
|
|
|
* AP_IRLock.cpp
|
2014-11-17 01:33:23 -04:00
|
|
|
*
|
|
|
|
* Created on: Nov 12, 2014
|
|
|
|
* Author: MLandes
|
|
|
|
*/
|
|
|
|
|
2025-02-06 06:23:54 -04:00
|
|
|
#include "AP_IRLock_config.h"
|
|
|
|
|
|
|
|
#if AP_IRLOCK_ENABLED
|
|
|
|
|
2025-02-06 05:57:36 -04:00
|
|
|
#include "AP_IRLock.h"
|
2014-11-17 01:33:23 -04:00
|
|
|
|
2016-07-05 16:20:35 -03:00
|
|
|
// retrieve body frame unit vector in direction of target
|
|
|
|
// returns true if data is available
|
2025-02-06 06:09:20 -04:00
|
|
|
bool AP_IRLock::get_unit_vector_body(Vector3f& ret) const
|
2016-07-05 16:20:35 -03:00
|
|
|
{
|
|
|
|
// return false if we have no target
|
2016-11-26 01:22:18 -04:00
|
|
|
if (!_flags.healthy) {
|
2016-07-05 16:20:35 -03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// use data from first (largest) object
|
2016-11-26 01:22:18 -04:00
|
|
|
ret.x = -_target_info.pos_y;
|
|
|
|
ret.y = _target_info.pos_x;
|
2019-02-12 07:08:28 -04:00
|
|
|
ret.z = _target_info.pos_z;
|
2016-07-05 16:20:35 -03:00
|
|
|
ret /= ret.length();
|
|
|
|
return true;
|
2016-11-26 01:22:18 -04:00
|
|
|
}
|
2025-02-06 06:23:54 -04:00
|
|
|
|
|
|
|
#endif // AP_IRLOCK_ENABLED
|