<?xml version='1.0' encoding='utf-8'?>
<root version="20190819">
    <world>
        <walls>
            <wall stroke-width="10" stroke="#ff000000" end="-150:150" begin="-150:0" stroke-style="none" fill="#ff000000" id="{04fc486f-4c61-48eb-87c1-46e0ccae595e}"/>
            <wall stroke-width="10" stroke="#ff000000" end="150:450" begin="0:450" stroke-style="none" fill="#ff000000" id="{49b40656-2128-43d8-b564-fc932957ffa4}"/>
            <wall stroke-width="10" stroke="#ff000000" end="750:0" begin="750:150" stroke-style="none" fill="#ff000000" id="{1b33a0ac-621a-4424-88cf-ade8dd87ee79}"/>
            <wall stroke-width="10" stroke="#ff000000" end="-150:0" begin="600:0" stroke-style="none" fill="#ff000000" id="{21d767e3-8ed2-4f52-956f-f0d55c4f5411}"/>
            <wall stroke-width="10" stroke="#ff000000" end="0:150" begin="-145:150" stroke-style="none" fill="#ff000000" id="{9ca4fbe8-2b13-4909-8429-d0797dbd7ae2}"/>
            <wall stroke-width="10" stroke="#ff000000" end="0:450" begin="0:150" stroke-style="none" fill="#ff000000" id="{0396abe5-2e75-4e21-a870-344f60ae6bf9}"/>
            <wall stroke-width="10" stroke="#ff000000" end="150:150" begin="300:150" stroke-style="none" fill="#ff000000" id="{253dbb5f-4655-4d5f-ac12-0bc2815f834e}"/>
            <wall stroke-width="10" stroke="#ff000000" end="600:450" begin="300:450" stroke-style="none" fill="#ff000000" id="{0af406e1-d6cb-4eaf-bc27-b83f092d38c7}"/>
            <wall stroke-width="10" stroke="#ff000000" end="150:450" begin="150:150" stroke-style="none" fill="#ff000000" id="{3c00f288-618f-4de1-a075-a3b592df366f}"/>
            <wall stroke-width="10" stroke="#ff000000" end="300:450" begin="300:150" stroke-style="none" fill="#ff000000" id="{acdb6560-8006-46e8-937e-6777fdfd4844}"/>
            <wall stroke-width="10" stroke="#ff000000" end="450:450" begin="450:150" stroke-style="none" fill="#ff000000" id="{6698382d-e324-43a8-9452-c7ce6d777320}"/>
            <wall stroke-width="10" stroke="#ff000000" end="600:450" begin="600:150" stroke-style="none" fill="#ff000000" id="{38b7bece-b956-4462-93f7-43d3ff97e8fa}"/>
            <wall stroke-width="10" stroke="#ff000000" end="750:150" begin="600:150" stroke-style="none" fill="#ff000000" id="{4aa9a82e-658b-411c-ba22-405db8c9cd83}"/>
            <wall stroke-width="10" stroke="#ff000000" end="800:0" begin="600:0" stroke-style="none" fill="#ff000000" id="{cf3bd70b-1fcf-4b65-a377-2bcd88eb98e9}"/>
        </walls>
        <skittles/>
        <balls/>
        <colorFields>
            <rectangle stroke-width="6" stroke="#ff000000" end="-125:25" begin="-75:125" stroke-style="solid" fill="#ff000000" id="{ad6f66cb-04ed-4d74-b2f9-2dd4f2e58fca}" fill-style="solid"/>
        </colorFields>
        <images/>
        <regions>
            <region type="rectangle" color="#008000" y="300" height="150" x="0" visible="true" width="150" id="wayzone4" filled="true"/>
            <region type="rectangle" color="#008000" y="0" height="150" x="450" visible="true" width="150" id="wayzone9" filled="true"/>
            <region type="rectangle" color="#008000" y="0" height="150" x="150" visible="true" width="150" id="wayzone5" filled="true"/>
            <region type="rectangle" color="#008000" y="150" height="150" x="300" visible="true" width="150" id="wayzone7" filled="true"/>
            <region type="rectangle" color="#008000" y="300" height="150" x="300" visible="true" width="150" id="wayzone8" filled="true"/>
            <region type="rectangle" color="#008000" y="0" height="150" x="300" visible="true" width="150" id="wayzone6" filled="true"/>
            <region type="rectangle" color="#008000" y="150" height="150" x="0" visible="true" width="150" id="wayzone3" filled="true"/>
            <region type="rectangle" color="#ff0000" text="Finish" y="0" height="150" x="-150" visible="true" width="100" id="finish" textY="0" textX="0" filled="true"/>
            <region type="rectangle" color="#0000ff" text="Start" y="50" height="50" x="-100" visible="true" width="50" id="start_zone" textY="0" textX="0" filled="true"/>
            <region type="rectangle" color="#008000" y="0" height="150" x="0" visible="true" width="150" id="wayzone2" filled="true"/>
            <region type="rectangle" color="#008000" y="0" height="150" x="-150" visible="true" width="150" id="wayzone1" filled="true"/>
            <region type="rectangle" color="#008000" y="300" height="150" x="450" visible="true" width="150" id="wayzone11" filled="true"/>
            <region type="rectangle" color="#008000" y="0" height="150" x="600" visible="true" width="150" id="wayzone12" filled="true"/>
            <region type="rectangle" color="#008000" y="150" height="150" x="450" visible="true" width="150" id="wayzone10" filled="true"/>
        </regions>
    </world>
    <robots>
        <robot position="-100.325:50.5109" direction="0.5" id="trikKitRobot">
            <sensors>
                <sensor type="kitBase::robotModel::robotParts::EncoderSensor" position="75:25" port="E1###input###M1$$$Е1###encoder1" direction="0"/>
                <sensor type="kitBase::robotModel::robotParts::EncoderSensor" position="75:25" port="E2###input###M2$$$Е2###encoder2" direction="0"/>
                <sensor type="kitBase::robotModel::robotParts::EncoderSensor" position="75:25" port="E3###input###M3$$$Е3###encoder3" direction="0"/>
                <sensor type="kitBase::robotModel::robotParts::EncoderSensor" position="75:25" port="E4###input###M4$$$Е4###encoder4" direction="0"/>
                <sensor type="kitBase::robotModel::robotParts::Motor" position="75:25" port="M4###output###М4###" direction="0"/>
                <sensor type="kitBase::robotModel::robotParts::Motor" position="75:25" port="M3###output###М3###" direction="0"/>
                <sensor type="trik::robotModel::parts::TrikInfraredSensor" position="25:25" port="A1###input###А1###sensorA1" direction="90"/>
                <sensor type="trik::robotModel::parts::TrikInfraredSensor" position="25:25" port="A2###input###А2###sensorA2" direction="0"/>
                <sensor type="trik::robotModel::parts::TrikLightSensor" position="50:25" port="A5###input###А5###sensorA5" direction="0"/>
            </sensors>
            <startPosition y="76.5109" x="-76.3247" direction="0.529144" id="{40525568-044e-48db-bf48-51d2df1e1287}"/>
            <wheels right="M3###output###М3###" left="M4###output###М4###"/>
        </robot>
    </robots>
    <settings realisticPhysics="false" realisticSensors="false" realisticMotors="false"/>
    <constraints>
        <timelimit value="130000"/>
        <!-- Провека, что нет датчиков, кроме двух датчиков расстояния и одного датчика освещенности-->
        <constraint checkOnce="true" failMessage="У робота не должно быть датчиков, кроме двух датчиков расстояния и одного датчика освещенности">
            <conditions glue="and">
                <equals>
                    <typeOf objectId="robot1.A3"/>
                    <string value="undefined"/>
                </equals>
                <equals>
                    <typeOf objectId="robot1.A4"/>
                    <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>
        <!-- Проверка, что на порт А1 и А2 установлены датчики расстояния, на порт А5 установлен датчик освещенности -->
        <constraint checkOnce="true" failMessage="У робота должены быть установлены датчики расстояния на портах А1 и А2 и датчик освещенности на порту А5">
            <conditions glue="and">
                <equals>
                    <typeOf objectId="robot1.A1"/>
                    <string value="twoDModel::robotModel::parts::RangeSensor"/>
                </equals>
                <equals>
                    <typeOf objectId="robot1.A2"/>
                    <string value="twoDModel::robotModel::parts::RangeSensor"/>
                </equals>
                <equals>
                    <typeOf objectId="robot1.A5"/>
                    <string value="trik::robotModel::twoD::parts::TwoDLightSensor"/>
                </equals>
            </conditions>
        </constraint>
        <!-- Зональное ограничение на начало езды. Проверяется один раз в начале программы-->
        <constraint checkOnce="true" failMessage="Робот должен находиться перед черной меткой перед стартом!">
            <inside regionId="start_zone" objectId="robot1"/>
        </constraint>
        <!-- Событие, которое выдает ошибку, если робот не тронулся с места в первую секунду -->
        <event settedUpInitially="true" id="Waiting for going forward too long">
            <conditions glue="and">
                <timer forceDropOnTimeout="true" timeout="1000"/>
                <settedUp id="We are alive, first move"/>
            </conditions>
            <trigger>
                <fail message="Робот так и не поехал в первую секунду"/>
            </trigger>
        </event>
        <!-- Событие, которое говорит о том, что робот начал двигаться. Мощность на одном из моторов больше 0. Запускается цепочка проверок -->
        <event settedUpInitially="true" id="We are alive, first move">
            <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="check1"/>
            </triggers>
        </event>
        <!-- Цепочка проверок, что робот едет по правильной траектории -->
        <event id="check1">
            <condition>
                <inside regionId="wayzone2" objectId="robot1"/>
            </condition>
            <trigger>
                <setUp id="check2"/>
            </trigger>
        </event>
        <event id="check2">
            <condition>
                <inside regionId="wayzone4" objectId="robot1"/>
            </condition>
            <trigger>
                <setUp id="check3"/>
            </trigger>
        </event>
        <event id="check3">
            <condition>
                <inside regionId="wayzone2" objectId="robot1"/>
            </condition>
            <trigger>
                <setUp id="check4"/>
            </trigger>
        </event>
        <event id="check4">
            <condition>
                <inside regionId="wayzone6" objectId="robot1"/>
            </condition>
            <trigger>
                <setUp id="check5"/>
            </trigger>
        </event>
        <event id="check5">
            <condition>
                <inside regionId="wayzone8" objectId="robot1"/>
            </condition>
            <trigger>
                <setUp id="check6"/>
            </trigger>
        </event>
        <event id="check6">
            <condition>
                <inside regionId="wayzone9" objectId="robot1"/>
            </condition>
            <trigger>
                <setUp id="check7"/>
            </trigger>
        </event>
        <event id="check7">
            <condition>
                <inside regionId="wayzone11" objectId="robot1"/>
            </condition>
            <trigger>
                <setUp id="check8"/>
            </trigger>
        </event>
        <event id="check8">
            <condition>
                <inside regionId="wayzone9" objectId="robot1"/>
            </condition>
            <trigger>
                <setUp id="check9"/>
            </trigger>
        </event>
        <event id="check9">
            <condition>
                <inside regionId="wayzone12" objectId="robot1"/>
            </condition>
            <trigger>
                <setUp id="black check"/>
            </trigger>
        </event>
        <!-- Событие, проверяющее, что робот увидел черную метку -->
        <event id="black check">
            <condition>
                <greater>
                    <objectState object="robot1.A5.value"/>
                    <int value="67"/>
                </greater>
            </condition>
            <triggers>
                <setUp id="newway1"/>
                <setUp id="Wrong way"/>
            </triggers>
        </event>
        <!-- Цепочка проверок нового пути -->
        <event id="newway1">
            <condition>
                <inside regionId="wayzone2" objectId="robot1"/>
            </condition>
            <trigger>
                <setUp id="newway2"/>
            </trigger>
        </event>
        <event id="newway2">
            <condition>
                <inside regionId="wayzone12" objectId="robot1"/>
            </condition>
            <trigger>
                <setUp id="newway3"/>
            </trigger>
        </event>
        <event id="newway3">
            <condition>
                <inside regionId="wayzone5" objectId="robot1"/>
            </condition>
            <trigger>
                <setUp id="finish checker"/>
            </trigger>
        </event>
        <!-- События, которые при повторном пути робота, 
		без датчиков, проверяют, чтобы робот проезжал только по нужной траектории -->
        <!-- Событие, оповещающее что робот заехал в недопустимую зону -->
        <event settedUpInitially="false" id="Wrong way">
            <conditions glue="or">
                <inside regionId="wayzone3" objectId="robot1"/>
                <inside regionId="wayzone7" objectId="robot1"/>
                <inside regionId="wayzone10" objectId="robot1"/>
            </conditions>
            <trigger>
                <fail message="Робот едет в неправильном направлении, посмотрите на условие задачи внимательнее."/>
            </trigger>
        </event>
        <!-- Событие, оповещающее об успешном выполнении программы -->
        <event id="finish checker">
            <condition>
                <inside regionId="finish" objectId="robot1"/>
            </condition>
            <trigger>
                <success/>
            </trigger>
        </event>
    </constraints>
</root>
