Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
This article is automatically translated from Russian by Google Translator.
Represents the gyroscope of the TRIK controller. At rest, the average value of the gyroscope output is not zero and is called a bias
or bias error
.
The parameter is determined by many factors and can vary, for example, depending on the ambient temperature.
In order for the gyroscope to work properly it is necessary to subtract the zero offset from the incoming values. This can be calculated using the "calibrate" method.
Since calibration takes a long time, if you run the model frequently, you can do it once, then store the value in a variable with "getCalibrationVaules", and call "setCalibrationValues" instead of calibration when you run the program.
Calculates a zero offset within a specified time and initializes the gyroscope with this parameter, resets the current tilt angles. The recommended calibration time is 10-20 seconds.
Parameter:
msec
— time in milliseconds.
The signal sent by the sensor after the end of the calibration.
Returns an object that contains the necessary zero-offset data.
Returns true
if calibration is complete, false
otherwise.
The signal sent by the sensor when it has new data ready.
Returns an array of seven elements:
0−2 — angular velocities on the three axes (in milligrades/seconds),
3 — a time of the last measurement (in microseconds),
4−6 — tilt angles on the three axes (in milligrads).
Returns an array of three elements with angular velocities on the three axes.
Sets the object containing the necessary parameters about the zero offset.
Since calibration takes a long time, if you run the model frequently, you can do it once, then store the value in a variable with "getCalibrationVaules", and call "setCalibrationValues" instead of calibration when you run the program.
Parameter:
values
— object containing bias data.
This article is automatically translated from Russian by Google Translator.
Provides access to the display of the robot.
Screen size: 240*320 pixels.
Print the specified text on the screen, starting from the specified coordinate. If there was already text in the specified coordinates, it will be replaced by the new text.
The changes on the display will occur only after calling the method "redraw".
Parameters:
text
— display text,
x
, y
— screen coordinates.
Clear the drawing window.
Draw an arc of an ellipse inscribed into a rectangle with the upper left corner at specified coordinates and having a given width and height. The changes on the display will occur only after calling the method "redraw".
Parameters:
x
, y
— the coordinates of the upper left corner of the rectangle on the screen,
l
— rectangle width,
h
— rectangle height,
from
— initial angle bounding the arc,
to
— finite angle bounding the arc.
Draw an ellipse inscribed into a rectangle with the upper left corner at specified coordinates and having a given width and height. The changes on the display will occur only after calling the method "redraw".
Parameters:
x
, y
— coordinates of the upper left corner of the rectangle,
l
— rectangle width,
h
— rectangle height.
Draw a line with the beginning and the end at the given coordinates. The changes on the display will occur only after calling the method "redraw".
Parameters:
x0
, y0
— line origin coordinates,
x1
, y1
— line end coordinates.
Draw a point at given coordinates. The changes on the display will occur only after calling the method "redraw".
Parameters:
point coordinates x
, y
.
Draw a rectangle with the upper left corner at the specified coordinates and having the specified width and height. The changes on the display will occur only after calling the method "redraw".
Parameters:
x
, y
— coordinates of the upper left corner of the rectangle,
l
— rectangle width,
h
— rectangle height.
Close and clear the drawing window.
Redraw the window to draw. The changes to the display will only happen after this method is called.
Remove from the screen all text added to it by calls to the "addLabel" method.
Set the screen background to the color you specify.
Available colors:
white,
red, darkRed,
green, darkGreen,
blue, darkBlue,
cyan, darkCyan,
magenta, darkMagenta,
yellow, darkYellow,
gray, darkGray, lightGray,
black.
As a parameter, you must specify the color.
Set the color of the brush used to draw the graphical primitives.
Available colors:
white,
red, darkRed,
green, darkGreen,
blue, darkBlue,
cyan, darkCyan,
magenta, darkMagenta,
yellow, darkYellow,
gray, darkGray, lightGray,
black.
As a parameter, you must specify the color.
Set the thickness of the brush used to draw the graphical primitives, in pixels.
As a parameter, you must specify the thickness d
.
Display the image generated in the one-dimensional array on the controller.
Parameters:
array
— a one-dimensional integer array with dimensions width
×height
width
и height
— the width and height of the image, respectively
The format in which each element of the array is represented should be passed as the format parameter. The formats currently supported are: «rgb32», «grayscale8», «rgb888».
Examples of using show()
on an image taken withgetPhoto()
.
Display the image previously loaded on the robot.
The name of the image file (in BMP, GIF, JPG, JPEG, PNG, PBM, PGM, PPM, TIFF, XBM, XPM formats) must be specified as a parameter, the path is specified either as absolute or relative to the trik
folder.
This article is automatically translated from Russian by Google Translator.
Represents power motor encoders connected to ports E1, E2, E3, E4.
Returns the current encoder reading in degrees on the specified port.
As a parameter, you must specify the port.
Resets the current encoder reading to 0.
As a parameter, you must specify the port.
Returns the current encoder reading in "ticks" on the specified port.
This article is automatically translated from Russian by Google Translator.
Used to operate the buttons on the robot's remote control.
Sent when the button with the specified code is pressed or released.
The first parameter is the code of the button, the second - 1 if the button is pressed, 0 if released.
Returns true
if the button with the specified code is currently pressed.
Possible options:
KeysEnum.Left
(code105),
KeysEnum.Up
(code 103),
KeysEnum.Down
(code 108),
KeysEnum.Enter
(code 28),
KeysEnum.Right
(code 106),
KeysEnum.Power
(code 116),
KeysEnum.Esc
(code 1).
Resets memorized button presses.
Returns whether or not a button with the specified code was pressed, reset the remembered presses for that button. Possible options:
KeysEnum.Left
(code 105),
KeysEnum.Up
(code 103),
KeysEnum.Down
(code 108),
KeysEnum.Enter
(code 28),
KeysEnum.Right
(code 106),
KeysEnum.Power
(code 116),
KeysEnum.Esc
(code 1).
This article is automatically translated from Russian by Google Translator.
The object "brick" represents the TRIK controller and provides access to the robot devices.
Provides access to the accelerometer (class "Accelerometer").
Provides access to battery information (class "Battery").
Provides access to the color sensor by the camera (class "ColorSensor").
Provides access to the display of the robot (class "Display").
Provides access to the encoder on the specified port (class "Encoder").
As a parameter, you must specify the port.
Get a photo from the camera as an array of bytes.
Provides access to the gyroscope (class "Gyroscope").
Provides access to the buttons on the robot body (class "Keys").
Provides access to the LED on the robot body (class "Led").
Provides access to the line sensor by the camera (class "LineSensor").
Provides access to the motor (power or servomotor) on the specified port (class "Motor").
As a parameter, you must specify the port.
Provides access to the object sensor by the camera (class "ObjectSensor").
Play the audio file.
As a parameter, you must specify the name of the file with an absolute path or the path relative to the folder trik
on the controller.
Warning! The file must be pre-loaded on the controller.
Say the line (in Russian or English).
As a parameter, you must specify a string in English or Russian.
Provides access to the sensor on the specified port (class "Sensor").
As a parameter, you must specify the port.
Stops all motors and active sensors, and removes what is drawn on the display.
This article is automatically translated from Russian by Google Translator.
Represents the accelerometer of the TRIK controller.
Returns the current sensor reading as an array of three elements corresponding to the sensor readings along each axis.
The signal sent by the sensor when new data is ready.
This article is automatically translated from Russian by Google Translator.
Represents a sensor (analog or digital) connected to ports A1, ..., A6, D1, D2.
Returns the current reading of the sensor (digital or analog) connected to this port. The present value is returned, depending on the port configuration, which is described in the file model-config.xml
in the trik
folder on the robot.
For example, the IR distance sensor returns a value in centimeters.
Returns the current raw reading of the sensor (digital or analog) connected to this port. The range of values depends on the specific sensor and does not take into account the configuration of the robot (the physical readings of the sensor are returned, e.g. the delay of the received ultrasonic signal).
This article is automatically translated from Russian by Google Translator.
Provides control of the robot motor (power or servo motor) connected to ports M1, ..., M4, S1, ..., S6.
Blocking of motors for braking for a specified time in milliseconds.
As a parameter, you must specify the time in milliseconds.
Returns the current motor power (-100 to 100).
Turns the motor off.
Turns on the motor with the specified power.
As a parameter, you must specify the power. The power is set in the range from -100 ("full reverse") to 100 ("full forward"). 0 corresponds to a force break
, i.e. the motor stops, it is blocked and remains energized.
This article is automatically translated from Russian by Google Translator.
Camera in object sensor mode. Captures a contrasting object in the center of the frame and returns its coordinates and size in the frame.
Detects the dominant color in the center of the frame and remembers it as the color of the object. After that, the "read" method starts to return data for the object.
Switches the camcorder on and initializes it in object sensor mode. The boolean parameter determines whether to display the image from the camera (true
— display).
The boolean parameter defines whether to display the image from the camera:
true
— output,
false
— don't output.
Returns an array that contains the following data in its cells:
In the zero cell, the X-axis coordinate of the object center relative to the center of the frame (-100 to 100, -100 is the center of the object on the edge of the frame on the left);
The Y-coordinate of the object's center relative to the frame center (from -100 to 100, -100 is the center of the object on the frame edge at the top);
The second cell is the relative size of the object, a number from 0 to 100 (100 - the object occupies almost the entire frame, 0 - the object is not on the frame).
Turns off the camera and stops the sensor.
This article is automatically translated from Russian by Google Translator.
The camera in color sensor mode.
Turns the camera on and initializes it in color sensor mode.
The boolean parameter defines whether to display the image from the camera:
true
— output,
false
— do not output
Returns an array with the coordinates of the dominant color in the RGB color scale in the specified area of the frame.
The frame is divided into squares by a grid, by default 3 by 3, the dimensionality of the grid can be set in model-config.xml
on the robot. Squares are indexed from 1. That is, (1, 1) is the upper-left edge of the frame, (2, 2) is its center.
The return value is an array of three elements from 0 to 255, indexed from 0. The zero element contains the intensity of red (0 - none at all, 255 - very much), the first - the intensity of green, the second - the intensity of blue. For example, (0, 0, 0) is black, (255, 255, 255) is white, (255, 0, 0) is red.
As a parameter, it is necessary to specify the indices of the square x
and y
.
Turns off the camera and stops the sensor.
This article is automatically translated from Russian by Google Translator.
Camera in line sensor mode.
Detects the dominant color in the vertical bar in the center of the frame and remembers it as a line color. Then the "" method starts returning data for that line.
Turns the camera on and initializes it inline sensor mode. The boolean parameter determines whether to display the image from the camera (true
- display).
The boolean parameter defines whether to display the image from the camera:
true
— output,
false
— don't output.
Returns an array with the following data in its cells:
the zero cell is the X coordinate of the line center relative to the center of the frame (from -100 to 100, -100 is the center of the line on the edge of the frame on the left);
in the first cell - the probability of crossing (the number from 0 to 100, showing how many points of the line color are in the horizontal stripe in the frame center);
the second cell - the relative size of the line, a number from 0 to 100 (100 - the line occupies almost the whole frame, 0 - the line is absent in the frame).
Turns off the video camera and stops the sensor.
Method
Description
Calculates a zero offset within a specified time and initializes the gyroscope with this parameter, resets the current tilt angles.
Returns an object that contains the necessary zero-offset data.
Returns true if calibration is complete, false otherwise.
Returns an array of seven elements: angular velocities on the three axes, time of the last measurement, tilt angles on the three axes.
Returns an array of three elements with angular velocities on the three axes.
Sets the object containing the necessary parameters about the zero offset.
Сигнал
Описание
The signal sent by the sensor after the end of the calibration.
The signal sent by the sensor when it has new data ready.
Method
Description
Print the specified text on the screen, starting from the specified coordinate.
Clear the drawing window.
Draw an arc of an ellipse inscribed into a rectangle with the upper left corner at specified coordinates and having a given width and height.
Draw an ellipse inscribed into a rectangle with the upper left corner at specified coordinates and having a given width and height.
Draw a line with the beginning and the end at the given coordinates.
Draw a point at given coordinates.
Draw a rectangle with the upper left corner at the specified coordinates and having the specified width and height.
Close and clear the drawing window.
Redraw the window to draw. The changes to the display will only happen after this method is called.
Remove from the screen all text added to it by calls to the "addLabel" method.
Set the screen background to the color you specify.
Set the color of the brush used to draw the graphical primitives.
Set the thickness of the brush used to draw the graphical primitives, in pixels.
Display the image generated in the one-dimensional array on the controller.
Display the image previously loaded on the robot.
Method
Description
Returns the current encoder reading in degrees on the specified port.
Resets the current encoder reading to 0.
Returns the current encoder reading in "ticks" on the specified port.
Method
Description
Sent when the button with the specified code is pressed or released.
Returns true
if the button with the specified code is currently pressed.
Сбрасывает запомненные нажатия кнопок.
Returns whether or not a button with the specified code was pressed, reset the remembered presses for that button.
Method
Description
Provides access to the accelerometer.
Provides access to battery information.
Provides access to the color sensor by the camera.
Provides access to the display of the robot.
Provides access to the encoder on the specified port.
Get a photo from the camera as an array of bytes.
Provides access to the gyroscope.
Provides access to the buttons on the body of the robot.
Play the audio file.
Provides access to the LED on the body of the robot.
Provides access to the line sensor by the camera.
Provides access to the motor on the specified port.
Provides access to the object sensor by the camera.
Pronounce the string passed as a parameter (in Russian or English).
Provides access to the sensor on the specified port.
Stops all motors and active sensors, and removes what is drawn on the display.
Method
Description
Returns the current sensor reading as an array of three elements corresponding to the sensor readings along each axis.
Signal
Description
The signal sent by the sensor when new data is ready.
Method
Description
Returns the current reading of the sensor (digital or analog) connected to this port.
Returns the current raw reading of the sensor (digital or analog) connected to this port.
Method
Description
Blocking of motors for braking for a specified time.
Returns the current motor power.
Turns the motor off.
Turns on the motor with the specified power.
Method
Description
Detects the dominant color in the center of the frame and remembers it as the color of the object.
Switches the camcorder on and initializes it in object sensor mode.
Returns an array with the X coordinate of the object center relative to the center of the frame, the Y coordinate of the object center relative to the center of the frame, and the relative size of the object.
Turns off the camera and stops the sensor.
Method
Description
Turns the LED on in "red" mode.
Turns the LED on in the "green" mode.
Turns the LED on in the "orange" mode.
Turns off the LED.
Method | Description |
Turns the camera on and initializes it in color sensor mode. |
Returns an array with the coordinates of the dominant color in the RGB color scale in the specified area of the frame. |
Turns off the camera and stops the sensor. |
Method | Description |
Detects the dominant color in the vertical bar in the center of the frame and remembers it as a line color. |
Turns the camera on and initializes it inline sensor mode. |
Returns an array with the X coordinate of the center of the line relative to the center of the frame, the probability of a crossover, and the relative size of the line. |
Turns off the video camera and stops the sensor. |