---
# System prepended metadata

title: Crossroads Navigating - Report III

---

[[_TOC_]]

---

# Crossroads Navigating - Report III

## Authors
* Tianjian Song (r0815584)
* Zhongxi Li (r0866180)


## Introduction
This report is built on basis of our previous knowledge base in Report II.

## Meta Model

### Priority_to_the_Right Constraint

The very first thing robot needs to decide when it comes to a crossroad is the traffic rule it needs to comply. To do that, prior Computer Vision algorithm need to be executed to check the presence of special landmark, special traffic sign and traffic lights. Only in the case that none of these are presented, the robot complies the Priority_to_the_Right(PR) rule and start looking the correponding template. Thus we requires all the lists of these things to have 0 length/count.

After that, robot needs to activate the corresponding perception system to support the PR rule like **Car_Perception** and **Blinker_Detection**.

#### relation crossroad observation

```json
{
    "@id": "ex:crossroad_observation1",
    "@type": "ex:crossroad_observation",

    "ex:crossroad": {"@id": "ex:crossroad1"},
    "ex:observation_results": [
        {
            "@id": "traffic:stop_sign1",
            "@type": "traffic:stop_sign",
            "ex:crossroad": {"@id": "ex:crossroad1"},
        },
        {
            "@id": "traffic:traffic_light1",
            "@type": "traffic:traffic_light",
            "ex:crossroad": {"@id": "ex:crossroad1"},
        }
    ] 
}
```
After the observation results are grounded, we can use the shape for validation. The shape of the relation should ensure that there is no stop sign or traffic light observed in the current crossroad.
#### SHACL constraints

```
ex:priority_to_right_shape a sh:NodeShape;
    sh:targetClass ex:crossroad_observation;
    sh:not [
        sh:or (
            [
                ex:has_stop_sign
            ]
            [
                ex:has_traffic_light
            ])
    ].


ex:has_stop_sign a sh:PropertyShape;
    sh:path ex:observation_results;
    sh:hasValue traffic:stop_sign.
    
ex:has_traffic_light a sh:PropertyShape;
    sh:path ex:observation_results;
    sh:hasValue traffic:traffic_light.
```



### Stop Position Constraint

After our robot decide that it needs to comply PR rule, the corresponding perception system should already be active because of the previous constraints we set.  

There is a ideal stop found by robot's algorithm system. However if a stop line (a landmard) is presented, robot automatically follow it over the others.

#### Modified Knowledge Base

Add one entities type called Stop_Position indicate the stopping position for the robot to pick.

Add two relations called: CV_Suggested_Stop_Position and Stop_Line_Specified_Position indicate the two stop positions from two types reasons. Each provide a unique solution.

```json
{
  "@type": "https://example.org/stop_position",
  "@id": "area1"
}
{
  "@type": "https://example.org/stop_position",
  "@id": "area2"
}
{
  "@type": "https://example.org/CV_Suggested_Stop_Position",
  "@id": "CV_Suggested_Stop_Position",
  
  "ideal_area" : {"@id": "area1"},
  
  "arguments": {
      "Robot_Perception_System": {"@id " : "Robot_Perception_System"}
  }
}
{
  "@type": "https://example.org/Stop_Line_Specified_Position",
  "@id": "Stop_Line_Specified_Position",
  
  "ideal_area" : {"@id": "area2"},
  
  "arguments": {
      "Robot_Perception_System": {"@id " : "Robot_Perception_System"}
  }
}

```


#### SHACL
```
ex: Robot_Motion_Path a sh:NodeShape;
    sh:targetClass ex: Robot_Motion
    sh:property [
        sh:path ex:destination
        sh:class ex:Suggested_Stop_Position
        sh:minCount 1
        sh:maxCount 1
    ];
    
ex: Suggested_Stop_Position_Choice a sh:NodeShape;
    sh:targetClass ex: Suggested_Stop_Position
    sh:property [
        sh:path ex:ideal_stop_position
        sh:class ex:stop_position
        sh:minCount 1;
        sh:maxCount 1;
        sh:in (ex:Stop_Line_Specified_Position:ideal_area, ex:CV_Suggested_Stop_Position:ideal_area,
        sh:lessThanOrEquals  ex:CV_Suggested_Stop_Position:ideal_area
        sh:lessThanOrEquals  ex:Stop_Line_Specified_Position:ideal_area
    ];
```

### Stop Condition Constraint

Robot only waits under PR rule if there is a right incoming car and its intention is moving forward or making a left turn.

#### SHACL
```
ex: Priority_To_Right_Motion_Strategy_Wait a sh:NodeShape;
    sh:targetClass ex: Priority_To_Right_Motion_Strategy
    sh:property [
        sh:path ex:traffic_rule
        sh:class ex:Traffic_Rule
        sh:minCount 1
        sh:maxCount 1
        sh:equals ex:Traffic_Rule:Priority_to_Right
    ];
    sh:property [
        sh:path ex:Car_Perception:Identified_Cars
        sh:minLength 1
    ];
    sh:property [
        sh:path ex:Car_Intention_Prediction
        sh:or (
            sh:path ex:Car_Perception:Identified_Cars:intention
            [
                sh:hasValue ex:Turn_Left
            ]
            [
                sh:hasValue ex:Move_Forward
            ]
        )
    ];
```

