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.31 Pen

Derived from Solid.

Pen {
  SFColor   inkColor     0 0 0   # [0,1]
  SFFloat   inkDensity   0.5
  SFFloat   leadSize     0.002
  SFBool    write        TRUE
}

3.31.1 Description

The Pen node models a pen attached to a mobile robot, typically used to show the trajectory of the robot. In order to work, a pen needs to be over a textured floor. Such a textured floor should be made up of a Solid node containing a Shape with a textured Material in its Appearance. Additionally, its geometry should be a rectangular IndexedFaceSet located at y=0. An example of an appropriate textured floor used with a robot equipped with a pen is given in the botstudio_pen.wbt example world (located in the projects/robots/hemisson/worlds directory of Webots).

Note: The drawings performed by a pen can be seen by infra-red distance sensors looking down at the ground. Hence, it is possible to implement a robotics experiment where a robot draws a line on the floor with a pen and a second robot performs a line following behavior with the line drawn by the first robot.

Note: The pen drawing will not be seen by Camera devices when the camera windows are displayed outside of Webots' main window. However, the pen drawing will be correctly perceived by Camera devices rendered inside Webots' main window. Please find more information on the two different camera behaviors in the Camera section.

3.31.2 Field Summary

  • inkColor: define the color of the pen's ink. This field can be changed from the pen API, using the wb_pen_set_ink_color() function.

  • inkDensity: define the density of the color of the ink. This field can also be changed from the pen API, using the wb_pen_set_ink_color() function.

  • leadSize: define the width of the "tip" of the pen. This allows the robot to write a wider or narrower track.

  • write: this boolean field allows the robot to enable or disable writing by the pen. It is also switchable from the pen API, using the wb_pen_write() function.

3.31.3 Pen Functions

NAME

   wb_pen_write - enable or disable pen writing

C SYNOPSIS

  #include <webots/pen.h>

  void wb_pen_write(WbDeviceTag pen, bool write);

C++ SYNOPSIS

  #include <webots/Pen.hpp>

  void Pen::write(bool write);

JAVA SYNOPSIS

  import com.cyberbotics.webots.controller.Pen;

  void Pen.write(boolean write);

PYTHON SYNOPSIS

  from controller import Pen

  none Pen.write(bool write)

DESCRIPTION

wb_pen_write() allows the user to switch a pen device on or off to disable or enable writing. If the write parameter is true, the specified pen device will write; if write is false, it won't.

NAME

   wb_pen_set_ink_color - change the color of a pen's ink

C SYNOPSIS

  #include <webots/pen.h>

  void pen_set_ink_color(WbDeviceTag pen, int color, double density);

C++ SYNOPSIS

  #include <webots/Pen.hpp>

  void Pen::setInkColor(int color, double density);

JAVA SYNOPSIS

  import com.cyberbotics.webots.controller.Pen;

  void Pen.setInkColor(int color, double density);

PYTHON SYNOPSIS

  from controller import Pen

  none Pen.setInkColor(int color, float density)

DESCRIPTION

wb_pen_set_ink_color() changes the current ink color of the specified pen device. The color is a 32 bit integer value which defines the new color of the ink in the 0xRRGGBB hexadecimal format (i.e., 0x000000 is black, 0xFF0000 is red, 0x00FF00 is green, 0x0000FF is green, 0xF0A040 is orange, 0X808080 is grey 0xFFFFFF is white, etc.). The density parameter defines the ink density, with 0 meaning transparent ink and 1 meaning completely opaque ink.

EXAMPLE

wb_pen_set_ink_color(pen,0xF01010.0.9);

The above statement will change the ink color of the indicated pen to some red color.

previous page go up next page
^ page top ^

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