Command centers need to know where their people are and where danger exists and may be approaching them. This system tracks fire boundaries & fire hotspots and firefighters or other persons on-the-ground and relays this data back to command centers where it is mapped in real time.
The drone roams via a planned route above a fire zone recognizing personnel, hotspots and fire movement using an on-board IR camera, HD camera, and local AI processing unit via an on-board Google AI Tensorflow Processing Unit (TPU) chip.
Both on-ground firefighters & remote CCC personnel can stream the HD+IR video stream to see a live overhead view of the situation in real time.
The drone has on-board sensors whose data is mapped in real time covering carbon dioxide, oxygen, temperature, humidity, barometric pressure, and light lux levels. CCC personnel can check to see if gas levels rise above safe maximums or minimums so they can inform ground personnel to unseen dangers not revealed by the IR+HD camera streams.
SystemFeatures
On-board Wi-Fi Access Point for access to video streams by ground personnel
On-board Cellular Modem to stream data to remote command & control center
Infrared Camera low-def video stream
Visual camera high-def video stream
AI detection of persons & objects on-the-ground from high-def video stream
Live visual view of fire boundaries, hotspots, and people via Wi-Fi and cellular link
Live report of temperature, barometric pressure, CO, CO2 and O2 gas levels
Automatic landing system
Automatic charging system
Automatic Landing SystemWe 3D printed a low-profile battery holder and mounted the Pixycam2 and a low-cost IR distance sensor on the underside. A spare grounding mat was re-tasked as a landing platform. A landing marker using three different colored blocks was created on the grounding mat and the Pixycam2 was taught to recognize and report the x-y coordinate boundaries of each block.
The Pixycam2 is connected to the FMU66 I2C connector. We wanted to connect the IR "lidar" distance sensor to the Telem2 UART on the FMUK66 but unfortunately this port is in use as the Mavlink remote port to the Coral-dev board over the USB interface. So instead we connected the downward facing distance sensor to a spare USB port on the Coral via a PL2303 USB-to-UART cable and sent the data to the PX4 firmware using the mavlink protocol.
This system functions similar to the IR-LOCK landing system that used an original Pixycam with the IR filter stripped off. The Pixycam2 protocol is different than the original Pixycam and our system recognizes multiple objects for more precise x-y orientation on landing and to allow us to create a z-coordinate estimate for height. We used a spare grounding mat as our landing platform and create three 10cm square blocks using colored Duct tape.
Because we know the dimensions of the colored blocks recognized by the Pixycam2 we can use this as a distance marker. The TFMini "lidar" system (which is not really lidar but rather a time-of-flight IR sensor) is redundant but adds additional height data that is averaged with that from our Pixycam2 PX4 driver. We trained the Pixycam2 to recognize the blocks with labels "Top", "Right" and "Left".
We re-tasked the original code from the IR-LOCK PX4 driver, modified it for the Pixycam2 protocol and added code to orient the drone in x-y coordinates from three recognized color blocks instead of the IR-LOCK's single target. We also added code to calculate a z-coordinate using the Pixycam2's x-y coordinates which gave us the size of the recognized blocks as we approach the landing pad. This z-distance is used to augment the TFMini "Lidar" sensor data sent over Mavlink from the Coral Dev board companion computer.
The C++ PX4 driver code for the Pixycam2 automatic landing system is available in our Hovergames PX4 git repo fork.
Automatic Charging SystemWe received a basic LiPo charger with the hovergames kit that charges 3s or 4s LiPo batteries over a 4-pin or 5-pin connector. Our drone is powered from a 3s LiPo battery which uses four wires for charging. We used copper tape to create four landing pads on the Pixyxam2 landing mat that mate to four copper taped sections on the drone's landing gear.
The Pixycam2 landing system has a resolution of ~10cm (2.5") so we created four 10cm square copper foil charging pads and fed them back to the charger via copper tape traces we laid out on the landing pad. When the Pixycam2 precision landing system takes over and positions the drone over the landing pad it also centers the charging contacts over the charging pads. When the drone lands it automatically begins charging for its next mission.
A fully operational version of the system could use two drones with one always in the air while its counterpart charges its battery to provide continuous airborne coverage. Ideally they would be linked via a W-Fi mesh network (the QCA6174 Wi-Fi chip on the Coral Dev board is mesh capable) and the incoming drone could signal its partner to take over so a drone is always in the air providing coverage.
Coral Dev Board AI Sensor SystemFreescale and Google created the Coral development board that also has a high-def camera and a sensor board as options. The Coral dev board includes a Google Tensorflow Processing Unit or TPU on the PCB connected to the i.MX8 M quad core ARM Cortex-A53 CPUs over the PCIe bus. Google and Freescale have created a Debian 10 "Buster" derived Linux OS for this board called Mendel. The Coral Dev board is powered from a USB-C connector so we created our own cable to power the board from the drone's battery.
We re-tasked the Coral dev board's QCA6174 Wi-Fi chip as an Access Point. Anyone with a smartphone can connect and access the web pages of the AI sensor and video stream system. We modified dnsmasq to automatically redirect any web request to the on-board Python web server code we created for this project, so a web request to http://<any URL> will redirect to our Python Flask local web server.
The Coral board's high-def camera was augmented by a USB FLIR infrared camera. We created a Python script that uses OpenCV and the i.MX8 M SoC CPU's video stream processing hardware to stream video from the high-def visual camera and the IR cameras to a web page served by the drone. The cameras are mounted on a low-cost Pimoroni pan-tilt HAT connected to the Coral dev board's I2C pins. Code to move the pan-tilt HAT was added and incorporated into our Python web server code so a user can move the cameras over from the web page.
The Coral sensor board comes with temperature, humidity, pressure and ambient light sensors. We added O2, CO2 and CO sensors to the Grove connectors on the sensor board and wrote Python code to record the percent O2 and parts-per-million of CO2, CO and volatile organic compounds in the air around the drone. These sensors are critical for sensing danger zones around firefighters and report a live stream of this data.
We used the Coral Dev board 3D printed case found at Thingiverse and modified the top portion for the Coral Sensor board that fits onto the Coral Dev board.
https://www.thingiverse.com/thing:4133970
We trained the on-board Google TPU to recognize human beings and objects from images and draw bounding boxes around them in the high-def video stream. This capability provides live reports of the location of emergency services personnel or people in need of help during an emergency. Combined with the IR camera feed and sensor data this should allow rapid response to hot-spots or other dangers in real time.
Training the Google TPU to Recognize Objects & PeopleThe on-board Tensorflow Processing Unit or TPU must be trained to recognize objects or, in our case, human beings from the on-board high-def camera video stream. The TPU runs an embedded version of Google's Tensorflow machine learning framework called Tensorflow Lite. We set up a Tensorflow training system on a workstation with an Nvidia GPU. We used the Pascal Visual Object Classes (VOC) data set found at http://host.robots.ox.ac.uk/pascal/VOC/index.html to train our system to recognize objects and people.
The TPU on the Coral-Dev board supports a subset of Tensorflow deepnet topologies. We chose the mobilnet_v1_ssd topology due to its direct mapping for use by the TPU. The training system is written in Tensorflow Python and trains the network on the VOC dataset into a.pb file. We used the TensorFlow Lite tools to convert the.pb deep network into a Tensorflow Lite structure and then compiled it with the TPU utilities for use on the Google TPU silicon. The system recognizes and counts the number of human beings it sees via the high-def Coral Dev camera. This count is maintained per-flight so someone viewing the drone's web page can see the accumulated human beings seen during its latest flight. Boxes are drawn live around humans recognized on the ground as the drone flies overhead.
Google has created and pre-trained Tensorflow models for object detection and classifying so you don't have to build a model from scratch. See the Coral Docuemention page under pre-trained models. We used the Google instructions to set up re-training the model on images from the VOC dataset on a desktop Intel i7 CPU with an Nvidia GTX 1070 GPU running Tensorflow.
Retraining the existing Tensorflow model with the VOC dataset
1) make sure CUDA is installed and running on. You can test this by running 'nvcc -V', which outputs the cuda compiler version.
2) git clone https://github.com/tensorflow/models.git
3) follow instructions to install dependencies at https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md
NOTE: do NOT install pycocotools per instructions -> use pip3 install pycocotools instead
4) run tests, make sure all return with OK
5) git clone https://github.com/PINTO0309/TPU-MobilenetSSD.git
6) cp -Rf TPU-MobilenetSSD/colaboratory/gpu/* models/research/object_detection/
7) chmod 0755 *.py *.sh
8) rm configs && mkdir configs && cd configs && unzip../collab.zip && cd..
9) ln -s. object_detection
10)./prepare_checkpoint_and_dataset.sh --network_type mobilenet_v1_ssd --train_whole_model false
11) rm -Rf object_detection/learn/train
12) Partial model retraining:
NUM_TRAINING_STEPS=500 && NUM_EVAL_STEPS=100 && ./retrain_detection_model.sh \
--num_training_steps ${NUM_TRAINING_STEPS} \
--num_eval_steps ${NUM_EVAL_STEPS}
Note: ignore warnings about deprecated APIs
On our GTX 1070 this process ran for four days. Once you have a re-trained network, you will need to convert it to a format usable by the Google TPU chip on the Coral Dev board. When training completes the last line will list the location of the.pb file you need to convert to TensorflowLite as a preliminary step to running on the Coral Dev board's TPU.
Converting the.pb file to TensorflowLite
Using the instructions found at https://coral.ai/docs/edgetpu/models-intro/ we converted the.pb file to a TensorflowLite format.
./convert_checkpoint_to_edgetpu_tflite.sh --checkpoint_num 500
Follow the instructions to install the edgetpu compiler. Run the following to convert the TensorflowLite file to a TPU version.
edgetpu_compiler output_tflite_graph.tflite
Copy the file output_tflite_graph_edgetpu.tflite and the labels.txt files to your Coral Dev board root filesystem so we can run the model to detect objects and human beings on the high-def camera stream.
Running the model:
edgetpu_detect_server --model ./output_tflite_graph.tflite --labels ./labels.txt
The high-def camera stream will be shown on web port 4664 with labeled boxes around the detected people and objects.
We purchased a Coral Sensor Board that is a daughter-board to the Coral Dev Board with the Google TPU. The sensor board comes with temperature, humidity, light, and barometric pressures and sample python scripts. We added an I2C extender board and oxygen, carbon dioxide and carbon monoxide sensors. We incorporated reading all of the sensors and displaying the data on both the local display and the on-board web page. Sensor data updates every thirty seconds.
Unfortunately we could not get our carbon monoxide sensor up and running, probably due to a bad ADC I2C board so we left carbon monoxide as a future 'to do' item.
On Board Live Web PageWe used Python and flask to create an on-board web page that shows the IR and high-def cameras, detected objects via the Google Edge Tensorflow Processing Unit (TPU), and a live view of the sensors.
We built the web page in Python Flask with multiple threads. One thread periodically updates sensor data which is handed off to a socketio thread which sends it on to the clients. Camera streams are handled by the python cv2 OpenCV package.
Pimoroni Tilt & SwivelWe added an inexpensive Pimoroni PanTiltHat controlled via I2C and create a custom cable to connect it to the Coral Dev Sensor board's I2C Grove connector. This cable supplies +5V, Gnd, SCA, and SDL lines to control it. We also created a 3D printed design to mount the PanTiltHat to the rails and mounted both the Coral Dev camera and the IR camera to the PanTiltHat.
S500 Pimoroni PanTiltHat mount on Thingiverse
Unfortunately the Coral Dev HD camera had to be mounted so that the image is reversed. This is due to the limited camera cable length. If we had mounted it the right way up, there would be no cable travel and thus no pan and tilt. This camera has no hardware ability to invert the image. It turns out that object and people detection works just as well on an inverted stream. As a future enhancement we would like to invert the video stream before the TPU detection software receives it and then send it on right-side-up to web clients viewing the stream.
Adding the IR Camera to the PanTiltHat
We picked up a tiny FLIR IR camera with micro-USB connector from the GroupGets site. This camera appears under Linux as a UVC camera and needs no special setup. The documentation for this camera includes a 3D image file that we used to create a snugly fitting mount that can be fastened above the Coral Dev HD camera on the Pimoroni PanTiltHat mount. We uploaded the 3D stl file to Thingiverse.
GroupGets Pure Therml mini FLIR camera mount
Putting it all together, here is a video of the cameras panning and tilting via the on-board web page. The sensor data displayed is a live view of temperature, humidity, barometric pressure, O2 level, CO2 level, Volatile Organic Compouds levels, as well as surrounding light intensity in lux.
ConclusionBuilding this project was one of the most fun so far here at hackster.io. This was also my first foray into working with drones. The idea of an intelligent, self-contained AI platform with camera and sensors is extremely engaging and I look forward to expanding this system's capabilities in the future. The Freescale/NXP i/MX8 quad 64-bit ARM CPU has quite a bit of horsepower and coupled with the Google TPU makes this quite an amazing system with a price well South of $200.
The ability to recognize people and objects as the drone flies overhead opens up huge new possibilities. This system could expanded into a completely independent robotic craft that keeps itself charged and ready to fly after each mission without the need for a human being to manually remove and recharge the battery. The communications capabilities together with the TPU AI detection feature means that it can scan an area and report back its findings without the need for a dedicated person watching the camera streams. This system could evolve into an autonomous self-contained AI platform that could perform complex missions without the need for human intervention to keep it up and flying.
Comments