OpenRAVE Documentation

showsensors Module

Opens a GUI window showing the sensor data of a scene.


Running the Example: --example showsensors


See `Sensor Concepts`_ for detailed infromation on sensors. When requesting data from the sensor right after it is powered on, the sensor might not return valid data. Therefore have to make sure the data is good by checking that the time stamps changed.


The BaseCamera - basesensors interface has a simple implementation of a pinhole camera. This example shows a robot with a camera attached to its wrist. The example opens data/testwamcamera.env.xml and queries image data from the sensor as fast as possible. The image will change in real-time as the robot is moved around the scene. The wireframe frustum rendered next to the robot shows the camera’s field of view.


The OpenRAVE XML required to attach a camera to the robot similar to the example above is:

    <translation>0 -0.2 0</translation>
    <rotationaxis>0 1 0 -90</rotationaxis>
    <sensor type="BaseCamera" args="">
      <KK>640 480 320 240</KK>
      <color>0.5 0.5 1</color>


The BaseLaser2D - basesensors interface has a simple implementation of ray-casting laser sensors.


The following OpenRAVE XML attaches a simple 2D laser to the wam1 link of the robot:

  <AttachedSensor name="mylaser">
    <translation>0 0.2 0.4</translation>
    <rotationaxis>0 0 1 90</rotationaxis>
    <sensor type="BaseLaser2D" args="">

To OpenRAVE XML to attach a flash LIDAR sensor is:

  <AttachedSensor name="myflashlaser">
    <translation>-0.2 -0.2 0</translation>
    <rotationaxis>0 1 0 -90</rotationaxis>
    <sensor type="BaseFlashLidar3D">
      <KK>32 24 32 24</KK>
      <color>1 1 0</color>


Usage: [options]

Displays all images of all camera sensors attached to a robot.

  -h, --help            show this help message and exit
  --scene=SCENE         OpenRAVE scene to load

  OpenRAVE Environment Options:
                        List all plugins and the interfaces they provide.
                        Default collision checker to use
    --physics=_PHYSICS  physics engine to use (default=none)
    --viewer=_VIEWER    viewer to use (default=qtcoin)
    --server=_SERVER    server to use (default=None).
                        port to load server on (default=4765).
    --module=_MODULES   module to load, can specify multiple modules. Two
                        arguments are required: "name" "args".
    -l _LEVEL, --level=_LEVEL, --log_level=_LEVEL
                        Debug level, one of
    --testmode          if set, will run the program in a finite amount of
                        time and spend computation time validating results.
                        Used for testing

Main Python Code

def main(env,options):
    "Main example code."
    ienablesensor = 0
    while True:
        sensors = env.GetSensors()
        for i,sensor in enumerate(sensors):
            if i==ienablesensor:
        print 'showing sensor %s, try moving obstacles'%(sensors[ienablesensor].GetName())
        if sensors[ienablesensor].Supports(Sensor.Type.Laser):
            # if laser, wait for the sensor data to be updated and then print it
            olddata = sensors[ienablesensor].GetSensorData(Sensor.Type.Laser)
            while True:
                data = sensors[ienablesensor].GetSensorData(Sensor.Type.Laser)
                if data.stamp != olddata.stamp:
            print 'sensor data: ',data.ranges                        
        ienablesensor = (ienablesensor+1)%len(sensors)

Class Definitions

openravepy.examples.showsensors.main(env, options)[source]

Main example code.*args, **kwargs)[source]

Command-line execution of the example.

Parameters:args – arguments for script to parse, if not specified will use sys.argv


Having problems with OpenRAVE?