LogoLogo
TRIK StudioTRIKLego EV3Lego NXT
English
English
  • TRIK help
  • TRIK Studio
    • About TRIK Studio
      • How to find out the version of TRIK Studio
    • Getting started and creating a project
    • TRIK Studio interface
      • TRIK Studio main menu
      • Working with graphs
      • How to open robot settings
      • How to change TRIK Studio interface language
    • TRIK Studio settings
    • 2D model
      • 2D model tuning
      • Adding restrictions to the 2D Model
        • Restrictions setting examples
    • Visual programming
      • Adding and removing blocks
      • Common blocks
      • Links between blocks
      • Syntax of expressions in the blocks
        • TRIK Studio language types
          • Array
        • TRIK Studio language tokens
        • TRIK Studio language operators
        • Constants
        • Sensor variables
        • Built-in functions
      • Property editing
      • Subprograms
    • Textual programming
    • Exercises
    • External tools
      • PuTTY
      • WinSCP
    • TRIK Studio shortcuts
    • Antivirus conflicts
      • Avast antivirus blocks TRIK Studio. What to do?
  • TRIK Studio Junior
    • About TRIK Studio Junior
      • How to find out the version of TRIK Studio Junior
    • Getting started and creating a project in TRIK Studio Junior
    • TRIK Studio Junior interface
      • How do I replace the "Character movement" image?
    • TRIK Studio Junior settings
    • Visual programming in TRIK Studio Junior
      • Adding and removing blocks in TRIK Studio Junior
      • Blocks in TRIK Studio Junior
      • Links between blocks in TRIK Studio Junior
      • Syntax of expressions in the blocks in TRIK Studio Junior
      • Property editing in TRIK Studio Junior
      • Subprograms in TRIK Studio Junior
    • Exercises in TRIK Studio Junior
  • INTEGRATIONS
    • PyCharm
      • Running a 2D model in TRIK Studio from PyCharm
    • Sublime Text
      • Running a 2D model in TRIK Studio from Sublime Text
      • Uploading programs to several TRIK robots from Sublime Text
    • VSCode
      • Running a 2D model in TRIK Studio from VSCode
      • Uploading programs to several TRIK robots from VSCode
  • TRIK controller
    • About the TRIK controller
      • Screenshot of the TRIK controller screen
    • TRIK controller firmware
      • How to find out the firmware version of the TRIK controller?
    • TRIK controller menu
    • Connecting to the TRIK controller via Wi-Fi
      • Connecting the TRIK controller to a computer and smartphone
      • Connecting the TRIK controller to TRIK Studio
      • Interaction of TRIK controllers
        • An example of solving a problem on the interaction of two robots
    • Connecting to the TRIK controller using UART
    • Launching and uploading programs to the TRIK controller
    • Programming TRIK with the visual programming language
      • TRIK specific blocks
      • Sensory variables for the TRIK controller
    • TRIK controller programming in Python and JavaScript
      • Object «brick»
        • Class «accelerometer»
        • Class «battery»
        • Class «colorSensor»
        • Class «display»
        • Class «encoder»
        • Class «gyroscope»
        • Class «keys»
        • Class «led»
        • Class «lineSensor»
        • Class «motor»
        • Class «objectSensor»
        • Class «sensor»
      • Object «script»
      • Object «mailbox»
      • Object «gamepad»
      • Object «Threading»
      • Function getPhoto
      • Function include
    • TRIK controller web interface
    • Connecting devices to TRIK and working with them
      • Connecting and working with the video module
      • Testing devices connected to the TRIK controller
      • Configuring the operation of a USB camera with a TRIK controller
      • Capturing images with TRIK camera and using them in TRIK Studio
      • Working with battery and charger
  • LEGO EV3 Controller
    • About LEGO EV3
    • Connecting a LEGO EV3 Controller to TRIK Studio
    • LEGO EV3 specific blocks
    • Sensory Variables for the LEGO EV3 Controller
    • Launching and uploading programs to the LEGO EV3
  • LEGO NXT Controller
    • About LEGO NXT
    • LEGO NXT Controller Firmware
    • Connecting a LEGO NXT Controller to TRIK Studio
    • LEGO NXT specific blocks
    • Sensory Variables for the LEGO NXT Controller
    • LEGO NXT C Programming
    • Launching and uploading programs to the LEGO NXT
  • Quadcopter Geoscan Pioneer
    • About quadcopter Geoscan Pioneer
    • Geoscan Pioneer specific blocks
  • TRIK Gamepad
    • About TRIK Gamepad
      • TRIK Gamepad App
      • TRIK Gamepad Utility
    • Robot control from the remote control
  • Feedback
    • Actions in case of TRIK Studio or TRIK controller malfunction
    • Ask a Question
    • trikset.com
Powered by GitBook
On this page
  • 2D model coordinate system
  • An XML file creation
  • Editing an XML file
  • Tags
  • Attributes
  • Robots
  • <robots>...</robots>
  • <robot>...</robot>
  • <sensors>...</sensors>
  • <sensor/>
  • <startPosition/>
  • <wheels/>
  • Objects
  • <wall>
  • <skittle>
  • <ball>
  • <line>
  • <cubicBezier>
  • <rectangle>
  • <ellipse>
  • <stylus>
  • <stylusLine>
  • <region>
  • 2D model setup example
  • The "Barcode" task
  • World creation

Was this helpful?

Export as PDF
  1. TRIK Studio
  2. 2D model

2D model tuning

Previous2D modelNextAdding restrictions to the 2D Model

Last updated 4 years ago

Was this helpful?

Defines walls. Used as a container, has no attributes. In addition to creating a 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 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:

  1. Specify the location and file name to save.

Editing an XML file

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:

<walls> <!-- start (opening) tag -->
     <wall begin="200:-200" id="{a3ede76b-1d7e-4c72-9ed4-08d8ea9af4bf}" end="200:150"/>
</walls> <!-- end (closing) tag -->

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:

The simplest virtual model
<?xml version='1.0' encoding='utf-8'?>
<root>
    <world>
        <background/>
        <walls/>
        <skittles/>
        <balls/>
        <colorFields/>
        <images/>
        <regions/>
    </world>
    <robots>
        <robot direction="0" id="trikKitRobot" position="0:0">
            <sensors/>
            <startPosition direction="0" id="{name}" y="25" x="25"/>
            <wheels left="M4###output###М4###" right="M3###output###М3###"/>
        </robot>
    </robots>
</root>

Robots

The following tags are available for describing robots:

Tag

Description

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.

<robots>
     <robot id="trikKitRobot" position="0:0" direction="0">
</robots>

<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"

id="trikKitRobot"

Unique ID.

Example:

<robot id="trikKitRobot" position="0:0" direction="0">

<sensors>...</sensors>

Defines sensors on a robot. Used as a container, has no attributes.

<sensors>
     <sensor type="kitBase::robotModel::robotParts::Motor" direction="0" port="M4###output###JM4$$$D$$$4###" position="75:25"/>
</sensors>

<sensor/>

Sensors ports configuration.

Attributes

Attribute

Description

position="x:y"

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.

Sensor

Description

RangeSensor

Range sensor.

TouchSensor

Touch sensor.

Ev3Gyroscope

Gyroscope.

LightSensor

Light sensor.

ColorSensorGreen

Color sensor (green).

ColorSensorFull

Color sensor (detection).

ColorSensorBlue

Color sensor (blue).

ColorSensorRed

Color sensor (red).

ColorSensorPassive

Color sensor (passive).

Example:

<sensor position="75:25" direction="0" port="A1###input###А1###sensorA1"
type="trik::robotModel::parts::TrikInfraredSensor"/>

<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″

y="25″

Example:

<startPosition id="{7a326d25-82f4-4eb4-9b42-1e75576f35a4}" direction="0" x="25" y="25"/>

<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:

<wheels left="M4###output###М4###" right="M3###output###М3###"/>
<wheels left="B###output###В###" right="C###output###С###"/>

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"

end="x:y"

Example:

<wall id="{wall1}" begin="50:-50" end="250:-50"/>

<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:

<skittle rotation="0" id="{skittle1}" markerY="44" startRotation="0" x="220" y="44"
markerX="220"/>

<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:

<ball rotation="0" id="{ball1}" markerY="169" startRotation="0" x="-18" y="169" markerX="-18"/> 

<line>

Adds a line to the scene.

Attributes

Attribute

Description

begin="x:y"

end="x:y"

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:

  • solid — solid;

  • dot — dotted line;

  • dash — dash line;

  • dashdot — dash-dot;

  • dashdotdot — dash-dot line with two points.

stroke="#ff000000″

Line color.

Example:

<line stroke-width="6" fill-style="none" end="250:-50" id="{line1}" stroke-style="solid"
fill="#ff000000" stroke="#ff000000" begin="50:-50"/>

<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"

end="x:y"

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:

<cubicBezier id="{cubicBezier1}" fill-style="none" stroke-width="6" end="-106.577:134.894"
begin="-112.95:-192.25" fill="#ff000000" cp1="-142.95:-192.25" cp2="17.0502:-192.25"
stroke="#ff000000" stroke-style="solid"/>

<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"

end="x:y"

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:

<rectangle stroke-width="6" fill-style="none" end="344:511" id="{rectengle1}" 
stroke-style="solid" fill="#ff000000" stroke="#ff000000" begin="285:229"/>

<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"

end="x:y"

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:

<ellipse stroke-width="6" fill-style="none" end="-178:300" id="{ellipse1}" 
stroke-style="solid" fill="#ff000000" stroke="#ff000000" begin="-260:7"/>

<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:

<stylus stroke-width="6" fill-style="none" id="{stylus_name}" stroke-style="solid" 
fill="#ff000000" stroke="#ff000000">

<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:

<stylusLine stroke-width="6" fill-style="none" end="-334:259" id="{name1}" stroke-style="solid"
fill="#ff000000" stroke="#ff000000" begin="-334:260"/>
<stylusLine stroke-width="6" fill-style="none" end="-333:258" id="{name2}" stroke-style="solid"
fill="#ff000000" stroke="#ff000000" begin="-334:259"/>
<stylusLine stroke-width="6" fill-style="none" end="-333:254" id="{name3}" stroke-style="solid"
fill="#ff000000" stroke="#ff000000" begin="-333:258"/>

<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:

<regions>
            <region filled="true" type="rectangle" height="300" width="300" textX="0" 
text="Finish" textY="0" x="1300" y="-200" visible="true" id="Start" color="#ff0000"/>
</regions>

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.

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-widthattribute.

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 beginand endattributes without gaps, so that you get a smooth barcode.

The result

Switch to the mode.

Go to the .

Right-click on the scene and choose "Save world model..." in the context menu.

Open a saved XML file in a text editor. , for example.

Defines a robot on stage. Used as a container and must contain a element.

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 .

The position of the sensor, where x and y is the position of the center point of the square of the sensor in the .

The x-axis position in the .

The y-axis position in the .

The beginning of the wall, where x and y is the position of the starting point in the .

The end of the wall, where x and y is the position of the starting point in the .

The beginning of the line, where x and y is the position of the starting point in the .

At end of the line, where x and y is the position of the starting point in the .

The beginning of the Bezier curve, where x and y is the position of the starting point in the .

The end of the Bezier curve, where x and y is the position of the starting point in the .

The beginning of the rectangle, where x and y is the position of the starting point in the .

The end of the rectangle, where x and y is the position of the starting point in the .

The beginning of the ellipse, where x and y is the position of the starting point in the .

The end of the ellipse, where x and y is the position of the starting point in the .

2D model
Notepad++
robots
robot
robot
sensors
sensor
startPosition
wheels
coordinate system
coordinate system
coordinate system
coordinate system
wall
skittle
ball
line
cubicBezier
rectangle
ellipse
stylus
stylusLine
region
coordinate system
coordinate system
coordinate system
coordinate system
coordinate system
coordinate system
coordinate system
coordinate system
coordinate system
coordinate system
"Debug mode"
create
virtual world