---
# System prepended metadata

title: Crossroads Navigating - Report II

---

[[_TOC_]]

---

# Crossroads Navigating - Report II

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

## Introduction
From the basis of [last report](https://gitlab.kuleuven.be/rob-ecs/robotics-2022/-/blob/main/Reports/Report-I/Crossroad_scenario/Crossroad_scenario.md), we extend our knowledge graph with extra relations and properties, and describe how to answer the query by traversing the graph in details.

## Robot Task

Our robot in this situation has only one purpose - pass the crossroad efficiently and legally. 

## Query

So the main query to be answered is **"How long can the robot pass the Crossroad?"** The enter and exit are given by the higher level navigation system as hyperparameters. To answer this query, however, requires sub-queries to be answered and they are listed below:

- **Query 1**: What kinds of perceptions do I need when I am crossing a crossroad?
- **Query 2**: What kinds of motion do I need if I am at a crossroad and there are cars incoming on the right?

## Graph Traversal

### Query 1 Traversal

1. The trigger is the event that a robot is  .The relation **Robot_In_Crossroad** could be a _starting_ node to do reasoning about the graph. It can be the output of the algorithm that continuously detecting whether the robot is approaching a crossroad when the robot is driving along the road. 
2. Once it gets the trigger, the robot should use the crossroad ID retrieved from the relation **Robot_In_Crossroad** and then it put a _query_: which traffic rules should be followed in this specific crossroad with ID1234? 
3. To find out the answer of the above question, the robot needs to traverse the graph to find out all **Crossroad_Traffic_Rule** relations which have an argument **crossroad** with ID1234, and then retrieves the value of property **traffic_rule** of each relation.
4. For each traffic rule it gets, the robot knows that there must be an encoded perception strategy linked to each rule, indicating what kinds of perception tasks it needs to do. For each perception strategy, the robot will look at the argument **robot_perception** to get the list of needed perceptions.
There are two possible rules in this context. 
    - In the case of traffic rule being traffic light control, the robot also needs to find out which specific traffic light controls the robot from relation **Traffic_Light_Presence_Control**. According to a **Traffic_Light_Control_Perception_Strategy**, the perception task of the robot is then **Traffic_Light_Detection** (to observe the state of the traffic light) and **Stop_Lines_Detection** (to know where to stop in case the light is red).
    - If the traffic rule is *Priority_to_Right*, based on the **Priority_To_Right_Perception_Strategy**, the robot should do perception task **Car_Perception** (to detect whether there are cars incoming from the right road) and **Blinker_Detection** (to detect the intension of the incoming cars).
5. After having a list of perception tasks, the robot will need to look at its relation **Robot_Perception_System** to see if it is able to do all the perception tasks in the list. If yes, then the robot starts executing all the tasks. If not, then the robot starts the tasks that it is capable of doing, and at the same time raises warning and seeks other alternatives (which can be encoded as exceptions in the future).


### Query 2 Traversal

1. The robot gets a signal from the navigation system and CV algorithms and the signal represents that the robot is now performing tasks about passing the current crossroad.
2. The query starts at the **Current_Motion_Plan**. From there, the robot knows the relations that needs to be traversed to find the answer of the query. And the following order is:
    - The robot start by checking the **Crossroad_Traffic_Rule**, in this case, we assume that it tells the robot and the current crossroad is under *Priority_to_Right*.
    - Then it finds out a template basic motion plan from **Robot_Motion/Robot_Base_Motion_in_Cross** about the general path it needs to follow.
    - The next step is to analysis the complex situation in crossroad. First, our robot looks at **Car_Perception** to describe the geometric and motion information of other cars from the right side.
    - Second, it checks **Car_Intention_Prediction**. This relation describe the intention and predict the future moves of the right incoming cars.
    - Third, it checks **Stop_Lines_Detection**. The stop lines may or may not present in the current crossroad.
    - **Suggested_Stop_Position** is now can be infereced from the above information. If stop lines are present, it is easier to inferece, but if it doesn't, a complex CV algorithm could be performed to inferece. This relation describes the safe plots for temporary waiting.
    - Now combining all informations, **Robot_Advanced_Motion_in_Cross** is the answer we will reach, which tactically describe the actions to be taken. The specific action varies depends on the result of perception and dectection. For example, if the right coming car has the intention to do a right turn, then we do not need to give it a hard priority, it could vary depends on its speed, our speed, relative position and human morality setting (we let it go first anyway)
3. The robot executes the suggested action.
4. The process ends, and only start when robot is passing through the current crossroad.

The process is performed after Query 1. And they are sequential queries to be answered to achieve the final task: Robot pass through the crossroad.


Many hyperparameters can be configured before the process. Human morality like the situation described above can be a example. Also, if one right-coming car pass by our robot and the next one is reacting slowly, leaving our robot a safe break, then we say: OK we can give the robot tolerance. We let our robot break the priority and start moving if the car on the right side does not start accelerating/reacting for 3 seconds while our robot is waiting. Things like this 3 seconds *waiting_time_limit* can be the hyperparameters.

## Further consideration: higher order relation/contraints:

**Traffic_Light_Control_Perception_Strategy** and **Priority_To_Right_Perception_Strategy** should just be a _minimum_ perception requirements that the robot needs to comply the current traffic rules. There should be connections to (or compositions of) other kinds of perception requirements under different traffic situations. Both of the perception strategy above could be subclasses of the general **Traffic_Rule_Perception_Strategy**. However, for a car driving on the road, there are more traffic rules for it to follow. For example, whenever the robot hears sirens, in addition to do car detection focused on the crossroad situation in front, it needs to do backwards detection, in order to find out if there are special vehicles coming behind.

## Knowledge graph

### Entities
#### Robot
```json
{
  "@type": "https://example.org/robot",
  "@id": "robot_A",
  "role_in_traffic": "car"
}
```


#### Traffic_Light
```json
{
  "@type": "https://example.org/traffic_light",
  "@id": "traffic_light_A",
  "Target_of_Traffic_Light": "car"
}
```


#### Traffic_Rule
```json
{
  "@type": "https://example.org/traffic_rule",
  "@id": "Priority_to_Right"
}
{
  "@type": "https://example.org/traffic_rule",
  "@id": "Traffic_Light_Control"
}
{
  "@type": "https://example.org/traffic_rule",
  "@id": "Emergency_Rule"
}
```

#### Crossroad
```json
{
  "@type": "https://example.org/crossroad",
  "@id": "Crossroad_A"
}
```

#### LandMark
The reason why geometric signature is property here is because a ground mark is not expected to move. It can be removed, then the corresponding entity will be deleted.
```json
{
  "@type": "https://example.org/LandMark/stopline",
  "@id": "Stop_Line_1",
  "geometric_xy": "(10,10)"
}
```

#### Motion_Strategy
```json
{
 "@type" : "https://example.org/robot/Motion_Strategy",
  "@id": "Motion_Strategy",
  "traversals": ["Relation1" , "Relation2", ...]
}
```

### Relations

#### Robot_In_Crossroad

```json
{
  "@type": "https://example.org/In_Crossroad",
  "@id": "in_crossroad_A",
  "motion": "enter",
  "Time Limit(second)" : 300, 
  "arguments": {
      "robot": {"@id": "robot_A"},
      "crossroad": {"@id": "crossroad_A"}
  }
}
```

#### Crossroad_Traffic_Rule
```json
{
  "@type": "https://example.org/crossroad_traffic_rule",
  "@id": "crossroad_traffic_rule_A",
  "traffic_rule": {"@id": "Priority_to_Right"},
  "arguments": {
      "crossroad": {"@id": "crossroad_A"},
      "traffic_light_presence": 
          {"@id": "traffic_light_Presence_A"}
  }
}
```

#### Traffic_Light_Presence_Control
```json
{
  "@type": "https://example.org/traffic_light_Presence",
  "@id": "traffic_light_Presence_A",
  "State": "Presence_And_HasControl",
  "arguments": {
      "traffic_light": {"@id": "traffic_light_A"},
      "crossroad": {"@id": "crossroad_A"}
  }
}
```

#### Traffic_Light_Control_Perception_Strategy
```json
{
  "@type": "https://example.org/adjustment",
  "@id": "traffic_rule_Traffic_Light",
  "arguments": {
      "traffic_rule": {"@id": "Traffic_Light_Control"},
      "robot_perception": [{"@id": "Traffic_Light_Detection"},
                           {"@id": "Stop_Lines_Detection"}]
  }
}
```

#### Priority_To_Right_Perception_Strategy
```json
{
  "@type": "https://example.org/adjustment",
  "@id": "traffic_rule_Priority_Right",
  "arguments": {
      "traffic_rule": {"@id": "Priority_to_Right"},
      "robot_perception": [{"@id": "Car_Detection_A"}]
  }
}

```


#### Traffic_Light_Detection
```json
{
  "@type": "https://example.org/Traffic_Light_Detection",
  "@id": "Traffic_Light_Detection",
    
  "state_of_traffic_light": "red",
  
  "arguments": {
      "robot_in_crossroad": {"@id": "robot_in_crossroad_A"},
  }
}
```

#### Stop_Lines_Detection
```json
{
  "@type": "https://example.org/Stop_Lines_Detection",
  "@id": "Stop_Lines_Detection",
    
  "list_of_StopLine_positions": [{ "@id": "Stop_Line_1",
                                  "@type": "https://example.org/LandMark/stopline",
                                  "geometric_xy_value": "(10,10)"}]
  
  "arguments": {
      "robot_in_crossroad": {"@id": "robot_in_crossroad_A"},
      "on_the_right": {"@id": "on_the_right_A"}
  }
}

```

#### Car_Perception
```json
{
  "@type": "https://example.org/Car_Perception",
  "@id": "Car_Perception_A",
  
  "Identified_Cars": [{"@id": "car1", "position": "position1", "speed": "speed1"}],
  
  "arguments": {
      "on_the_right": {"@id": "on_the_right_A"}
  }
}
```

#### Blinker_Detection
```json
{
  "@type": "https://example.org/Blinker_Perception",
  "@id": "Blinker_Perception",
  
  "Light_State": ["left-light-on"],
  
  "arguments": {
      "car_perception": {"@id": "Car_Perception_A"}
  }
}
```

#### Car_Intention_Prediction
```json
{
  "@type": "https://example.org/Blinker_Perception",
  "@id": "Car_Intention_Prediction",
  
  "intention": "turn_left",
  
  "arguments": {
      "Blinker_Detection": {"@id": "Blinker_Perception"}
  }
}
```

#### Suggested_Stop_Position
```json
{
  "@type": "https://example.org/Suggested_Stop_Position",
  "@id": "Suggested_Stop_Position",
  
  "ideal_area" : ["Area1"],
  
  "arguments": {
      "Robot_Perception_System": {"@id " : "Robot_Perception_System"}
  }
}
```

#### Robot_Motion
```json
{
  "@type": "https://example.org/Robot_Motion/Robot_Base_Motion_in_Cross",
  "@id": "Robot_Base_Motion_in_Cross",
  
  "Suggested Time Cost(s)": 600,   
    
  "arguments": {
      "Robot" : {"@id" : "Robot_A"},
      "crossroad": {"@id": "crossroad_A"}
  }
}
```
```json
{
  "@type": "https://example.org/Robot_Motion/Robot_Advanced_Motion_in_Cross",
  "@id": "Robot_Advanced_Motion_in_Cross",
  
  "Suggested Time Cost(s)": 600,  
  "Expected_React_Time(s)": 3,
  "Max Waiting time(s)" : 20,
    
  "arguments": {
      "Robot" : {"@id" : "Robot_A"},
      "Suggested_Stop_Position": {"@id" : "Suggested_Stop_Position"},
      "traffic_rule": {"@id": "Priority_to_Right"},
      "Stop_Lines_Detection": {"@id" : "Stop_Lines_Detection"}
      "Base_Action": {"@id": "Robot_Base_Motion_in_Cross"}
  }
}
```


#### Robot_Perception_System
```json
{
  "@type": "https://example.org/Robot_Perception_System",
  "@id": "Robot_Perception_System",

  "robot": {"@id": "robot_A"},    
  "arguments": {
      "perception_systems" : [{"@id" : "Car_Perception"},
                              {"@id" : "Traffic_Light_Detection"},
                              {"@id" : "Stop_Lines_Detection"},                                   {"@id" : "Car_Intention_Prediction"}]
  }
}
```

#### Current_Motion_Plan
```json
{
  "@type": "https://example.org/Current_Motion_Plan",
  "@id": "Current_Motion_Plan",
    
  "Plan" : "Motion_Strategy"
    
  "arguments": {
      "Robot": {"@id": "Robot_A"},
      "Crossroad": {"@id": "Crossroad_A"}

  }
}
```