APM:Libraries
OpticalFlow_backend.cpp
Go to the documentation of this file.
1 /*
2  This program is free software: you can redistribute it and/or modify
3  it under the terms of the GNU General Public License as published by
4  the Free Software Foundation, either version 3 of the License, or
5  (at your option) any later version.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
12  You should have received a copy of the GNU General Public License
13  along with this program. If not, see <http://www.gnu.org/licenses/>.
14  */
15 
16 #include "OpticalFlow.h"
17 
18 extern const AP_HAL::HAL& hal;
19 
21  frontend(_frontend)
22 {
23  _sem = hal.util->new_semaphore();
24 }
25 
27 {
28  if (_sem) {
29  delete _sem;
30  }
31 }
32 
33 // update the frontend
35 {
38 }
39 
40 // apply yaw angle to a vector
42 {
43  float yawAngleRad = _yawAngleRad();
44  if (is_zero(yawAngleRad)) {
45  return;
46  }
47  float cosYaw = cosf(yawAngleRad);
48  float sinYaw = sinf(yawAngleRad);
49  float x = v.x;
50  float y = v.y;
51  v.x = cosYaw * x - sinYaw * y;
52  v.y = sinYaw * x + cosYaw * y;
53 }
void _applyYaw(Vector2f &v)
const AP_HAL::HAL & hal
-*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
Definition: AC_PID_test.cpp:14
AP_HAL::Util * util
Definition: HAL.h:115
virtual Semaphore * new_semaphore(void)
Definition: Util.h:108
uint32_t _last_update_ms
Definition: OpticalFlow.h:100
T y
Definition: vector2.h:37
#define x(i)
void _update_frontend(const struct OpticalFlow::OpticalFlow_state &state)
virtual ~OpticalFlow_backend(void)
bool is_zero(const T fVal1)
Definition: AP_Math.h:40
uint32_t millis()
Definition: system.cpp:157
OpticalFlow_backend(OpticalFlow &_frontend)
static int state
Definition: Util.cpp:20
struct OpticalFlow_state _state
Definition: OpticalFlow.h:98
float v
Definition: Printf.cpp:15
float _yawAngleRad(void) const
T x
Definition: vector2.h:37
AP_HAL::Semaphore * _sem