Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Cookbook

This page will teach you how to use Enki step by step.

Overview

Enki is a robot simulator. Several objects (Enki::PhysicalObject) are placed in a virtual world (Enki::World). Some are passively obeying physical laws, but others are able to move and and interact with other objects by sending or receiving signals, they are robots (Enki::Robot). In the bare Enki distribution, there are four subclasses of robots, three true robots and one beacon: Robots have members that can be set, such as leftSpeed and rightSpeed for Enki::Khepera, that will be used to compute their movements. World is updated on Enki::World::step() which defines the duration of the timestep in seconds.

First program using Enki

The following program initializes a world, adds a Khepera to it and runs the world for a while:

testenki.cpp:

#include <enki/PhysicalEngine.h>
#include <enki/robots/khepera/Khepera.h>
#include <iostream>

int main(int argc, char *argv[])
{
    // Create the world
    Enki::World world(200, 200);
    
    // Create a Khepera and position it
    Enki::Khepera *khepera = new Enki::Khepera();
    khepera->pos = An::Point(100, 100);
    khepera->leftSpeed = 30;
    khepera->rightSpeed = 20;
    
    // objects are garbage collected by the world on destruction
    world.addObject(khepera);
    
    // Run for some times
    for (unsigned i=0; i<1000; i++)
    {
        // step of 50 ms
        world.step(0.05);
        std::cout << "Khepera pos is (" << khepera->pos.x << "," << khepera->pos.y << ")" << std::endl;
    }
}

You can then compile this program, assuming its name is testenki.cpp, with the following command:

g++-3.4 testenki.cpp -o testenki -lenkikhepera -lenkiinteractions -lenkicore -lan

Additional notes

Please note that, by convention, units are: Although Enki's core is unit-independent, the existing robots use those conventions.
Generated on Mon Oct 24 17:33:58 2005 for Enki by  doxygen 1.4.2