You are here

Sensor simulator description

Sensor simulator is a java standalone application that simulates sensor data and transmits them to the Android emulator. You can try out a web preview version of the Sensor simulator online.

Currently, Sensor simulator sensors supports the following functions:

  • Simulates accelerometer, compass, and orientation sensors, as well as a temperature sensor.
  • Mobile device can be rotated and moved through the mouse or sliders.
  • Supports all functionality that the Android Sensor classes provide (enabled / supported sensors, sensor update rates).
  • Listens on a selectable port for incoming connection from the Android emulator.
  • Many settings available to control various aspects of the sensors.

The connection settings are set in the emulator through the sensor simulator settings. There one can also test the connection and see the data transmitted.

Try it out

  • Launch the Sensor Simulator as standalone application from the tools directory.
  • In the emulator, open OpenIntents, then tab "Settings", and then "Sensor Simulator".
  • There you should enter the IP address and socket as displayed in the Sensor Simulator application.
  • To test the connection, click on the "Testing" tab and press "Connect".
  • Note: The first time you connect to the SensorSimulator, all sensors are DISABLED automatically. This is, because it is the Android application's responsibility to enable the sensors before reading values.
  • In the emulator, enable the sensors you wish to monitor.
  • If you rotate or move the mobile device in the Sensor simulator, the values in the emulator are updated as well.
  • You can also set the sensor update rate in the emulator (see below for details).
  • When you are done, disable the sensors and press "Disconnect".
  • You may further test the Sensor simulator with the sample application OpenGLSensors or with the API Demos Sensors.

Testing advanced features

The SensorSimulator throws the same exceptions as a real sensor would. To try this out:

  • Switch to the "Testing" tab in the sensor simulator settings and connect
  • Enable a sensor in the settings tab of the emulator.
  • Disable the same sensor in the SensorSimulator java application in the settings pane.
  • A moment later, when the Android emulator tries to read out the sensor values to update them, an exception is thrown.
  • An application developer can catch these exceptions in their program and test these exceptions properly.
  • Tip: if you want to change the supported sensors, disconnect first, then adjust the settings, and then connect again.

  • Settings in the Sensor Simulator

    The Sensor Simulator allows a lot of customization. Scroll down the settings pane to see all settings.
    Supported sensors:
    Choose the supported Sensors, that is those sensors that are reported to be available in the emulator. Do this before you connect the emulator to the Sensor simulator.
    Enabled sensors:
    Sensors have to be enabled by the application. You should not need to touch these check boxes, except for testing purposes.
    Sensor update rate:

    'Update rates' lets you specify a list of possible update rates that is reported to the Android emulator. 'Default rate' is the rate to which a sensor is reset upon unsetting the rate from an application. 'Current rate' is the current update rate as set by the application. 'Average ' means that average sensor data should be returned instead of instantaneous values. Internally the simulation is updated as specified below in 'Simulation update', but the data output is only updated at the rate specified here.

    Simulation update:

    This sets the internal update rate of the Sensor simulator. 'Update sensors' sets the duration between internal updates. External updates are controlled by the 'Update rates' settings above. 'Refresh after' determines after how many queries by the emulator the update rates given below are calculated and averaged over. If sensors are enabled and read out through the emulator, the actual read-out rates are displayed here. 'Sensor update' shows the actual internal update rate.
    Accelerometer:

    Lets you specify the physical behavior of the accelerometer. 'Gravity constant' is the earth's gravity constant. Accelerometer limit limits the values returned independently for the x-, y-, and z-components. 'Pixels per meter' is used to calculate between screen distance and real word distance in units pixel per meter (p/m). The accelerometer is physically modeled through the deviation of a test mass on a spring. Its spring constant to mass ratio k/m is given in screen units pixel per seconds squared (p/s^2), and its damping constant is given in pixels per second. 'Show acceleration' displays the current acceleration in the simulated device.
    Gravity:

    You can set the standard gravity to a different value in units of g=9.8 m/s^2.
    Magnetic field:

    Set the magnetic field in units of nano Tesla. You can obtain the values for your current location from the National Geophysical Data Center.
    Temperature:

    Set the temperature in centigrade Celsius.
    Random component:

    Set a random component that is added to the data to simulate inaccurate sensors.
    Real sensor bridge:

    This feature will let you connect a real hardware sensor to the Sensor simulator to control applications in the emulator. In the current version it only displays the sensor data on a Thinkpad computer, if the sensor data are written to a special file.

    The wii-mote extension by Dale Thatcher lets you connect a wii-mote to the sensor simulator.