3.36 Pen
Derived from Device.
Pen { |
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).
|
|
|
|
3.36.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 with the pen. It is also switchable from the pen API, using the wb_pen_write() function.
3.36.3 Pen Functions
NAME
wb_pen_write - enable or disable pen writingSYNOPSIS [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 inkSYNOPSIS [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.
|
|