2D model tuning
Defines walls. Used as a container, has no attributes. In addition to creating a virtual world of robots in TRIK Studio, you can do more flexible customization by editing an XML file: specify the location of objects, color, width, and other parameters more precisely.
First, you need to create an XML file for the virtual model.
2D model coordinate system
In the 2D model window the axes located as follows:
Attention! One cell has dimensions of 17.5 × 17.5 centimeters or 50 × 50 pixels.
An XML file creation
To create an empty XML file you should use your OS' standard tools such as Notepad in Windows or whatever.
To save the world model created in TRIK Studio:
Switch to the 2D model mode.
Go to the "Debug mode".
Specify the location and file name to save.
Editing an XML file
Open a saved XML file in a text editor. Notepad++, for example.
The XML file contains tags and attributes.
Tags
Tag is a markup language element. There is the start (opening) and end (closing) tags. The text contained between the start and end tags is displayed and placed according to the properties specified in the start tag.
Example:
Attributes
Attributes are tag properties that provide additional text formatting capabilities. They are recorded as a combination of "attribute name-value". Text values are enclosed in quotation marks.
In the above example, the attributes are:
begin="200:-200"
id="{a3ede76b-1d7e-4c72-9ed4-08d8ea9af4bf}"
end="200:150"
The simplest virtual world model without objects in .xml
the format is as follows:
Robots
The following tags are available for describing robots:
Tag | Description |
Defines a robot on stage. Used as a container and must contain a robot element. | |
Adds a robot to the scene. Can be used as a container. | |
Defines sensors on a robot. Used as a container. | |
Sensors ports configuration. | |
Defines the starting position of the robot. | |
Motor ports configuration. |
<robots>...</robots>
Defines a robot on stage. Used as a container, has no attributes.
<robot>...</robot>
Adds a robot to the scene. Can be used as a container.
Attention! You can not add multiple robots to the scene.
Attributes
Attribute | Description |
direction="0″ | The direction of the robot, which can be adjusted by clicking on the robot and pulling the arrow. |
position="x:y" | The position of the robot, where x and y is the position of the upper left point of the square of the robot in the coordinate system. |
id="trikKitRobot" | Unique ID. |
Example:
<sensors>...</sensors>
Defines sensors on a robot. Used as a container, has no attributes.
<sensor/>
Sensors ports configuration.
Attributes
Attribute | Description |
position="x:y" | The position of the sensor, where x and y is the position of the center point of the square of the sensor in the coordinate system. |
direction="0″ | The direction of the sensor, which can be adjusted by clicking on the sensor and pulling the arrow. |
port="A1###input######sensorA1" | The port to which the sensor is connected. |
type="trik::robotModel::parts::TrikInfraredSensor" | Type of connected sensor. |
There are 5 types of sensors for TRIK and 9 types of sensors for EV3:
Sensor | Description |
TrikSonarSensor | Ultrasonic distance sensor |
TrikLineSensor | Line sensor. |
TrikLightSensor | Light sensor. |
TrikTouchSensor | Touch sensor. |
TrikInfraredSensor | Infrared distance sensor. |
Example:
<startPosition/>
Defines the starting position of the robot.
Attributes
Attribute | Description |
id="{name}" | Unique ID. |
direction="0″ | The direction of the robot, if you click on the "return" button. To adjust, click on the cross and pull the arrow. |
x="25″ | The x-axis position in the coordinate system. |
y="25″ | The y-axis position in the coordinate system. |
Example:
<wheels/>
Motor ports configuration.
Attributes
Attribute | Description |
left="M4###output###М4###" | The port to which the left engine is connected. |
right="M3###output###М3###" | The port to which the right engine is connected. |
Example:
Objects
The following tags are available for describing objects:
Tag | Description |
walls | Defines walls. Used as a container, has no attributes. |
skittles | Defines skittles. Used as a container, has no attributes. |
balls | Defines balls. Used as a container, has no attributes. |
colorFields | Defines the elements that you can draw (line, Bezier curve, rectangle, ellipse, elements drawn with a stylus). Used as a container, has no attributes. |
images | Specifies the inserted image. Used as a container, has no attributes. |
regions | Defines regions. Used as a container, has no attributes. |
Adds a wall. | |
Adds a skittle. | |
Adds a ball. | |
Adds a ball. | |
Adds a Bezier curve. | |
Adds a rectangle. | |
Adds an ellipse. | |
Detects the stylus on the scene. Used as a container. | |
Allows you to draw arbitrary shapes using the stylus. | |
Allows you to add regions to the scene. |
<wall>
Adds a wall to the scene.
Attributes
Attribute | Description |
id="{name}" | Unique ID. |
begin="x:y" | The beginning of the wall, where x and y is the position of the starting point in the coordinate system. |
end="x:y" | The end of the wall, where x and y is the position of the starting point in the coordinate system. |
Example:
![](https://help.trikset.com/~gitbook/image?url=https%3A%2F%2Fthumb.tildacdn.com%2Ftild6663-3261-4931-b236-333164353633%2F-%2Fresize%2F413x%2F-%2Fformat%2Fwebp%2F2019-03-18_18-57-03.png&width=768&dpr=4&quality=100&sign=4b210c30&sv=1)
<skittle>
Adds a skittle to the scene.
Attributes
Attribute | Description |
markerY="44″ | The position on which the skittle will stand along the Y-axis if you click on the "return" button. |
markerX="220″ | The position on which the skittle will stand along the X-axis if you click on the "return" button. |
id="{name}" | Unique ID. |
y="44″ | Y-axis position. |
x="220″ | X-axis position. |
Example:
<ball>
Adds a ball to the scene.
Attributes
Attribute | Description |
markerY="169″ | The position on which the ball will fall along the Y-axis if you click on the "return" button. |
markerX="-18″ | The position on which the ball will fall along the X-axis if you click on the "return" button. |
id="{name}" | Unique ID. |
y="169″ | Y-axis position. |
x="-18″ | X-axis position. |
Example:
![](https://help.trikset.com/~gitbook/image?url=https%3A%2F%2Fthumb.tildacdn.com%2Ftild6537-3061-4462-b664-646330373237%2F-%2Fresize%2F164x%2F-%2Fformat%2Fwebp%2F2019-03-18_19-05-10.png&width=768&dpr=4&quality=100&sign=ea495cdb&sv=1)
<line>
Adds a line to the scene.
Attributes
Attribute | Description |
begin="x:y" | The beginning of the line, where x and y is the position of the starting point in the coordinate system. |
end="x:y" | At end of the line, where x and y is the position of the starting point in the coordinate system. |
id="{name}" | Unique ID. |
stroke-width="6″ | Line width. |
fill="#ff000000″ | The line fills color. |
fill-style="none" | Fill style. In this case, this attribute does not make sense, because the line is always smooth. |
stroke-style="solid" | Line style. There are 5 styles:
|
stroke="#ff000000″ | Line color. |
Example:
![](https://help.trikset.com/~gitbook/image?url=https%3A%2F%2Fthumb.tildacdn.com%2Ftild3131-3637-4536-b833-373734383231%2F-%2Fresize%2F350x%2F-%2Fformat%2Fwebp%2F2019-03-18_19-17-05.png&width=768&dpr=4&quality=100&sign=b52ac8b1&sv=1)
<cubicBezier>
Adds a Bezier curve.
Attributes
Attribute | Description |
cp1="x:y" | Marker defining the curve bend. |
cp2="x:y" | Marker defining the curve bend. |
stroke-style="solid" | Style of the Bezier curve. The styles of the Bezier curve are similar to the line styles. |
begin="x:y" | The beginning of the Bezier curve, where x and y is the position of the starting point in the coordinate system. |
end="x:y" | The end of the Bezier curve, where x and y is the position of the starting point in the coordinate system. |
id="{name}" | Unique ID. |
fill-style="none" | Fill style. In this case, this attribute does not make sense, because the line is always smooth. |
stroke-width="6″ | The width of the Bezier curve. |
stroke="#ff000000″ | Bezier curve fills color. |
fill="#ff000000″ | Bezier curve color. |
Example:
![](https://help.trikset.com/~gitbook/image?url=https%3A%2F%2Fthumb.tildacdn.com%2Ftild3039-3336-4136-b962-353831373133%2F-%2Fresize%2F459x%2F-%2Fformat%2Fwebp%2F2019-03-18_19-44-30.png&width=768&dpr=4&quality=100&sign=6e05b569&sv=1)
<rectangle>
Adds a rectangle.
Attributes
Attribute | Description |
stroke-style="solid" | Style of the rectangle. The styles of the rectangle are similar to the line styles. |
begin="x:y" | The beginning of the rectangle, where x and y is the position of the starting point in the coordinate system. |
end="x:y" | The end of the rectangle, where x and y is the position of the starting point in the coordinate system. |
id="{name}" | Unique ID. |
fill-style="none" | Fill style. The default value is "none". The filled rectangle should be set to "solid". |
fill="#ff000000″ | Border color. |
stroke-width="6" | Border width. |
stroke="#ff000000″ | Fill color. |
Example:
![](https://help.trikset.com/~gitbook/image?url=https%3A%2F%2Fthumb.tildacdn.com%2Ftild3435-3234-4464-a232-653365343039%2F-%2Fresize%2F363x%2F-%2Fformat%2Fwebp%2F2019-03-18_19-50-54.png&width=768&dpr=4&quality=100&sign=defa1a83&sv=1)
<ellipse>
Adds an ellipse.
Attributes
Attribute | Description |
stroke-style="solid" | Style of the ellipse. The styles of the rectangle are similar to the line styles. |
begin="x:y" | The beginning of the ellipse, where x and y is the position of the starting point in the coordinate system. |
end="x:y" | The end of the ellipse, where x and y is the position of the starting point in the coordinate system. |
id="{name}" | Unique ID. |
fill-style="none" | Fill style. The default value is "none". The filled ellipse should be set to "solid". |
stroke-width="6″ | Border width. |
fill="#ff000000″ | Border color. |
stroke="#ff000000″ | Fill color. |
Example:
![](https://help.trikset.com/~gitbook/image?url=https%3A%2F%2Fthumb.tildacdn.com%2Ftild3261-3339-4333-b639-663432303630%2F-%2Fresize%2F402x%2F-%2Fformat%2Fwebp%2F2019-03-18_19-54-16.png&width=768&dpr=4&quality=100&sign=5ac6bf0a&sv=1)
<stylus>
Defines a stylus for drawing.
Attributes
Attribute | Description |
stroke-style="solid" | Style of the stylus. The styles of the stylus are similar to the line styles. |
id="{name}" | Unique ID. |
fill-style="none" | Fill style. In this case, this attribute does not make sense, because shapes drawn with a stylus are always homogeneous. |
stroke-width="6″ | Stilus width. |
fill="#ff000000″ | Stylus color. |
stroke="#ff000000″ | Fill color. |
Example:
![](https://help.trikset.com/~gitbook/image?url=https%3A%2F%2Fthumb.tildacdn.com%2Ftild3731-3835-4431-a632-623366313137%2F-%2Fresize%2F214x%2F-%2Fformat%2Fwebp%2F2019-03-18_20-05-28.png&width=768&dpr=4&quality=100&sign=5c114f37&sv=1)
<stylusLine>
Allows you to draw arbitrary shapes using the stylus. This block of code consists of many segments.
Attributes
Attribute | Description |
stroke-style="solid" | Shape style. The styles of the shape are similar to the line styles. |
id="{name}" | Unique ID. |
fill-style="none" | Fill style. In this case, this attribute does not make sense, because shapes drawn with a stylus are always homogeneous. |
stroke-width="6″ | Stilus width. |
fill="#ff000000″ | Stylus color. |
stroke="#ff000000″ | Fill color. |
Example:
<region>
Allows you to add regions to the scene. There are 2 types of regions:
rectangle
ellipse
Attributes
Attribute | Description |
filled="true" | Fill. The default value is true. |
type="rectangle" | Region type. |
height="300″ | The height of the region (in the case of an ellipse, this is the height of the rectangle that describes the ellipse). |
width="300″ | The width of the region (in the case of an ellipse, this is the width of the rectangle that describes the ellipse). |
text="Finish" | The text will be displayed in TRIK Studio. |
textX="0″ | The position is of the text relative to the lower-left corner along the X-axis. |
textY="0″ | The position is of the text relative to the lower-left corner along the Y-axis. |
x="1300″ | The position of the beginning of the region (upper left corner) along the X-axis (in the case of an ellipse, this is the coordinate along the X-axis of the upper left corner of the rectangle describing the ellipse). |
y="-200″ | The position of the beginning of the region (upper left corner) along the Y-axis (in the case of an ellipse, this is the coordinate along the Y-axis of the upper left corner of the rectangle describing the ellipse). |
visible="false" | Visibility in TRIK Studio. |
id="finish" | Unique ID. |
color="#ff0000″ | Fill and borders color. |
Example:
![](https://help.trikset.com/~gitbook/image?url=https%3A%2F%2Fthumb.tildacdn.com%2Ftild3334-6334-4534-b539-356262353336%2F-%2Fresize%2F360x%2F-%2Fformat%2Fwebp%2F2019-04-01_14-23-44.png&width=768&dpr=4&quality=100&sign=79685399&sv=1)
2D model setup example
The "Barcode" task
You need to draw a barcode. The barcode consists of white and black lines of the same thickness. The black line specifies 1 in a binary number, and the white one 0. The first black line in the robot path is the first bit of the number.
The barcode lines order: 1001011011
.
World creation
In this task, the lines should be the same thickness and length. It’s very difficult to draw lines by hand using the Line or Stylus tool, so edit the lines manually:
1. Draw 10 lines on the scene.
![](https://help.trikset.com/~gitbook/image?url=https%3A%2F%2Fthumb.tildacdn.com%2Ftild3431-6663-4035-b566-393133623464%2F-%2Fresize%2F676x%2F-%2Fformat%2Fwebp%2Fimage26.png&width=768&dpr=4&quality=100&sign=8e6ea84f&sv=1)
2. Save the model of the world.
3. Open the resulting XML file in any convenient editor. Pay attention to the code block with the<line...>
tag.
4. For convenience, name each line black1-black5 and white1-white5. You can do this in the "id" attribute. Name the lines in the order shown above.
5. Specify the line thickness "50" in the stroke-width
attribute.
6. Assign the color to each line: #ff000000
is black, #ffffffff
is white. You can do this in the attribute fill
. Assign colors so that you get a barcode.
7. Set the position of each line in the begin
and end
attributes without gaps, so that you get a smooth barcode.
The result
![](https://help.trikset.com/~gitbook/image?url=https%3A%2F%2Fthumb.tildacdn.com%2Ftild3330-6466-4461-b262-373037613431%2F-%2Fresize%2F428x%2F-%2Fformat%2Fwebp%2Fimage24.png&width=768&dpr=4&quality=100&sign=c6b78ea3&sv=1)
Last updated