Mark Foley
Created May 3, 2017 © CC BY

Termite Detector

The Termite Detector proposes, in a nondestructive manner, to discover the destructive insects well before they do any real damage.

AdvancedShowcase (no instructions)24 hours140
Termite Detector

Things used in this project

Hardware components

Walabot Developer Pack
Walabot Developer Pack
×1
Ant Farm
×1
Live Ants
×1
SheetRock
×1

Story

Read more

Code

Small Insect Detection

C#
Attempt to use Walabot to detect termites. Due to dangerous nature of termites in captivity, I used ants in an ant farm instead to simulate a termite nest. Unfortunately, I could not get Walabot to detect the ants or their motion. I also had trouble keeping the ants alive so I lost time acquiring more ants. I went through 3 ant nests. Maybe with more time to devote I may have found a way to configure the Walabot to detect such small moving objects a short distance away from the Walbot transmitters.
using System;
using WalabotAPI_NET;

namespace InWallApp_SampleCode
{
    class InWallSampleCode
    {
        WalabotAPI walabot;
        string versions;

        static void Main()
        {
            InWallSampleCode inWall = new InWallSampleCode();
            inWall.InWall_SampleCode();
        }

        void PrintImagingTargets(ImagingTarget[] targets, int numTargets)
        {   //Clean screen
            //Console.Clear();

            //  MEF
            Console.WriteLine("Walabot Versions:\n"+ versions);

            //print targets values
            if (numTargets > 0)
                for (int targetIdx = 0; targetIdx < numTargets; targetIdx++)
                    Console.WriteLine("Target #" + targetIdx + ":\n\t\t type " + (targets[targetIdx].type == TARGET_TYPE.TARGET_TYPE_PIPE ? "Pipe" : "Unknown") + ",\n\t\t angleDeg = " + targets[targetIdx].angleDeg + ",\n\t\t xPosCm = " + targets[targetIdx].xPosCm + ",\n\t\t yPosCm = " + targets[targetIdx].yPosCm + ",\n\t\t zPosCm = " + targets[targetIdx].zPosCm + ",\n\t\t wPosCm = " + targets[targetIdx].widthCm + ",\n\t\t amplitude = " + targets[targetIdx].amplitude + "\n ");
            else
                Console.WriteLine("No targets detected");
        }

        void PrintSensorTargets(SensorTarget[] targets, int numTargets)
        {   //Clean screen
            //Console.Clear();

            //  MEF
            Console.WriteLine("Walabot Versions:\n" + versions);

            if (numTargets > 0)
                for (int targetIdx = 0; targetIdx < numTargets; targetIdx++)
                    Console.WriteLine("Target #" + targetIdx + ":\n\t\t" + ",+ ","\n\t\t xPosCm = " + targets[targetIdx].xPosCm + ",\n\t\t yPosCm = " + targets[targetIdx].yPosCm + ",\n\t\t zPosCm = " + targets[targetIdx].zPosCm + ",\n\t\t amplitude = " + targets[targetIdx].amplitude + "\n ");
            else
                Console.WriteLine("No targets detected");
        }
        //
        void PrintBreathingEnergy(double energy)
        {
            Console.Clear();
            energy *= 1e7;
            Console.WriteLine("Energy = " + energy + "\n ");
        }
        
        //
        public void InWall_SampleCode()
        {
            walabot = new WalabotAPI();
            // --------------------
            // Variable definitions
            // --------------------          
            // Walabot_GetStatus - output parameters
            APP_STATUS appStatus;

            double calibrationProcess; // Percentage of calibration completed, if status is STATUS_CALIBRATING

            // Walabot_GetImagingTargets - output parameters
            ImagingTarget[] targets1;
            SensorTarget[] targets2;
            int numTargets1;
            int numTargets2;

            // Walabot_GetRawImageSlice - output parameters
            int sizeX;
            int sizeY;
            double sliceDepth;
            double power;
            // Walabot_GetImageEnergy 
            double energy;

            // ------------------------
            // Initialize configuration
            // ------------------------
            double zArenaMin = 3;
            double zArenaMax = 8;
            double zArenaRes = 0.5;

            double xArenaMin = -3;
            double xArenaMax = 4;
            double xArenaRes = 0.5;

            double yArenaMin = -6;
            double yArenaMax = 4;
            double yArenaRes = 0.5;

            // ----------------------
            // Sample Code Starts Here
            // ----------------------

            /*
            For an image to be received by the application, the following need to happen :
                1) Connect
                2) Configure
                3) Calibrate
                4) Start
                5) Trigger
                6) Get action
                7) Stop/Disconnect
            */

            // Configure Walabot database install location (for windows)
            walabot.SetSettingsFolder(@"C:\ProgramData\Walabot\WalabotSDK");

            //	1) Connect : Establish communication with Walabot.
            //	==================================================
            walabot.ConnectAny();
            versions = walabot.GetVersion();


            //  2) Configure : Set scan profile and arena
            //	=========================================

            // Set Profile - short range . 
            //			Walabot recording mode is configure with the following attributes:
            //			-> Distance scanning through air; 
            //			-> lower - resolution images for a fast capture rate (useful for tracking 
            //  PROF_SHORT_RANGE_IMAGING
            //  PROF_SHORT_RANGE_SINGLE_LINE            
            walabot.SetProfile(APP_PROFILE.PROF_SHORT_RANGE_IMAGING);


            // Set arena by Cartesian coordinates, with arena resolution :
            walabot.SetArenaX(xArenaMin, xArenaMax, xArenaRes);
            walabot.SetArenaY(yArenaMin, yArenaMax, yArenaRes);
            walabot.SetArenaZ(zArenaMin, zArenaMax, zArenaRes);

            // Walabot filtering disable 
            walabot.SetDynamicImageFilter(FILTER_TYPE.FILTER_TYPE_NONE);

            //	3) Start: Start the system in preparation for scanning.
            //	=======================================================
            walabot.Start();

            // calibrates scanning to ignore or reduce the signals
            walabot.StartCalibration();

            //	4) Trigger: Scan(sense) according to profile and record signals to be available
            //	for processing and retrieval.
            //	================================================================================
            bool recording = true;

            while (recording)
            {
                // calibrates scanning to ignore or reduce the signals
                walabot.GetStatus(out appStatus, out calibrationProcess);

                //	5) Trigger: Scan(sense) according to profile and record signals to be 
                //	available for processing and retrieval.
                //	====================================================================
                walabot.Trigger();

                //	6) 	Get action : retrieve the last completed triggered recording 
                //	================================================================                
                targets1 = walabot.GetImagingTargets();
                targets2 = walabot.GetSensorTargets();


                //public int[,,] GetRawImage(out int sizeX, out int sizeY, out int sizeZ, out double power);
                //public int[,] GetRawImageSlice(out int sizeX, out int sizeY, out double sliceDepth, out double power);

                walabot.GetRawImageSlice(out sizeX, out sizeY, out sliceDepth, out power);
                energy = walabot.GetImageEnergy();

                //	******************************
                //	TODO: add processing code here
                //	******************************
                PrintBreathingEnergy(energy);
                //
                numTargets1 = targets1.Length;
                numTargets2 = targets2.Length;
                PrintImagingTargets(targets1, numTargets1);
                PrintSensorTargets(targets2, numTargets2);
            }

            //	7) Stop and Disconnect.
            //	======================
            walabot.Stop();
            walabot.Disconnect();
        }
    }
}

Credits

Mark Foley

Mark Foley

3 projects • 1 follower

Comments