Overview

HBot embeds a lua interpreter for both configuration and real-time control of a robot. The intention is to provide an easy and quick way to test specific configurations and behaviors without diving into the C++ code of HBot core libraries. It also gives a dynamic control on the choice of algorithms to use, the way components are connected to one each others, etc.

Lua interpreter in HBot is called luabot.There are three parts in a luabot configuration file: hardware configuration, algorithms and components configuration, dynamic control.

Hardware configuration

This part defines what type of controllers, sensors, servos, motors are used in the robot to control, and also what is the category of move model, of sensor control, etc. Most objects correspond to real-life devices, and are specialized with a type parameter. All objects are defined with a name, in a lua table (a series of value = string or int inside { }).

Primitives are defined as follow:

  • controller is the interface to robotic hardware
  • cservo represents a continuous servomotor
  • servo represents a servomotor
  • sensor can represent several devices, yet for the moment it can only be an infra-red sensor
  • sensorcontrol is an evoluted sensor, for example a device for getting ranges over an area defined by 180° field of vision. For the moment, two major types exist:
    • laser is a laser rangefinder, such as SICK ones
    • turretrangefinder represents a sensor mounted on a servo for taking several measures at a varying angle
  • robot represents the robotic model; behind this item is provided limited move, unlimited move, move feedback (depending on the robot type). Several types of robotic models exist:
    • wheeeledrobot for a two-wheels robot
    • playerrobot is for using Player/Stage HAL to control a robot move (position2d proxy)

See hardware configuration example to learn more.

Algorithms and components configuration

This section of a luabot configuration file instantiates the objects that make HBot work, and gives possibility to connect the events of these objects. Behind these instantiations, HObjects from core library are instantiated, and the connection in luabot corresponds to connection between HObjects signals and slots.

You can get objects from two means: fetching instances created in during hardware configuration, or create objects (maps, algorithms, user controller, etc.).

Objects you can fetch

Provided the name of the originated hardware object, from those instantiated during hardware:

  • SensorControl (as in the hardware part)
  • RobotMove (movement model for limited moves, possibly in an open-loop fashion)
  • FreeMove (movement model for unlimited moves)
  • Odometer (feedback from robot)

Objects you can create

  • GridMap, provided the size of a grid cell edge in mm
  • RobotTracker
  • WebHRI (a Human-Robot Interface that provides maps through an HTTP server), provided the path of the www repository
  • MovementPlanning (which provide waypoint moves primitives), provided a RobotTracker
  • MapGenerator (generates an occupancy map), provided a GridMap and a RobotTracker
  • MapRayTracer (generates rays from sensor reports, provided a GridMap and a RobotTracker
  • Discovery (algorithm for exploration of the world), provided a GridMap and a RobotTracker
  • PIDController (algorithm for controlling limited move in a closed-loop fashion), provided the P, I and D gains, and a frequency setting
  • KeyboardControl (control your bot with your keyboard)
  • PadControl (control your bot with your gamepad), provided the gamepad device path

Some of these objects need parameters for initialization, but most of them also need event connection to work properly. These connection can change dynamically, depending on the algorithms you want. You can connect a signalling object to a slot object for a given event with the primitive connect(signalObject, eventName, slotObject).

See software configuration example to learn more.

Dynamic control

Some specific methods are available, that propose control on objects. The methods are noted with their class names, you should use them on the object instead (e.g.

  • HObject:connect(string, HObject) has been seen previously, it does the connection of a signal HObject and a slot HObject for a given event name; note that a global version of this function exists
  • RobotMove:rotate(number) and RobotMove:translate(number) are basic moves; they take an amount as argument (rotate takes a rotation amount in degrees, translate takes a translation amount in mm)
  • FreeMove:move(number, number) is a free move; it takes a translation speed and a rotation speed; note that in some cases you cannot have non-null translation and rotation
  • MovementPlanning:goto(int, int) is a waypoint move; it takes a MovementPlanning first, then x and y coordinates
  • SensorControl:scan() does a scan on a SensorControl
  • Discovery:launchDiscovery(int) with a limit parameter, starts a discovery loop
  • PadCtl:loop() starts a loop reading events on a gamepad; free move events are emitted when stick #1 is used; a “sensor request” is emitted when any button is pressed; check that you have connected these events to a FreeMove and a SensorControl before starting padloop.
  • KbdCtl:loop() acts the same as padloop; free moves are commanded with i/k (forward, backward), j/l (turn left, turn right), v sends a sensor request, any other key send a stop free move.

There are also global functions available:

  • connect(HObject, string, HObject) behaves the same than the connect method, it connects two objects with an event (given in string).
  • interactive() reads lua command on the standard input; you can call interactive at any point of the lua script, and stop the interpreter with ctrl+d
  • socketloop(int) takes a TCP port number as first parameter; it acts the same as interactive, except it listens to a TCP socket (localhost, given port number) for connections and lua commands; it notifies updates from the map given as second parameter to the client of the socket (with a message “MAP [URL]”)
 
luabot.txt · Last modified: 2009/03/24 18:05 by hadrien
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS La rache Driven by DokuWiki