Example application: RoboSim

From plexil
Jump to: navigation, search



RoboSim is a simple two-dimensional robot simulator that can be used to demonstrate and study the behavior of planning, scheduling, and plan execution systems.

Several instances of robots can be created and deployed in a 2D terrain that contains obstacles, energy sources, goals, and other robots. Robots understand and respond to a small list of commands.

The RoboSim application is filed in the plexil/src/apps/robosim directory of the PLEXIL distribution. It has been tested on Linux and MacOS systems.

This document describes the RoboSim application and its interface with PLEXIL and the PLEXIL Executive.



Figure 1: A snapshot of the RoboSim terrain and its occupants.

This screenshot shows an example terrain occupied by many robots (squares with small triangular appendages representing sensors). The red angular lines are static obstacles, the magenta spheres are energy sources, and the white cloudy region (its center, specificially) is a goal.

Terrain and Obstacles

The RoboSim terrain is a 2D cell grid where each cell is represented by its row and column (integers). Figure 1 depicts a square terrain with 32 cells along each direction.

There are two types of obstacles in a terrain, static and dynamic. Static obstacles include the terrain boundary and walls (thick red lines within the terrain). Dynamic obstacles are other robots. Obstacles block a robot's movement, and static obstacles cannot be removed.

Energy Sources

Distributed throughout the terrain are energy sources that robots can “consume” to boost their energy level. Such energy sources can be viewed as charging stations and are shown as magenta colored spheres in Figure 1. (Note that energy sources occupy exactly one grid cell, though visually they extend over several surrounding cells.)

The energy level of each robot, initialized to its maximum value of 1.0, drops by a prefixed amount (currently 0.025 units) for every successful step it takes. The energy level is boosted to the maximum level of 1.0 by visiting a cell containing an energy source.

The presence of an energy source can be “sensed” by a robot as will be discussed in subsequent sections.


The goal component in the scene gives the robots a purpose to navigate the terrain. Figure 1 shows a white region, the center of which could be what the robot is tasked to find.

As with energy sources, a goal occupies exactly one grid cell (with a visual region extending outwards many cells), and its presence of the goal can also be “sensed” by the robots.

Robots and their Sensors

Robots are display as colored squares with small triangular appendages representing their sensors. A robot can be moved one cell at a time along one of the four principal directions up, right, down and left, provided the movement is not blocked by an obstacle. A robot is equipped with three sensors along each principal direction that provide feedback about energy source levels, goal levels and visibility. See the section below on the robot interface for details about these values.

Commanding Robots

The following commands can be issued to each of the robots.


  Integer MoveUp(String robot_name);
  Integer MoveRight(String robot_name);
  Integer MoveDown(String robot_name);
  Integer MoveLeft(String robot_name);

As their names suggest, these commands attempt to move the controlled robot up, right, down, or left. The integer value returned is interpreted as follows.

  • 1 means the move succeeded
  • -1 means the move failed due to the presence of a dynamic obstacle
  • 0 means the move failed due to the presence of a static obstacle

Sensing Energy Sources and Goal

  Real[5] QueryEnergySensor();
  Real[5] QueryGoalSensor();

These commands query the energy and goal values, respectively, in the neighborhood of the robot. They return an array of five real values in the range [0, 1], corresponding to the interpolated energy/goal values at the cell location in the directions up, right, down and left, respectively, followed by the energy/goal value at the current location of the robot.

Sensing Obstacles

Integer[4] QueryVisibilitySensor();

This command is used to determine the mobility of the robot from its current location. It returns an array of four integers ∈ {-1, 0, 1} where each of the four values corresponding to cells in the directions up, right, down and left, respectively. The values have the following interpretation.

  • 1 means the desired cell is currently unoccupied
  • -1 means there is a dynamic object in the desired cell
  • 0 means there is a static object in the desired cell

Querying Location and Energy Level

Real[3] QueryRobotState();

This command returns an array of three real values corresponding to the controlled robot's current row and column position and its current energy level, respectively. Note that the robot's coordinates are returned as real numbers rather than integers.

Using RoboSim

To use RoboSim, first start the IPC communication server:

% ipc

Then, in a separate Unix shell, start the graphical simulator:

% robosim

Finally, in a third shell, run the Plexil Executive with the plan of your choice:

% plexilexec -p <plan-file> -c <config>

where <config> must be plexil/src/apps/robosim/interface-config.xml. Note that other options to plexilexec are possible.

Currently, PLEXIL can control a yellow robot ("RobotYellow") and a blue one ("RobotBlue3"). Other robots move around randomly until they run out of energy.

PLEXIL Interface

PLEXIL plans can interact with RoboSim using commands only. At this time no lookups (world state queries) have been implemented.

The commands available are exactly those listed above in the section Commanding Robots.

See the directories plexil/src/apps/robosim/plans and robosim/scripts for sample PLEXIL code, which contain examples of the commands.

Copyright (c) 2006-2014, Universities Space Research Association (USRA). All rights reserved.