William Burbidge
Created August 30, 2020 © GPL3+

Indoor UV Sanitization Drone

Story of the design of a Drone for sanitization of surfaces for Covid19 response. Designed for continued autonomous use without interaction.

AdvancedWork in progress41
Indoor UV Sanitization Drone

Story

Read more

Schematics

Basic schematic

A basic schematic showing how the main elements of the electronics connect with each other.

Incomplete CAD Design file

Power distribution schematic

This is the schematic for the DC-DC converter board before the Current sharing was implemented (as seen on the PCB design).

BOM

Several incomplete BOM files, the FInal BOM page has the components used on the power distribution board.

Power distribution PCB all layers

Power distribution PCB top layers

Power distribution PCB bottom layer

Incomplete base station schematic

Code

Unity drone time of flight code

C#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TofSenseCone : MonoBehaviour
{
	public Transform target;
	public Collider cone;
	public Collider plane;
	public int angle;
	private int runThrough1;
	private int runThrough2;
	private bool sectionDone;
	
	private int pos1;
	private int pos2;
	private int distance;	
	
    // Start is called before the first frame update
    void Start()
    {
        angle = 20;
        runThrough1 = 0;
        
    }

    // Update is called once per frame
    void Update()
    {
    	// For each 180 degree runthrough there needs to be 9 scans.
    	// There then needs to be 9 scans for the other axis, leading to 81 in total
    	// This should take under 3 seconds, which isnt the quickest.
    	// If scan is made to be 2sqm that would be better.
    	if (sectionDone == false){
			if (runThrough2 < 9){
				if (runThrough1 < 9){
					transform.RotateAround(target.transform.position, Vector3.left, angle);
					if (cone.bounds.Intersects(plane.bounds))
					{
						Debug.Log("Bounds intersecting");
						// Work out point to add to file based on current rotation of the sensor. The sensor would output the distance to this, so I will find a premade function that will give this distance.
						if (angle > 0){
							pos1 = 0;
							pos2 = 0;
						}
						else{
							pos1 = 180;
							pos2 = 180;
						}
						pos1 = pos1 + ((runThrough1+1) * angle); // Distance from side edge.
						pos2 = pos2 + ((runThrough2+1) * angle); // Distance along
						Debug.Log(pos1);
						Debug.Log(pos2);
					}
					runThrough1 += 1;
				}
				else{
					transform.RotateAround(target.transform.position, Vector3.up, angle);
					runThrough2 += 1;
					runThrough1 = 0;
					angle = (-angle);
				}
			}
			else{
				//sectionDone = true;
				Debug.Log("One runthrough done");
				runThrough2 = 0;
				transform.RotateAround(target.transform.position, Vector3.up, 180);
			}
		}
    }
}

Unity drone mapping and stabilization script

C#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ZoneMover : MonoBehaviour
{
	public Transform forRight;
	public Transform forLeft;
	public Transform baRight;
	public Transform baLeft;
	public Rigidbody body;
	private bool left;
	private bool right;
	private bool forward;
	private bool back;
	private bool up;
	private bool down;
	private bool rotLeft;
	private bool rotRight;
	private float force;
	private float stabFor;
	private Vector3 leftRightRot;
	
	// New variables
	private float xCoor;
	private float yCoor;
	private float zCoor;
	private float goToX;
	private float goToY;
	private float goToZ;
	private float oldX;
	private float oldY;
	private float oldZ;
	
	private int moveCycle;
	
	void Start(){
		force = 9.81f;
		stabFor = 0.2f;
		
		leftRightRot = new Vector3(0, 100, 0);
		
		goToX = 10.0f;
		goToY = 10.0f;
		goToZ = 10.0f;
		
		moveCycle = 0;
	}

    // Update is called once per frame
    void Update()
    {
    	xCoor = body.transform.position.x;
    	yCoor = body.transform.position.y;
    	zCoor = body.transform.position.z;
    	
	if (body.velocity.y > 0.01){ //Stabilises it along its upwards direction.
	    	body.AddForceAtPosition(body.transform.up*-force*stabFor, forLeft.position);
		body.AddForceAtPosition(body.transform.up*-force*stabFor, baLeft.position);
		body.AddForceAtPosition(body.transform.up*-force*stabFor, forRight.position);
		body.AddForceAtPosition(body.transform.up*-force*stabFor, baRight.position);
	}
	if (body.velocity.y < -0.01){ //Stabilises it along its upwards direction.
	    	body.AddForceAtPosition(body.transform.up*force*stabFor, forLeft.position);
		body.AddForceAtPosition(body.transform.up*force*stabFor, baLeft.position);
		body.AddForceAtPosition(body.transform.up*force*stabFor, forRight.position);
		body.AddForceAtPosition(body.transform.up*force*stabFor, baRight.position);
	}
    	
    	// New script for getting to right position
    	if (moveCycle >= 0 && moveCycle < 9){
	    	if (body.rotation.z < 0.5f && body.rotation.z > -0.5f){
		    	if (xCoor < goToX) {
		    		if (body.velocity.x < 1){// && oldX <= xCoor){ // This value needs to be looked at.
		    			right = true;
		    		}
		    		if (body.velocity.x > 1){
		    			left = true;
		    		}
		    	}
		    	else{
		    		if (body.velocity.x > -1){// && oldX >= xCoor){ // This value needs to be looked at.
		    			left = true; 
		    		}
		    		if (body.velocity.x < -1){
		    			right = true;
		    		}
		    	}
	    	}
    	}
    	
    	if (moveCycle >= 13 && moveCycle < 21){
	    	if (body.rotation.x < 0.5f && body.rotation.x > -0.5f){
		    	if (zCoor < goToZ) {
		    		if (body.velocity.z < 1){// && oldX <= xCoor){ // This value needs to be looked at.
		    			forward = true;
		    		}
		    		if (body.velocity.z > 1){
		    			back = true;
		    		}
		    	}
		    	else{
		    		if (body.velocity.z > -1){// && oldX >= xCoor){ // This value needs to be looked at.
		    			back = true; 
		    		}
		    		if (body.velocity.z < -1){
		    			forward = true;
		    		}
		    	}
	    	}
    	}
    	
    	if (moveCycle >= 25 && moveCycle < 33){
	    	if (yCoor < goToY) {
	    		if (body.velocity.y < 1){// && oldX <= xCoor){ // This value needs to be looked at.
	    			up = true;
	    			Debug.Log("Y needs to increase");
	    		}
	    		if (body.velocity.y > 1){
	    			down = true;
	    			Debug.Log("Y up too high");
	    		}
	    	}
	    	else{
	    		if (body.velocity.y > -1){// && oldX >= xCoor){ // This value needs to be looked at.
	    			down = true; 
	    			Debug.Log("YYYY DOWN");
	    		}
	    		if (body.velocity.y < -1){
	    			up = true;
	    			Debug.Log("YYY Up");
	    		}
	    	}
    	}
    	
	/*
    	if (yCoor < goToY) {
    		up = true;
    	}
    	else{
    		down = true; 
    	}
    	
    	if (body.rotation.x < 0.5f && body.rotation.x > -0.5f){
    		Debug.Log(body.rotation.x);
	    	if (zCoor < goToZ) {
	    		forward = true;
	    	}
	    	else{
	    		back = true; 
	    	}
    	}*/
    
    	// Old script for stabilisation
    	/*if (left > 0){
    		if (left == 1){
    			body.AddForceAtPosition(body.transform.up*6, forRight.position);
    			body.AddForceAtPosition(body.transform.up*6, baRight.position);
    		}
    		left += 1;
    		if (left == 10){
    			left = 0;
    			body.AddForceAtPosition(body.transform.up*-6, forRight.position);
    			body.AddForceAtPosition(body.transform.up*-6, baRight.position);
    		}
        }*/
        if (left == true){
    		body.AddForceAtPosition(body.transform.up*2, forRight.position);
    		body.AddForceAtPosition(body.transform.up*2, baRight.position);
    		left = false;
        }
        if (right == true){
    		body.AddForceAtPosition(body.transform.up*2, forLeft.position);
    		body.AddForceAtPosition(body.transform.up*2, baLeft.position);
    		right = false;
        }
        if (forward == true){
    		body.AddForceAtPosition(body.transform.up*2, baRight.position);
    		body.AddForceAtPosition(body.transform.up*2, baLeft.position);
    		forward = false;
        }
        if (back == true){
    		body.AddForceAtPosition(body.transform.up*2, forRight.position);
    		body.AddForceAtPosition(body.transform.up*2, forLeft.position);
    		back = false;
        }
        if (up == true){
    		body.AddForceAtPosition(body.transform.up*force*2, forRight.position);
    		body.AddForceAtPosition(body.transform.up*force*2, forLeft.position);
    		body.AddForceAtPosition(body.transform.up*force*2, baRight.position);
    		body.AddForceAtPosition(body.transform.up*force*2, baLeft.position);
    		up = false;
        }
        if (down == true){
    		body.AddForceAtPosition(body.transform.up*force*-2, forRight.position);
    		body.AddForceAtPosition(body.transform.up*force*-2, forLeft.position);
    		body.AddForceAtPosition(body.transform.up*force*-2, baRight.position);
    		body.AddForceAtPosition(body.transform.up*force*-2, baLeft.position);
    		down = false;
        }
        if (rotLeft == true){
        	Quaternion rotationQ = Quaternion.Euler(-leftRightRot * Time.deltaTime);
        	body.MoveRotation(body.rotation * rotationQ);
        	rotLeft = false;
        }
        if (rotRight == true){
        	Quaternion rotationQ = Quaternion.Euler(leftRightRot * Time.deltaTime);
        	body.MoveRotation(body.rotation * rotationQ);
        	rotRight = false;
        }
        // If rotating to right, z angular velocity will increase, if to front, x ang vel will increase
        if (body.angularVelocity.z < -0.9){
        	body.AddForceAtPosition(body.transform.up*3, forRight.position);
		body.AddForceAtPosition(body.transform.up*3, baRight.position);
        }
        if (body.angularVelocity.z > 0.9){
        	body.AddForceAtPosition(body.transform.up*3, forLeft.position);
		body.AddForceAtPosition(body.transform.up*3, baLeft.position);
        }
        if (body.angularVelocity.x > -0.9){
        	body.AddForceAtPosition(body.transform.up*3, forLeft.position);
		body.AddForceAtPosition(body.transform.up*3, forRight.position);
        }
        if (body.angularVelocity.x < 0.9){
        	body.AddForceAtPosition(body.transform.up*3, baLeft.position);
		body.AddForceAtPosition(body.transform.up*3, baRight.position);
        }
        if (body.angularVelocity.z > -0.9 && body.angularVelocity.z < 0.9){
        	if (body.rotation.z > 0){
        		body.AddForceAtPosition(body.transform.up*2*stabFor, forLeft.position);
			body.AddForceAtPosition(body.transform.up*2*stabFor, baLeft.position);
		}
		if (body.rotation.z < 0){
        		body.AddForceAtPosition(body.transform.up*2*stabFor, forRight.position);
			body.AddForceAtPosition(body.transform.up*2*stabFor, baRight.position);
		}
        }
        if (body.angularVelocity.x > -0.9 && body.angularVelocity.x < 0.9){
        	if (body.rotation.x < 0){
        		body.AddForceAtPosition(body.transform.up*2*stabFor, baRight.position);
			body.AddForceAtPosition(body.transform.up*2*stabFor, baLeft.position);
		}
		if (body.rotation.x > 0){
        		body.AddForceAtPosition(body.transform.up*2*stabFor, forRight.position);
			body.AddForceAtPosition(body.transform.up*2*stabFor, forLeft.position);
		}
        }
        
        oldX = body.transform.position.x;
    	oldY = body.transform.position.y;
    	oldZ = body.transform.position.z;
    	
    	if (moveCycle < 37){
    		moveCycle += 1;
    	}
    	else{
    		moveCycle = 0;
    	}
    }
    
    void OnGUI()
    {

        if (GUI.Button(new Rect(10, 70, 50, 50), "Left"))
            left = true;

        if (GUI.Button(new Rect(130, 70, 50, 50), "Right"))
            right = true;
            
        if (GUI.Button(new Rect(70, 10, 50, 50), "Forward"))
            forward = true;

        if (GUI.Button(new Rect(70, 130, 50, 50), "Back"))
            back = true;
            
        if (GUI.Button(new Rect(70, 200, 50, 50), "Up"))
            up = true;

        if (GUI.Button(new Rect(70, 260, 50, 50), "Down"))
            down = true;
        
        if (GUI.Button(new Rect(10, 330, 50, 50), "Rot Left"))
            rotLeft = true;

        if (GUI.Button(new Rect(130, 330, 50, 50), "Rot Right"))
            rotRight = true;
    }
}

Credits

William Burbidge

William Burbidge

1 project • 1 follower
Hi! I am a student who is about to begin university to study Medical Engineering. I am motivated in electronics work which does some good.

Comments