Close

Our first attempts to take control

A project log for Self Flying Quadcopter

A fun and educational project to convert a small quadcopter to a self-flying indoor drone.

george-albercookGeorge Albercook 12/12/2017 at 23:130 Comments

We want to start small with our transformation of an Eachine H8 mini into a zombie drone.  The idea is to add a distance sensor to the bottom of the quad and use the distance values to control the altitude.  Paul's first goal was to find the place in the code that waits for the throttle to increase the first time after the quad and controller have paired. He them inserted a call to the failloop() function when the throttle is increased. 

Within Silverware>scr there are several files that provide communication for different quads. There was one called drv_xn297_3wire.c within it Paul found a function xn_readpayload. Payload refers to the contents of the communication packet.  

He then searched within scr for all examples of xn_readpayload. He found that when the file rx_bayang_protocol_telemetry.c called xn_readpayload it communicated with our Eachine H8 mini. (Cleverly he did it by breaking them one at a time until he found the correct one).

Next he added the failloop to make it stop as soon as the throttle was increased.

The relevant part of the packet starts after 165

     if (rxdata[0] == 165)
                 rx[3] =
                     ((rxdata[8] & 0x0003) * 256 +
                      rxdata[9]) * 0.000976562f;
+     if (((rxdata[8] & 0x0003) * 256 + rxdata[9]) > 50 ) {
+     failloop(5);
+ }
 

He added the three lines starting with "+"

Discussions