<?xml version='1.0' encoding='utf-8'?>
<root version="20190819">
    <world>
        <walls/>
        <skittles/>
        <balls/>
        <colorFields/>
        <images/>
        <regions>
            <region id="wayzone" color="#008000" type="rectangle" width="2050" visible="true" filled="true" x="0" height="18" y="16"/>
            <region id="finish_zone" color="#ff0000" type="rectangle" width="50" visible="true" filled="true" x="2000" height="52" y="-1"/>      
            <region id="start_zone" color="#0000ff" type="rectangle" width="50" visible="true" filled="true" x="0" height="50" y="0"/>            
        </regions>
    </world>
    <robots>
        <robot id="trikKitRobot" direction="0" position="0:0">
            <sensors>
                <sensor type="kitBase::robotModel::robotParts::Motor" direction="0" port="M4###output###М4###" position="75:25"/>
                <sensor type="" direction="0" port="E1###input###M1$$$Е1###encoder1" position="0:0"/>
                <sensor type="kitBase::robotModel::robotParts::Motor" direction="0" port="M3###output###М3###" position="75:25"/>
                <sensor type="" direction="0" port="E2###input###M2$$$Е2###encoder2" position="0:0"/>
                <sensor type="kitBase::robotModel::robotParts::EncoderSensor" direction="0" port="E3###input###M3$$$Е3###encoder3" position="75:25"/>
                <sensor type="kitBase::robotModel::robotParts::EncoderSensor" direction="0" port="E4###input###M4$$$Е4###encoder4" position="75:25"/>
            </sensors>
            <startPosition id="{d8d7e64e-0f6f-46ed-93e0-8cef65157c57}" direction="0" x="25" y="25"/>
            <wheels right="M3###output###М3###" left="M4###output###М4###"/>
        </robot>
    </robots>
    <settings realisticSensors="false" realisticPhysics="false" realisticMotors="true"/>
    <constraints>
        <timelimit value="60000"/>
        <!-- Провека, что нет датчиков, кроме двух датчиков расстояния и одного датчика освещенности-->
        <constraint failMessage="У робота не должно быть датчиков, кроме двух датчиков расстояния и одного датчика освещенности" checkOnce="true">
            <conditions glue="and">
				<equals>
                    <typeOf objectId="robot1.A1"/>
                    <string value="undefined"/>
                </equals>
                <equals>
                    <typeOf objectId="robot1.A2"/>
                    <string value="undefined"/>
                </equals>
                <equals>
                    <typeOf objectId="robot1.A3"/>
                    <string value="undefined"/>
                </equals>
                <equals>
                    <typeOf objectId="robot1.A4"/>
                    <string value="undefined"/>
                </equals>
				<equals>
                    <typeOf objectId="robot1.A5"/>
                    <string value="undefined"/>
                </equals>
                <equals>
                    <typeOf objectId="robot1.A6"/>
                    <string value="undefined"/>
                </equals>
                <equals>
                    <typeOf objectId="robot1.D1"/>
                    <string value="undefined"/>
                </equals>
                <equals>
                    <typeOf objectId="robot1.D2"/>
                    <string value="undefined"/>
                </equals>
                <equals>
                    <typeOf objectId="robot1.F1"/>
                    <string value="undefined"/>
                </equals>
            </conditions>
        </constraint>
        <!-- Зональное ограничение на начало езды. Проверяется один раз в начале программы-->
        <constraint failMessage="Робот должен находиться в синем квадрате перед стартом!" checkOnce="true">
            <inside objectId="robot1" regionId="start_zone"/>
        </constraint>
		<!-- Робот находится в допустимой зоне-->
        <constraint failMessage="Робот покинул допустимую зону!">
            <inside objectId="robot1" regionId="wayzone"/>
        </constraint>
        <!-- Событие, которое выдает ошибку, если робот не тронулся с места в первую секунду -->
        <event id="Waiting for going forward too long" settedUpInitially="true">
            <conditions glue="and">
                <timer timeout="1000" forceDropOnTimeout="true"/>
                <settedUp id="We are alive, first move"/>
            </conditions>
            <trigger>
                <fail message="Робот так и не поехал в первую секунду"/>
            </trigger>
        </event>
        <!-- Событие, которое говорит о том, что робот начал двигаться. Мощность на одном из моторов больше 0. Запускается проверку на финиш -->
        <event id="We are alive, first move" settedUpInitially="true">
            <conditions glue="or">
                <notEquals>
                    <objectState object="robot1.M3.power"/>
                    <int value="0"/>
                </notEquals>
                <notEquals>
                    <objectState object="robot1.M4.power"/>
                    <int value="0"/>
                </notEquals>
            </conditions>
            <triggers>
                <setUp id="finish checker"/>
            </triggers>
        </event>
        <event id="finish checker">
            <condition>
                <inside objectId="robot1" regionId="finish_zone"/>
            </condition>
            <trigger>
                <success/>
            </trigger>
        </event>
    </constraints>
</root>
