Webots Reference Manual - chapter 3 - section 1

Webots Reference Manual


3.1 Accelerometer

Derived from Device.

Accelerometer {
  MFVec3f    lookupTable    []    # interpolation
  SFBool     xAxis          TRUE  # compute x-axis
  SFBool     yAxis          TRUE  # compute y-axis
  SFBool     zAxis          TRUE  # compute z-axis
}

3.1.1 Description

The Accelerometer node can be used to model accelerometer devices such as those commonly found in mobile electronics, robots and game input devices. The Accelerometer node measures acceleration and gravity induced reaction forces over 1, 2 or 3 axes. It can be used for example to detect fall, the up/down direction, etc.

3.1.2 Field Summary

3.1.3 Accelerometer Functions



NAME

   wb_accelerometer_enable, wb_accelerometer_disable, wb_accelerometer_get_sampling_period, wb_accelerometer_get_values - enable, disable and read the output of the accelerometer

SYNOPSIS [C++] [Java] [Python] [Matlab]

  #include <webots/accelerometer.h>

  void wb_accelerometer_enable(WbDeviceTag tag, int ms);
  void wb_accelerometer_disable(WbDeviceTag tag);
  int wb_accelerometer_get_sampling_period(WbDeviceTag tag);
  const double *wb_accelerometer_get_values(WbDeviceTag tag);

DESCRIPTION

The wb_accelerometer_enable() function allows the user to enable the acceleration measurement each ms milliseconds.

The wb_accelerometer_disable() function turns the accelerometer off, saving computation time.

The wb_accelerometer_get_sampling_period() function returns the period given into the wb_accelerometer_enable() function, or 0 if the device is disabled.

The wb_accelerometer_get_values() function returns the current values measured by the Accelerometer. These values are returned as a 3D-vector, therefore only the indices 0, 1, and 2 are valid for accessing the vector. Each element of the vector represents the acceleration along the corresponding axis of the Accelerometer node, expressed in meters per second squared [m/s2]. The first element corresponds to the x-axis, the second element to the y-axis, etc. An Accelerometer at rest with earth's gravity will indicate 1 g (9.81 m/s2) along the vertical axis. Note that the gravity can be specified in the gravity field in the WorldInfo node. To obtain the acceleration due to motion alone, this offset must be subtracted. The device's output will be zero during free fall when no offset is substracted.

language: C, C++
The returned vector is a pointer to the internal values managed by the Accelerometer node, therefore it is illegal to free this pointer. Furthermore, note that the pointed values are only valid until the next call to wb_robot_step() or Robot::step(). If these values are needed for a longer period they must be copied.
language: Python
getValues() returns the 3D-vector as a list containing three floats.
release 7.0.2
Copyright © 2012 Cyberbotics Ltd. All right reserved.