Webots Reference Manual - chapter 3 - section 36

Webots Reference Manual


3.36 Pen

Derived from Device.

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

3.36.1 Description

The Pen node models a pen attached to a mobile robot, typically used to show the trajectory of the robot. The paint direction of the Pen device coincides with the -y-axis of the node. So, it can be adjusted by modifying the rotation and translation fields of the Solid node. In order to be paintable, an object should be made up of a Solid node containing a Shape with a valid Geometry. Even if a ImageTexture is already defined, the painture is applied over the texture without modifying it.

The precision of the painting action mainly depends on the subdivision field of the Geometry node. A high subdivision value increases the number of polygons used to represent the geometry and thus allows a more precise texture mapping, but it will also slow down the rendering of the scene. On the other hand, with a poor texture mapping, the painted area could be shown at a different position than the expected one. An example of a textured floor used with a robot equipped with a pen is given in the pen.wbt example world (located in the projects/samples/devices/worlds directory of Webots).

The inkEvaporation field of the WorldInfo node controls how fast the ink evaporates (disappears).
The drawings performed by a pen can be seen by infra-red distance sensors. 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.

3.36.2 Field Summary

3.36.3 Pen Functions



NAME

   wb_pen_write - enable or disable pen writing

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

  #include <webots/pen.h>

  void wb_pen_write(WbDeviceTag tag, 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 tag device will write; if write is false, it won't.



NAME

   wb_pen_set_ink_color - change the color of a pen's ink

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

  #include <webots/pen.h>

  void wb_pen_set_ink_color(WbDeviceTag tag, int color, double density);

DESCRIPTION

wb_pen_set_ink_color() changes the current ink color of the specified tag 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 blue, 0xFFA500 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.

language: Matlab
In the Matlab version of wb_pen_set_ink_color(), the color argument must be a vector containing the three RGB components: [RED GREEN BLUE]. Each component must be a value between 0.0 and 1.0. For example the vector [1 0 1] represents the magenta color.
release 7.0.2
Copyright © 2012 Cyberbotics Ltd. All right reserved.