Example Sources

The example sources are hosted on github: https://github.com/ilpincy/argos3-examples.

To download them, open up a terminal and clone the repository with this command:

$ git clone https://github.com/ilpincy/argos3-examples.git argos3-examples

Follow the instructions in the README file to compile the code.

Diffusion 1

A foot-bot performs obstacle avoidance while navigating in a small, obstacle-free environment.

diffusion_1.argos: The ARGoS configuration file.

footbot_diffusion.h: The C++ header of the robot behavior.

footbot_diffusion.cpp: The C++ implementation of the robot behavior.

img/diffusion_1.png

Diffusion 10

10 foot-bots perform obstacle avoidance while navigating in an small square environment. The difference between this experiment and the previous is that, in this experiment, robots and obstacles are randomly distributed in the environment.

diffusion_10.argos: The ARGoS configuration file.

footbot_diffusion.h: The C++ header of the robot behavior.

footbot_diffusion.cpp: The C++ implementation of the robot behavior.

img/diffusion_10.png

Synchronization

This example experiment reproduces the coupled oscillators of Mirollo and Strogatz. In the beginning, the robots flash their LEDs out of sync, but over time, seeing each other’s LEDs, they synchronize. In this example you’ll see how to use the camera, and how to distribute robots in a grid.

synchronization.argos: The ARGoS configuration file.

footbot_synchronization.h: The C++ header of the robot behavior.

footbot_synchronization.cpp: The C++ implementation of the robot behavior.

img/synchronization.png

Flocking

This example shows how to achieve foraging through the well known Lennard-Jones potential. The robots light up their central LED (called the beacon) in red. They use the omnidirectional camera to detect robots around and calculate the Lennard-Jones interaction force to all of them. The robots collectively go to a light source located in the origin.

flocking.argos: The ARGoS configuration file.

footbot_flocking.h: The C++ header of the robot behavior.

footbot_flocking.cpp: The C++ implementation of the robot behavior.

img/flocking.png

Gripping

This examples shows how to use a cylinder as a movable object. Using a simple time-based logic, a foot-bot moves towards the cylinder, grips it, moves backwards dragging it, and finally releases it while keeping the backwards motion.

gripping.argos: The ARGoS configuration file.

footbot_gripping.h: The C++ header of the robot behavior.

footbot_gripping.cpp: The C++ implementation of the robot behavior.

img/gripping.png

Trajectory

10 foot-bots perform obstacle avoidance while navigating in a small square environment. The difference between this experiment and diffusion 10 is that, in this experiment, the trajectory of the robots in the arena is drawn.

trajectory.argos: The ARGoS configuration file.

footbot_diffusion.h: The C++ header of the robot behavior.

footbot_diffusion.cpp: The C++ implementation of the robot behavior.

trajectory_loop_functions.h: The C++ header of the loop functions that collect the trajectory data.

trajectory_loop_functions.cpp: The C++ implementatiohn of the loop functions that collect the trajectory data.

trajectory_qtuser_functions.h: The C++ header of the user functions that draw the trajectory of a robot.

trajectory_qtuser_functions.cpp: The C++ implementation of the user functions that draw the trajectory of a robot.

img/trajectory.png

Robot ID

10 foot-bots perform obstacle avoidance while navigating in a small square environment. The difference between this experiment and diffusion 10 is that, in this experiment, the id of the robots in the arena is displayed.

id.argos: The ARGoS configuration file.

footbot_diffusion.h: The C++ header of the robot behavior.

footbot_diffusion.cpp: The C++ implementation of the robot behavior.

id_qtuser_functions.h: The C++ header of the user functions that draw the id of a robot.

id_qtuser_functions.cpp: The C++ implementation of the user functions that draw the id of a robot.

img/id.png

Foraging

This example is a complete experiment. It shows how to interact with the simulation through the loop functions and how to draw on the OpenGL graphical visualization through the Qt user functions. The arena is divided in two areas: a grey area that serves as nest, where the robots are initially deployed; and a white area where food items are scattered. The task of the foot-bots is to exit the nest, search for food items, grab them and bring them back to the nest. To simplify control, food items are just drawn as black spots on the ground, and when a robot passes over a food item it automatically grabs it. When a robot is transporting a food item, a cylinder is drawn on top of it. Each robot can transport only one item per time. Once a robot has grabbed an item, it must bring it back to the nest. The direction to/away from the nest is detectable through light sensors, that read the position of a set of lights displaced over the nest.

foraging.argos: The ARGoS configuration file.

footbot_foraging.h: The C++ header of the robot behavior.

footbot_foraging.cpp: The C++ implementation of the robot behavior.

foraging_loop_functions.h: The C++ header of the loop functions that collect data.

foraging_loop_functions.cpp: The C++ implementation of the loop functions that collect data.

foraging_qt_user_functions.h: The C++ header of the user functions that draw the collected object on top of a robot.

foraging_qt_user_functions.cpp: The C++ implementation of the user functions that draw the collected object on top of a robot.

img/foraging.png

Single-process evolution with GALib

This example shows how to embed ARGoS into a genetic algorithm and how to evolve a simple neural network controller. In this example, a foot-bot is evolved to perform phototaxis. The example is composed of a neural network controller, a loop function, and additional code to wrap ARGoS.

The code uses GALIB, available at http://lancet.mit.edu/ga/. You can download GALIB through your system’s package manager. On Ubuntu type

$ sudo apt-get install libga-dev

while on HomeBrew type

$ brew install homebrew/science/galib

galib.argos: The ARGoS configuration file for a trial.

galib-trial.argos: The ARGoS configuration file to show the behavior of the robot in a specific trial.

footbot_nn_controller.h: The C++ header of the neural network.

footbot_nn_controller.cpp: The C++ implementation of the neural network.

galib_phototaxis_loop_functions.h: The C++ header of the loop functions that set up each trial and collect data.

galib_phototaxis_loop_functions.cpp: The C++ implementation of the loop functions that set up each trial and collect data.

main.cpp: The main file that executes the evolution.

img/evolution.png

Multi-process evolution

This examples shows how to launch multiple, parallel ARGoS processes. The code is organized in a custom-made, fairly flexible genetic algorithm class and a dedicated loop function definition.

The program is organized in a master process and several slave processes. Each slave process launches ARGoS once and goes to sleep. The master process wakes the slaves up when trials must be executed, and then collects the results to perform selection, crossover, and mutation.

The .argos file for this experiment contains only those aspects of the evoluion that do not change across trials. The aspects that must change are managed by the loop functions.

mpga.argos: The ARGoS configuration file for a trial.

mpga-trial.argos: The ARGoS configuration file to show the behavior of the robot in a specific trial.

footbot_nn_controller.h: The C++ header of the neural network.

footbot_nn_controller.cpp: The C++ implementation of the neural network.

mpga.h: The C++ header of the multi-process genetic algorithm.

mpga.cpp: The C++ implementation of the multi-process genetic algorithm.

mpga_loop_functions.h: The C++ header of the base loop functions for multi-process evolution.

mpga_loop_functions.cpp: The C++ implementation of the base loop functions for multi-process evolution.

mpga_phototaxis_loop_functions.h: The C++ header of the loop functions that set up each trial and collect data.

mpga_phototaxis_loop_functions.cpp: The C++ implementation of the loop functions that set up each trial and collect data.

main.cpp: The main file that executes the evolution.

img/evolution.png