This article is automatically translated from Russian by Google Translator.
Sensor variables are reserved variables for getting readings of the sensors connected to the corresponding ports.
These values can be assigned to variables and used in mathematical expressions.
Variable changes can be tracked as you go through the program in the variable table.
An array of three elements containing accelerometer readings on the X, Y, and Z axis, respectively.
The color sensor readings by the camcorder in the center of the frame are the intensity of red, green, and blue, respectively. They are only updated when the color sensor is turned on and initialized.
From 0 to 255.
The coordinates of pressing the active areas on the remote control.
Each variable stores an array of two elements corresponding to the coordinate of the click point.
From (-100, -100) to (100, 100), (-100, -100) - top left corner of the active area. (-101, -101) - if there is no click.
An array of three elements containing the gyroscope readings on the X, Y, and Z-axis respectively.
An array of three elements containing camera readings inline sensor mode. The values are updated when the sensor is on and initialized.
Variable
Description
An array of three elements containing accelerometer readings on the X, Y, and Z-axis.
buttonDown
buttonUp
buttonEnter
buttonEsc
buttonPower
buttonLeft
buttonRight
State of the buttons on the TRIK controller body: "Down", "Up",
"Enter", "Esc", "Power",
"Left", "Right".
Possible values: 0 — button not pressed. 1 — button pressed.
The color sensor readings by the camcorder in the center of the frame are the intensity of red, green, and blue, respectively.
They are only updated when the color sensor is turned on and initialized.
Possible values: 0 ... 255
encoder1 encoder2 encoder3 encoder4
Encoder readings on ports E1, E2, E3, E4 respectively.
gamepadButton1
...
gamepadButton5
The state of the buttons on the remote control from 1 to 5 respectively.
0 — the button is not pressed. 1 — button is pressed.
gamepadConnected
Remote control connection status.
0 — remote control is not connected. 1 — the remote control is connected.
The coordinates of pressing the active areas on the remote control.
Each variable stores an array of two elements corresponding to the coordinate of the press point.
Possible values: From (-100, -100) to (100, 100).
(-101, -101) — if there is no press.
gamepadPad1Pressed gamepadPad2Pressed
The state of the click on the left and right area of the remote control respectively. The coordinates of pressing can be found out with the help of the variables gamepadPad1 and gamepadPad2. Possible values: 1 — the active area on the remote control is pressed. 0 — the active area on the remote control is not pressed.
gamepadWheel
Tilt value of the remote control (if it is connected and the "steering wheel" is enabled on it).
Possible values: -100 ... 100. -101 — if there is no data on the "rudder" position.
-100 — extreme left position. 100 — extreme right position.
An array of three elements containing the gyroscope readings on the X, Y, and Z-axis respectively.
The array of three elements containing the camera readings in the line sensor mode. The values are updated when the line sensor is enabled and initialized.
objectSensorX objectSensorY
The coordinates of the object detected by the video camera in relation to the center of the screen. The values are updated when the sensor is on and initialized.
Possible values: -100 to 100 (relative to the center of the frame).
objectSensorSize
The size of the object recognized by the video camera. The value is updated when the object sensor is activated and initialized.
Possible values: 0 to 100.
100 - object occupies the whole frame.
sensorA1 ... sensorA6
Readings of the sensors connected to the corresponding analog ports.
sensorD1 sensorD2
Readings from sensors connected to the corresponding digital ports.
lineSensor[0]
The deviation of the line from the screen center from -100 (leftmost line position in the frame) to 100 (rightmost line position).
lineSensor[1]
Crossing probability is defined as the percentage of points inside the horizontal stripe in the center of the frame that is recognized as a line, from 0 (no such points) to 100 (all points in the horizontal strip are recognized as a line).
lineSensor[2]
Relative line size, that is, the number of points in the frame defined as a line, from 0 (no line in the frame) to 100 (the whole frame is recognized as a line).
TRIK specific blocks consist of three categories:
Actions - blocks that perform any action on the controller: turning on the motors, playing sounds, etc.
Waiting - blocks waiting for an event to occur: certain sensor readings, pressing a button, etc.
Drawing - blocks displaying graphics and text on the screen.
For blocks common for all platforms see the article
Sends the message to a parallel task with a specified identifier (the identifier must be specified while creating the task in the "Fork" block).
The message can be arbitrary.
Assigns the pressed button code to a specified variable.
The "Waiting" property allows you to wait for the button to be pressed. If the button is not pressed, the variable will be set to -1.
Plays a sound with specified frequency and duration on the controller.
Plays an audio file on the controller.
The file must be pre-loaded on the controller. The path to the file is relative to the trik
folder on the controller. You can download the file to the controller, for example, using the WinSCP program.
Turn on the motors on the given ports with the given power.
The ports are specified by lines M1, M2, M3, and M4, separated by commas. The power specified as a percentage by a number from -100 to 100. If the value is negative, the motors will be reversed.
Turn on the motors in reverse mode on the given ports with the given power.
Parameters are similar to the "motors forward" block.
Stop the motors on the specified ports.
The ports are specified by lines M1, M2, M3, and M4, separated by commas.
Reset the motors revolutions count on the specified ports.
The ports are specified by lines E1, E2, E3, and E4, separated by commas.
Set the servos rotation angle on the specified ports to the specified position (from -90 to 90 degrees).
The ports are specified by comma separated values.
Use the speaker to say the phrase passed as the block argument.
Set the specified LED color on the controller.
The block has a logical parameter "Code". If it's True, the content of the "Command" parameter translates directly into the program code. Otherwise, an OS' CLI call will be pulled.
Enable the video camera on the controller in one of three modes:
Line Sensor - detects a color line in the center of the frame and subsequently returns the deviation of the center of the line from the center of the frame as a number in the range from -100 (left) to 100 (right).
Object sensor - detects a contrasting object in the center of the frame and later returns the coordinates of its center and diameter in pixels.
Color sensor - returns the dominant color in the center of the frame as its coordinates in the RGB color scale.
Captures the image in the center of the frame and initializes a line sensor or object sensor with it. The camera must be switched on in the appropriate mode with the "Initialize Camera" block.
Places the current line sensor reading in the specified variable.
The camera must be switched on inline sensor mode by the "Initialize Camera" block and initialized by the "Detect by camera" block.
Starts a video broadcast on the robot.
The video can be viewed on the TRIK control panel or in a browser at the address
{robots ip-address}:8080/?action=stream/
.
Sends the message to the robot with the board number specified.
The robot must be on the same network as the robot sending the message and registered as master or slave using Settings → Messages
on the robot. If there is more than one robot with the given board number in the network, all of them will receive the message.
Writes the given expression to a file.
The path can be absolute or relative to the folder containing trik-studio.exe
.
The file can be retrieved from the controller, e.g. with the WinSCP program for Windows or SCP for Linux.
Deletes a file.
The path can be absolute or relative to the folder containing trik-studio.exe
.
Turn off the camera.
Stop the video feed from the robot's camera.
Sets the gyroscope angle to zero at the current position..
Wait for a message from another parallel task.
The message text will be assigned to the specified variable.
The "Wait for message" property allows you to specify what to do if the message queue is empty: wait for a new message to arrive or continue working by assigning an empty string to the variable.
The message is automatically converted to the same type as the receiver variable. For example, if you send a number as a string, it will be accepted as a number.
Wait for the user to enter a value. The value will be assigned to the specified variable.
The block has three properties:
Example
Wait until the value returned by the gyro sensor on the specified port is greater or less than the one specified in the "degrees" parameter..
Wait for the touch sensor to operate on the specified port.
Wait until the value returned by the light sensor on the specified port is greater or less than the one specified in the "percents" parameter. Parameters:
"Percents" - value to compare with the value returned by the light sensor.
"Port" - the port to which the light sensor is connected.
"Read value" - the operation that will be used to compare with the value of the "Percents" parameter.
Wait until the distance returned by the ultrasonic distance sensor is greater or less than the one specified in the "distance" parameter (distance is set in centimeters, from 0 to 300).
Parameters:
"Distance" - value to compare with the value returned by the distance sensor.
"Port" - the port to which the distance sensor is connected.
"Read value" - the operation to be used for comparison with the value of the Distance parameter.
Wait until the distance returned by the infrared distance sensor is greater or less than the one specified in the "distance" parameter.
By default, the distance on ports A1 and A2 is set in centimeters (from 0 to 100). It is not recommended to connect other sensors to these ports as incorrect values may be read.
Another parameter is the number of the port to which the distance sensor is connected. The last parameter specifies the operation to be used for comparison with the distance.
Wait until the revolutions count reading on the specified port is greater or less than the Tacho limit value.
Wait until the specified button on the robot is pressed.
Wait for the message in the mailbox. When the message is received, it will be assigned to the specified variable.
The Wait for message property allows you to specify what to do if the message queue is empty: wait for a new message to arrive or continue working by putting an empty string into the variable.
The message is automatically converted to the type corresponding to the receiver variable type, i.e. you can, for example, send a number as a string and accept it as a number.
Wait for the button to be pressed on the remote control connected to the robot. The buttons are numbered from 1 to 5.
Wait for one of the two active areas of the RC to be pressed. The coordinates of the click can be obtained with the "gamepadPad" sensory variables.
Wait for the desired tilt of the RC.
The tilt is only registered if the remote is in "steering" mode, the tilt angle is coded with numbers from -100 (maximum left) to 100 (maximum right).
Another parameter specifies the operation that will be used to compare with the Angle parameter value.
Wait until the RC is disconnected from the robot. If the RC is not connected, the program will continue running.
Wait for the RC to connect to the robot. If the RC is already connected, the program will continue running.