Webots Reference Manual

previous page go up next page

Thanks

1. Introduction

2. Node Chart

3. Nodes and API Functions

4. Prototypes

5. Physics Plugin

6. Fast2D Plugin

7. MTN Functions

8. Webots World Files

     

3.1 Accelerometer

Derived from Solid.

Accelerometer {
  SFFloat    resolution   0.01 # m/s2
}

3.1.1 Description

The Accelerometer node is used to model a 3D accelerometer device such as those commonly found in mobile electronic devices. This component can measure the instantaneous acceleration in three dimensions over the X, Y and Z axes.

3.1.2 Field Summary

  • resolution: This field defines the precision of the accelerometer, that is the absolute maximum error (expressed in m/s2) in the measured acceleration. This error is implemented in Webots as white noise.

3.1.3 Accelerometer Functions

NAME

   accelerometer_enable, accelerometer_disable - enable and disable the accelerometer measurements

C/C++ SYNOPSIS

  #include <device/accelerometer.h>

   void accelerometer_enable (DeviceTag sensor, unsigned short ms);
   void accelerometer_disable (DeviceTag sensor);

JAVA SYNOPSIS

  import com.cyberbotics.webots.Controller;

   void accelerometer_enable (int sensor, int ms);
   void accelerometer_disable (int sensor);

DESCRIPTION

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

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

NAME

   accelerometer_get_values, accelerometer_value_x, accelerometer_value_y, accelerometer_value_z - get the accelerometer measurement as an array of 3 floating point values (X, Y and Z accelerations)

C/C++ SYNOPSIS

  #include <device/accelerometer.h>

   const float *accelerometer_get_values (DeviceTag sensor);
   float accelerometer_value_x (const float values[3]);
   float accelerometer_value_y (const float values[3]);
   float accelerometer_value_z (const float values[3]);

JAVA SYNOPSIS

  import com.cyberbotics.webots.Controller;

   float[] accelerometer_get_values (int sensor);
   float accelerometer_value_x (float[] values);
   float accelerometer_value_y (float[] values);
   float accelerometer_value_z (float[] values);

DESCRIPTION

The accelerometer_get_values() function returns the last values measured by the specified accelerometer sensor. The value returned is an array of 3 floating point numbers representing the 3D acceleration vector of the Accelerometer node, expressed in meters per second squared (m/s2).

The accelerometer_value_x(), accelerometer_value_y() and accelerometer_value_z() functions are helper macros used to retrieve the x, y and z acceleration components measured by the accelerometer sensor from the floating point array data. They are defined as follows:

#define accelerometer_value_x(array) ((array)[0])
#define accelerometer_value_y(array) ((array)[1])
#define accelerometer_value_z(array) ((array)[2])

previous page go up next page
^ page top ^

  E-mail to webmaster Last updated: Copyright © 2008 Cyberbotics Ltd.