Webots Reference Manual

previous page go up next page

Thanks

1. Introduction

2. Node Chart

3. Nodes and API Functions

4. Motion Functions

5. Prototypes

6. Physics Plugin

7. Fast2D Plugin

8. MTN Functions

9. Webots World Files

     

3.27 LED

Derived from Solid.

LED {
  MFColor   color   [ 1 0 0 ]  # [0,1]
  SFBool    gradual FALSE      # for gradual color display and RBG LEDs
}

3.27.1 Description

The LED node is used to model a light emitting diode (LED). The light produced by an LED can be used for debugging or informational purposes. The shape of the light-emitting part of the LED device is defined as a Solid node in the children list of the LED node. This Solid node should have a name field set to "lamp" in order to be recognized as the light emitting part of the LED device. Upon activation, the emissiveColor field of the first Material node in this Solid node will be changed to the color specified by the color field of the LED node.

If such a "lamp" Solid node doesn't exist, the color change applies to the first Shape node in the children list which has a Material node defined.

3.27.2 Field Summary

  • color: This defines the colors of the LED device. When off, an LED is always black. However, when on it may have different colors as specified by the LED programming interface. By default, the color defines only one color (red), but you can change this and add extra colors that could be selected from the LED programming interface. However, the number of colors defined depends on the value of the gradual field (see below).

  • gradual: This defines the type of LED. If set to FALSE, the LED can take any of the color values defined in the color list. If set to TRUE, then the color list should either be empty or contain only one color value. If the color list is empty, then the LED is an RGB LED and can take any color in the R8G8B8 color space (16 million possibilities). If the color list contains a single color, then the LED is monochromatic, and its intensity can be adjusted between 0 (off) and 255 (maximum intensity).

3.27.3 LED Functions

NAME

   wb_led_set - turn an LED on or off

C SYNOPSIS

  #include <webots/led.h>

  void wb_led_set(WbDeviceTag device, int value);

C++ SYNOPSIS

  #include <webots/LED.hpp>

  void LED::set(int value);

JAVA SYNOPSIS

  import com.cyberbotics.webots.controller.LED;

  void LED.set(int value);

PYTHON SYNOPSIS

  from controller import LED

  none LED.set(int value)

DESCRIPTION

wb_led_set() switches an LED on or off, possibly changing its color. If the value parameter is 0, the LED is turned off. Otherwise, it is turned on.

In the case of a non-gradual LED (gradual field set to FALSE), if the value parameter is 1, the LED is turned on using the first color specified in the color field of the corresponding LED node. If the value parameter is 2, the LED is turned on using the second color specified in the color field of the LED node, and so on. The value parameter should not be greater than the size of the color field of the corresponding LED node.

In the case of a monochromatic LED (gradual field set to TRUE and color field containing exactly one color), the value parameter indicates the intensity of the LED in the range 0 (off) to 255 (maximum intensity).

In the case of an RGB LED (gradual field set to TRUE and color field containing an empty list), the value parameter indicates the RGB color of the LED in the range 0 (off or black) to 0xffffff (white). The format is R8G8B8: The most significant 8 bits (left hand side) indicate the red level (between 0x00 and 0xff). Bits 8 to 15 indicate the green level and the least significant 8 bits (right hand side) indicate the blue level. For example, 0xff0000 is red, 0x00ff00 is green, 0x0000ff is blue, 0xffff00 is yellow, etc.

previous page go up next page
^ page top ^

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