Any views expressed within media held on this service are those of the contributors, should not be taken as approved or endorsed by the University, and do not necessarily reflect the views of the University in respect of any particular issue.
insect robots

Insect Robotics Group

Insect Robotics Group

Building robots to understand insect behaviour

AntBot: Setting up the App

Now that you have the projects set up and ready to start development, it is time to examine the code itself.

This post will cover ‘wiring up’ an App with the pre-packaged combiners and navigation modules.

What is Pre-Packaged?

With the AntBot codebase comes with 2 combiners and 4 navigation modules. The ‘Simple Combiner’ ignores all modules apart from one and issues that as the path to be followed. The ‘Weighted Combiner’ takes the average angle and distance of all 4 modules and submits it.

The Navigation modules represent Path Integrators that work through basic trigonometry and one based on Haferlach’s model. The other two implement visual homing based on pixel-wise error and the ‘Run-Down’ algorithm and a simplistic Systematic Search generator.

Setup

First, open MainActivity and declare the modules and combiner that you want to use at the top of the class (we will only use the trig path integrator for now):

WeightedCombiner weightedCombiner;
VisualHoming visualHoming;
TrigPathIntegration trigPathIntegration;
SystematicSearch systematicSearch;

The method ‘onCreate’ holds the actual setup code. First the combiner is instantiated and registered with the framework:

weightedCombiner = new WeightedCombiner();
setCombiner(weightedCombiner);

Now, the modules are set up – for each module it must be instantiated, subscribed to it’s feeds and registered with the combiner (where it is given a name so it can be identified), for example:

visualHoming = new VisualHoming();
cameraFragment.addSubscriber(visualHoming);
simpleCombiner.addModule("VH", visualHoming);

The trig path integrator has to be subscribed to the controller fragment and should be called “PI”. The systematic search generator should be subscribed to the trig path integrator and the controller fragment. It should be called “SS”.

If data is to be sent to the server the Network Fragment must be subscribed to the modules which will supply it with said information:

trigPathIntegration.addSubscriber(networkFragment);
visualHoming.addSubscriber(networkFragment);

Finally, a further step is needed for any modules that make use of OpenCV (such as the Visual Homing module), below onCreate is another method named onOpenCVLoaded – it is recommended that all vision based modules be placed into a dormant state until the library is loaded, after which they can be ‘woken up’ (this stops function calls being made to non-existant libraries):

visualHoming.enableVisualHoming();

This is all that setup consists of – pressing the Run app button should load the app onto the phone ready for use.

Swapping Modules

To swap modules in and out you simply need to comment out/delete their code. If you wanted to replace the trig path integrator with the haferlach path intergator you would simply have to do the following:

//trigPathIntegration = new TrigPathIntegration();
//controllerFragment.addSubscriber(trigPathIntegration);
//simpleCombiner.addModule("PI", trigPathIntegration);

haferlachPathIntegration = new HaferlachPathIntegration();
controllerFragment.addSubscriber(haferlachPathIntegration);
simpleCombiner.addModule(“PI”, haferlachPathIntegration);

Having said that, the system is of course module agnostic so it is more than possible to have the two modules coexist happily (but with one of them would have to be called something that isn’t PI).

The weighted combiner could be swapped for the simple combiner in the same way, but only one combiner can be used at a time.

 

Now we have the app working, let’s tweak the modules!

css.php

Report this page

To report inappropriate content on this page, please use the form below. Upon receiving your report, we will be in touch as per the Take Down Policy of the service.

Please note that personal data collected through this form is used and stored for the purposes of processing this report and communication with you.

If you are unable to report a concern about content via this form please contact the Service Owner.

Please enter an email address you wish to be contacted on. Please describe the unacceptable content in sufficient detail to allow us to locate it, and why you consider it to be unacceptable.
By submitting this report, you accept that it is accurate and that fraudulent or nuisance complaints may result in action by the University.

  Cancel