|
2 | 2 |
|
3 | 3 | This repository contains code for the robot controller, it should be added as a |
4 | 4 | submodule to the [main Webots project |
5 | | -repository](https://github.com/IDP-L211/simulation). |
| 5 | +repository](https://github.com/IDP-L211/simulation). Documentation can be found |
| 6 | +at https://idp-l211.github.io/controllers/. |
| 7 | + |
| 8 | +The robot chooses the closest accessible target to drive to, or perform a scan |
| 9 | +if no such target is available. When the robot reaches a target, it will check |
| 10 | +the colour using two LDRs. If the colour is wrong, the robot will send the |
| 11 | +confirmed position to the other robot. |
6 | 12 |
|
7 | 13 | <p align="center"> |
8 | 14 | <img alt="Overall Flowchart" src="docs/figs/overall_flow.svg" width="300"> |
9 | 15 | </p> |
10 | 16 |
|
11 | | -The class diagram is shown below |
| 17 | +Custom classes for devices are created by inheriting from classes in Webots C |
| 18 | +interface, which are then composed together in a robot class. Various |
| 19 | +subroutines are also handle by child classes (e.g. `TargetingHandler`). The |
| 20 | +class diagram is shown below |
12 | 21 |  |
13 | 22 |
|
14 | | -## Subroutines |
| 23 | +## Algorithms and Subroutines |
| 24 | + |
| 25 | +DBSCAN clustering algorithm is used in the scanning subroutine to calculate |
| 26 | +block positions from filtered data from IR sensor and GPS. This means the |
| 27 | +effect of noise is minimised, and the target positions are relatively accurate. |
| 28 | + |
| 29 | +The targeting algorithm picks the closest block of a valid class that has a |
| 30 | +clear path to it. A clear path is determined by creating a rectangle from the |
| 31 | +robot to the target and checking no other object is inside it. It will start |
| 32 | +the check from the closest potential target and continue until a valid target |
| 33 | +is found. When driving to the selected target, an active collision avoidance |
| 34 | +algorithm (with a similar working principle) diverts the robot to a different |
| 35 | +target if necessary. |
| 36 | + |
| 37 | +A passive collision avoidance algorithm is used when the robot is not moving |
| 38 | +towards a block. It calculates the distance to each known object and then does |
| 39 | +a weighted sum of the current target angle and the angles to avoid each object |
| 40 | +(i.e. right angle away from it). A recursive component is added to combine |
| 41 | +small obstructions into larger ones to avoid clusters of blocks. |
| 42 | + |
| 43 | +When the robot is far from the target, proportional combined with open loop |
| 44 | +control is used to achieve a velocity. When nearby, a proportional distance |
| 45 | +controller is used. A non-linear controller which uses both error and |
| 46 | +derivative are used to control the angle. The two controllers produced forward |
| 47 | +and rotational velocities respectively, which were combined to give the overall |
| 48 | +motor velocities. |
15 | 49 |
|
16 | 50 | <p align="center"> |
17 | 51 | <img alt="Motion" src="docs/figs/overall_flow.svg" width="250"> |
18 | 52 | <img alt="Scanning" src="docs/figs/scan_flow.svg" width="200"> |
19 | 53 | <img alt="Targeting" src="docs/figs/target_flow.svg" width="200"> |
20 | 54 | </p> |
21 | 55 |
|
22 | | - |
23 | 56 | ## Development |
24 | 57 |
|
25 | 58 | It is useful to set up a proper development environment with the provided |
|
0 commit comments