[DISCUSSION] Implementing new robots in the ARGoS Simulator

Requests regarding how to set up experiments in ARGoS.
mallwright
Posts: 35
Joined: Tue Apr 17, 2012 11:15 am

[DISCUSSION] Implementing new robots in the ARGoS Simulator

Postby mallwright » Wed May 16, 2012 4:01 pm

Hi All,

I have been going through the ARGoS source code trying to understand how a robot (along with it's sensors and actuators) is defined and instantiated in the simulator. As far as I can tell, entities whether they are inanimate blocks or complex robots are not treated any differently by the simulator. Rather what is happening is that these entities inherit certain characteristics such as being controllable and embodying simulated space etc.

From what I (think I) have learned, it seems that robots in the simulator are defined using the following components/definitions:
  • The controller - defined in dynamically linked shared library defines the behaviour of the robot. during the initialisation (Init method) of the robot it requests references (pointers) to it actuators and sensors which are stored within an instance of that controller. During each step (ControlStep method) the controller can read the sensors and update the values of the actuators via the stored pointers in that instance.
  • The experiment file - an XML document which is passed to ARGoS on the command line. Amongst many other things, this file defines configurable type instances of the aforementioned controller, which are parametrised via XML attributes. The sensors and actuators used in the controller are instantiated as this configuration file is parsed. If the controller requests references to sensors or actuators which have not been declared in the XML, the simulator throws an exception.
  • Features and Properties
    • Entities, the way in which each robot seems to be able to interact with the simulated world seems to be using the entity class (incl the inheritance hierarchy) definitions. For example all of the implemented robots have a class which derives from an EmbodiedEntity and a ComposableEntity. The EmbodiedEntity defines the shape of the robot in terms of how it occupies the simulated space. I'm uncertain what the ComposableEntity represents. (attached diagram for inheritance hierarchy).
    • Physics, for each robot (more generally entity) type a physics engine is specified in the XML experiment file. It seems that for this physics engine to interact with an entity, each entity type must also specify a model which inhertits from the PhysicsEngineEntity.
    • Sensors, for each robot there is a base class which defines the type C<Robot>Sensor, and each sensor implemented on the robot inherits from this base class.
    • Actuators, same as the sensors
  • Rendering definition, each robot defines an OpenGL model class which is used for the OpenGL and POVRay Rendering modes.
As far as I can tell, when a robot is instantiated, all of its properties, actuators, sensors and characteristics, are stored into a respective map alongside with the entities ID. These maps are used by the various components in the simulator to determine how the simulated world moves through each time step.

I haven't quite figured out how the names in the XML link into all these classes (i.e. how attribute assigning the footbot to a physic engine e.g. engine id="dyn2d" links to the class CDynamics2DFootBotEntity), I assume that there is some tag which is stored as const string with each class as it is registered as a plugin during the simulators initialisation.

Anyway I'll be interested to know whether I am understanding everything here, so feel free to let me know if I'm completely wrong about any of this.

Cheers

-mallwright
Attachments
inherit_graph_13.png
inherit_graph_13.png (112.92 KiB) Viewed 21603 times

pincy
Site Admin
Posts: 632
Joined: Thu Mar 08, 2012 8:04 pm
Location: Boston, MA
Contact:

Re: [DISCUSSION] Implementing new robots in the ARGoS Simula

Postby pincy » Mon May 21, 2012 8:23 pm

Hi mallright,

I am writing an extensive manual about ARGoS that contains all the information you need to create new robots.

You got many things right :-)

In a nutshell, any simulated object in ARGoS is an entity. Several entity types exist in ARGoS. Robots are typically derived from the Composable entity, which is simply an entity that can contain other entities. Typical components are (1) the Controllable entity, that stores a reference to the robot controller and the sensor/actuator instances, and (2) the Embodied entity, which contains the current position, orientation and bounding box of the robot body.
Actuators and sensors aren't entities. Rather, they read data from and write data into entities. Many entities are specialized to interact with particular sensors and actuators. For instance, the LED actuator writes the new color of the robot LEDs into the LEDEquipped component of a robot.
Thus, to add a robot, you need to create a new entity that derives from CComposableEntity. Your class must reference the relevant entities that compose the robot, i.e., wheels (CWheeledEntity), LEDs (CLEDEquippedEntity), etc.

Once your fresh entity is ready, you need to tell the various components of ARGoS how to deal with it. For instance, you need to tell ARGoS how to add and remove your entity from the simulated space; how to add and remove it from the physics engines; how to draw it in OpenGL and in POV-Ray; and so on. To this aim, ARGoS is based on the visitor pattern. The basic visitor class is in argos2/simulator/space/entity_visitor.h. Any operation to be performed on the entities is encoded into a class that extends CEntityVisitor. You'll find CSpaceVisitorAdd/CSpaceVisitorRemove, CDynamics2DVisitorAdd/CDynamics2DVisitorRemove, CQTOpenGLVisitor, and so on. You need to add an implementation for the Visit(CMyRobot&) method for each of these classes, or an empty implementation if you choose to not support that operation for you robot.

Finally, regarding the link between XML and classes, well, that's maybe the shortest and most complex piece of code I have ever written :-) The basic ideas are taken from this article: http://www.linuxjournal.com/article/3687.
I made ARGoS.

Greg H
Posts: 5
Joined: Wed Jan 09, 2013 3:49 pm

Re: [DISCUSSION] Implementing new robots in the ARGoS Simula

Postby Greg H » Wed Jan 09, 2013 5:52 pm

Hello everyone,

I am trying to add a plane to argos2 simulator,

I don t get the difference between files defining actuators in common/control_interface/swarmanoid/eyebot/ci_eyebot_propellers_actuator.* and in simulator/actuators/eye-bot/eyebot_propellers_actuators.*

Can anyone help me, please ?

Thanks in advance,
Greg

Greg H
Posts: 5
Joined: Wed Jan 09, 2013 3:49 pm

Re: [DISCUSSION] Implementing new robots in the ARGoS Simula

Postby Greg H » Fri Jan 11, 2013 12:12 pm

Hello,

I think that now I get it right.

please, Correct me if I am wrong.

in simulator folder you define there the actuators and sensors.
and in common/control_interface folder you define conversion between what the controller give & need as parameter, and what actuators' parameters need & sensors' parameters give.

Thanks in advance,
Greg

pincy
Site Admin
Posts: 632
Joined: Thu Mar 08, 2012 8:04 pm
Location: Boston, MA
Contact:

Re: [DISCUSSION] Implementing new robots in the ARGoS Simula

Postby pincy » Fri Jan 11, 2013 1:56 pm

Hi Greg,
you are correct.
When you want to add new sensors and actuators, you first define their control interface (i.e., what you will use in the controller). That stuff goes in common/control_interface.
Next, you define the actual implementation. For simulated experiments, you have a folder simulator/actuators and a folder simulator/sensors where stuff goes. For the real robots, you can define your own implementation depending on the robot.
Hope it's clear now!
Cheers,
Carlo
I made ARGoS.


Return to “How to... ?”