altb_pmic / Mbed 2 deprecated Test_optical_flow_PX4

Dependencies:   mbed

Revision:
5:d97332d7f812
Parent:
4:77914e52baf3
Child:
6:db20dd57a30a
--- a/main.cpp	Wed Aug 28 11:43:15 2019 +0000
+++ b/main.cpp	Thu Aug 29 06:40:14 2019 +0000
@@ -3,6 +3,7 @@
 #include "LSM9DS1_i2c.h"
 #include "EncoderCounter.h"
 #include "DiffCounter.h"
+#include "TFmini.h"
 #define   pi 3.1415927f
 
 Serial pc(SERIAL_TX, SERIAL_RX);
@@ -26,6 +27,10 @@
 DiffCounter diffcounter(1/(2.0f*pi*30.0f), 0.005f);   // discrete differentiate, based on encoder data
 float velocity;
 
+RawSerial uart(PC_10, PC_11);
+TFmini tfmini(uart);
+float dist;
+
 int main()
 {
     i2c.frequency(400000);
@@ -45,6 +50,8 @@
     
     diffcounter.reset(0.0f,0.0f);
     velocity = 0.0f;
+    
+    dist = 0.0f;
 
     /**
     * uint16_t frame_count;       // counts created I2C frames 0
@@ -76,6 +83,8 @@
                 counts = encoder;
                 velocity = diffcounter(counts)*gain_encoder;
                 
+                dist = tfmini();
+                
                 dt = timer.read();
                 timer.reset();
                 
@@ -104,7 +113,7 @@
                 // compare gyros
                 // pc.printf("%i, %.3f, %.3f, %.3f, %.3f, %.3f, %.3f, %.3f; \r\n", counter, lsm_gyro[0], lsm_gyro[1], lsm_gyro[2], px4_gyro[0], px4_gyro[1], px4_gyro[2], 1.0f/dt);
                 // compare encoder and px4flow output
-                pc.printf("%i; %.3f; %.3i; %.3i; %.3i; %.3i; %.3i; %.3f \r\n", counter, velocity, -PX4.pixel_flow_y_sum(), -PX4.pixel_flow_x_sum(), -PX4.flow_comp_m_y(), -PX4.flow_comp_m_x(), PX4.qual(), 1.0f/dt);
+                pc.printf("%i; %.3f; %.3i; %.3i; %.3i; %.3i; %.3i; %.3f; %.3f \r\n", counter, velocity, -PX4.pixel_flow_y_sum(), -PX4.pixel_flow_x_sum(), -PX4.flow_comp_m_y(), -PX4.flow_comp_m_x(), PX4.qual(), dist, 1.0f/dt);
    
                 counter++;
                 wait_us(1600); // -> 200 Hz