2015-01-02 04:30:32 -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/>.
|
|
|
|
*/
|
|
|
|
|
2021-12-23 20:05:30 -04:00
|
|
|
#include "AP_OpticalFlow.h"
|
2015-01-02 04:30:32 -04:00
|
|
|
|
2021-12-24 01:47:21 -04:00
|
|
|
#if AP_OPTICALFLOW_ENABLED
|
|
|
|
|
2015-01-02 04:30:32 -04:00
|
|
|
extern const AP_HAL::HAL& hal;
|
|
|
|
|
2022-08-14 22:31:14 -03:00
|
|
|
OpticalFlow_backend::OpticalFlow_backend(AP_OpticalFlow &_frontend) :
|
2016-11-04 20:00:49 -03:00
|
|
|
frontend(_frontend)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-11-18 05:56:05 -04:00
|
|
|
OpticalFlow_backend::~OpticalFlow_backend(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-01-02 04:30:32 -04:00
|
|
|
// update the frontend
|
2022-08-14 22:31:14 -03:00
|
|
|
void OpticalFlow_backend::_update_frontend(const struct AP_OpticalFlow::OpticalFlow_state &state)
|
2015-01-02 04:30:32 -04:00
|
|
|
{
|
2018-09-02 09:27:29 -03:00
|
|
|
frontend.update_state(state);
|
2015-01-02 04:30:32 -04:00
|
|
|
}
|
2016-11-19 17:22:02 -04:00
|
|
|
|
|
|
|
// apply yaw angle to a vector
|
|
|
|
void OpticalFlow_backend::_applyYaw(Vector2f &v)
|
|
|
|
{
|
|
|
|
float yawAngleRad = _yawAngleRad();
|
|
|
|
if (is_zero(yawAngleRad)) {
|
|
|
|
return;
|
|
|
|
}
|
2023-07-13 21:43:55 -03:00
|
|
|
v.rotate(yawAngleRad);
|
2016-11-19 17:22:02 -04:00
|
|
|
}
|
2021-12-24 01:47:21 -04:00
|
|
|
|
|
|
|
#endif
|