APM:Libraries
AP_OpticalFlow_test.cpp
Go to the documentation of this file.
1 /*
2  * Example of AP_OpticalFlow library.
3  * Code by Randy Mackay. DIYDrones.com
4  */
5 
6 #include <AP_AHRS/AP_AHRS.h>
7 #include <AP_Baro/AP_Baro.h>
9 #include <AP_GPS/AP_GPS.h>
10 #include <AP_HAL/AP_HAL.h>
12 #include <AP_NavEKF2/AP_NavEKF2.h>
13 #include <AP_NavEKF3/AP_NavEKF3.h>
16 
17 void setup();
18 void loop();
19 
21 
22 class DummyVehicle {
23 public:
32  NavEKF3 EKF3{&ahrs, sonar};
33 };
34 
36 static OpticalFlow optflow{vehicle.ahrs};
37 
38 void setup()
39 {
40  hal.console->printf("OpticalFlow library test ver 1.6\n");
41 
42  hal.scheduler->delay(1000);
43 
44  // flowSensor initialization
45  optflow.init();
46 
47  if (!optflow.healthy()) {
48  hal.console->printf("Failed to initialise PX4Flow ");
49  }
50 
51  hal.scheduler->delay(1000);
52 }
53 
54 void loop()
55 {
56  hal.console->printf("this only tests compilation succeeds\n");
57 
58  hal.scheduler->delay(5000);
59 }
60 
61 AP_HAL_MAIN();
NavEKF2 EKF2
Definition: AHRS_Test.cpp:29
Definition: AP_GPS.h:48
AP_SerialManager serial_manager
AP_HAL::UARTDriver * console
Definition: HAL.h:110
AP_HAL_MAIN()
AP_AHRS_NavEKF ahrs
Definition: AHRS_Test.cpp:31
AP_InertialSensor ins
void loop()
bool healthy() const
Definition: OpticalFlow.h:46
virtual void delay(uint16_t ms)=0
virtual void printf(const char *,...) FMT_PRINTF(2
Definition: BetterStream.cpp:5
static DummyVehicle vehicle
static OpticalFlow optflow
void setup()
RangeFinder sonar
Definition: AHRS_Test.cpp:28
const AP_HAL::HAL & hal
-*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
const HAL & get_HAL()
Catch-all header that defines all supported optical flow classes.
void init(void)
Definition: OpticalFlow.cpp:84
Catch-all header that defines all supported RangeFinder classes.
NavEKF3 EKF3
Definition: AHRS_Test.cpp:30
AP_HAL::Scheduler * scheduler
Definition: HAL.h:114