Beagle Board - beagleboard.org
Damian GonzalezErik Welsh
Published

DIY QUADCOPTER (for all your droning needs)

Ever looked to the skies and wondered what it would be like to roam across the stars, look here to create your own 3d-printed drone!!!

IntermediateWork in progress20 hours251
DIY QUADCOPTER (for all your droning needs)

Things used in this project

Hardware components

Arduino Mega 2560
Arduino Mega 2560
×1
PocketBeagle
BeagleBoard.org PocketBeagle
×1
Brushless Motors
×4
Solo Propellers
3DR Solo Propellers
×10
ESC
×4

Software apps and online services

Arduino IDE
Arduino IDE
OpenCV
OpenCV
Visual Studio Code Extension for Arduino
Microsoft Visual Studio Code Extension for Arduino

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
Soldering Tools, Filters
Soldering Tools, Filters
Mastech MS8217 Autorange Digital Multimeter
Digilent Mastech MS8217 Autorange Digital Multimeter
Extraction Tool, 0.093" Commercial Pin & Socket Contacts
Extraction Tool, 0.093" Commercial Pin & Socket Contacts
Multitool, Screwdriver
Multitool, Screwdriver
Threaded Inserts
10 Pc. Jumper Wire Kit, 5 cm Long
10 Pc. Jumper Wire Kit, 5 cm Long
Set Screw, Pack of 10
Set Screw, Pack of 10

Story

Read more

Custom parts and enclosures

Drone Arms

These are the arms that are used in order to connect the motors to the body of the drone.

Middle Body

This the part of the body that will carry the Arduino. Make sure you print the other bodies to shield the Arduino and Pocketbeagle

Camera Body

This is the part of the body that will carry the pocketbeagle and thus will be instrumental to the livestream.

Top Cover

This will shield the Pocketbeagle, Arduino, and any exposed parts from the elements.

Camera Mount

This is what will hold the camera as we are flying.

Schematics

Pocketbeagle adapter

Fritzing Diagram for PocketBeagle

Arduino Motor Drone Fritzing Diagram

It shows how the ESCS and the brushless motors connect to the Arduino

Calibration Arduino ESCS

Code

ESC_Calibration

C/C++
This is the file that I used to calibrate the ESCS before flight. Essentially they make sure that they are in working order.
/** DAMIAN GONZALEZ 4/4/2022
 
 *     1. Plug your Arduino to your computer with USB cable, open terminal, then type 1 to send max throttle to every ESC to enter programming mode
 * 
 *     2. Power up your ESCs. You must hear "beep1 beep2 beep3" tones meaning the power supply is OK
 * 
 *     3. After 2sec, "beep beep" tone emits, meaning the throttle highest point has been correctly confirmed
 * 
 *     4. Type 0 to send min throttle
 * 
 *     5. Several "beep" tones emits, which means the quantity of the lithium battery cells (3 beeps for a 3 cells LiPo)
 *     6. A long beep tone emits meaning the throttle lowest point has been correctly confirmed
 
 *     7. Type 2 to launch test function. This will send min to max throttle to ESCs to test them
 */
// ---------------------------------------------------------------------------
#include <Servo.h>
// ---------------------------------------------------------------------------
// Customize here pulse lengths as needed
#define MIN_PULSE_LENGTH 1000 // Minimum pulse length in µs
#define MAX_PULSE_LENGTH 2000 // Maximum pulse length in µs
// ---------------------------------------------------------------------------
Servo motA, motB, motC, motD;
char data;
// ---------------------------------------------------------------------------

/**
 * This here is our main initialization loop that we run. 
 */
void setup() {
    Serial.begin(9600);
    
    motA.attach(4, MIN_PULSE_LENGTH, MAX_PULSE_LENGTH);
    motB.attach(5, MIN_PULSE_LENGTH, MAX_PULSE_LENGTH);
    motC.attach(6, MIN_PULSE_LENGTH, MAX_PULSE_LENGTH);
    motD.attach(7, MIN_PULSE_LENGTH, MAX_PULSE_LENGTH);
    
    displayInstructions();
}

/**
 * Main function
 */
void loop() {
    if (Serial.available()) {
        data = Serial.read();

        switch (data) {
            // 0
            case 48 : Serial.println("Sending minimum throttle");
                      motA.writeMicroseconds(MIN_PULSE_LENGTH);
                      motB.writeMicroseconds(MIN_PULSE_LENGTH);
                      motC.writeMicroseconds(MIN_PULSE_LENGTH);
                      motD.writeMicroseconds(MIN_PULSE_LENGTH);
            break;

            // 1
            case 49 : Serial.println("Sending maximum throttle");
                      motA.writeMicroseconds(MAX_PULSE_LENGTH);
                      motB.writeMicroseconds(MAX_PULSE_LENGTH);
                      motC.writeMicroseconds(MAX_PULSE_LENGTH);
                      motD.writeMicroseconds(MAX_PULSE_LENGTH);
            break;

            // 2
            case 50 : Serial.print("Running test in 3");
                      delay(1000);
                      Serial.print(" 2");
                      delay(1000);
                      Serial.println(" 1...");
                      delay(1000);
                      test();
            break;
        }
    }
    

}

/**
 * Test function: send min throttle to max throttle to each ESC.
 * Here once we press 2, the ESCS will each go from 0 to their max pulse (which should be 2000).
 */
void test()
{
    for (int i = MIN_PULSE_LENGTH; i <= MAX_PULSE_LENGTH; i += 5) {
        Serial.print("Pulse length = ");
        Serial.println(i);
        
        motA.writeMicroseconds(i);
        motB.writeMicroseconds(i);
        motC.writeMicroseconds(i);
        motD.writeMicroseconds(i);
        
        delay(200);
    }

    Serial.println("STOP");
    motA.writeMicroseconds(MIN_PULSE_LENGTH);
    motB.writeMicroseconds(MIN_PULSE_LENGTH);
    motC.writeMicroseconds(MIN_PULSE_LENGTH);
    motD.writeMicroseconds(MIN_PULSE_LENGTH);
}

/**
 * This is what will appear in the serial monitor when you first open it. 
 */
void displayInstructions()
{  
    Serial.println("READY - PLEASE SEND INSTRUCTIONS AS FOLLOWING :");
    Serial.println("\t0 : Send min throttle");
    Serial.println("\t1 : Send max throttle");
    Serial.println("\t2 : Run test function\n");
}

Camera New Code

Python
You can capture video here
import cv2
import numpy as np

# Create a VideoCapture object
cap = cv2.VideoCapture(0)

# Check if camera opened successfully
if (cap.isOpened() == False): 
  print("Unable to read camera feed")

# Default resolutions of the frame are obtained.The default resolutions are system dependent.
# We convert the resolutions from float to integer.
frame_width = int(cap.get(3))
frame_height = int(cap.get(4))
print('frame: width = {0} height = {1}'.format(frame_width,frame_height))
frame_width = 320
frame_height = 240
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 320)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 240)

# Define the codec and create VideoWriter object.The output is stored in 'outpy.avi' file.
out = cv2.VideoWriter('outpy.mp4',cv2.VideoWriter_fourcc(*'MP4V'), 10, (frame_width,frame_height))

print('Camera Set Up')

try:
  while(True):
    ret, frame = cap.read()
  
    if ret == True: 
      
      # Write the frame into the file 'output.avi'
      out.write(frame)
      print('Frame Written')
      
      # Display the resulting frame    
      #cv2.imshow('frame',frame)
  
      # Press Q on keyboard to stop recording
      if cv2.waitKey(1) & 0xFF == ord('q'):
        break
  
    # Break the loop
    else:
      break  

except KeyboardInterrupt:
  pass

# When everything done, release the video capture and video write objects
cap.release()
out.release()

# Closes all the frames
#cv2.destroyAllWindows() 

CameraLiveStream

Python
You run the code through the Cloud 9, then you have to open another file located on your directory called output.avi, in which you can see the livestream.
import cv2
import numpy as np

# Create a VideoCapture object
cap = cv2.VideoCapture(1)

# Check if camera opened successfully
if (cap.isOpened() == False): 
  print("Unable to read camera feed")

# Default resolutions of the frame are obtained.The default resolutions are system dependent.
# We convert the resolutions from float to integer.
frame_width = int(cap.get(3))
frame_height = int(cap.get(4))

# Define the codec and create VideoWriter object.The output is stored in 'outpy.avi' file.
out = cv2.VideoWriter('outpy.avi',cv2.VideoWriter_fourcc('M','J','P','G'), 10, (frame_width,frame_height))

while(True):
  ret, frame = cap.read()

  if ret == True: 
    
    # Write the frame into the file 'output.avi'
    out.write(frame)

    # Display the resulting frame    
    cv2.imshow('frame',frame)

    # Press Q on keyboard to stop recording
    if cv2.waitKey(1) & 0xFF == ord('q'):
      break

  # Break the loop
  else:
    break  

# When everything done, release the video capture and video write objects
cap.release()
out.release()

# Closes all the frames
cv2.destroyAllWindows() 

Credits

Damian Gonzalez

Damian Gonzalez

1 project • 0 followers
Erik Welsh

Erik Welsh

18 projects • 13 followers

Comments

Add projectSign up / Login