top of page
Algorithms​

Release of a movable object

An object is released after a predefined time after the start of the game, making the location random. The starting position of the object is above ground in the robot’s arm. When the time condition is reached, the robot will stop and lower the arm carefully. The location of the object is determined by calculation based on earlier testing. The arm will then be raised again so it is not in the way of the ultrasonic sensor. To differentiate between movable and non-movable objects we use both color sensor and ultrasonic sensor. When the robot detects an object it slows down and stops in front of it. It then turns left and right to check the size of the object by using the ultrasonic sensor. As an extra check it uses the color sensor to check if the object has the color of a movable object, as given by the competition rules.

Obstacle detection

Periodically the the robot will turn 35 degrees to each side of its current heading to look for obstacles. If is sees an obstacle that it may collide with it will try to avoid it by turning slightly the other way, and driving forward for some distance before turning back to the original heading. The position of the discovered object is added to the map.

​

The robot always checks for obstacles ahead, in the main thread. If an obstacle is detected it slows down and approaches the object slowly. When the distance is lower than a given threshold the robot stops and turn to both to the left and right to see if the object is movable or not. If also uses the color sensor to determine if the object is movable. 

​

Positioning

Position is found by using the start position, heading, distance and time. When the robot turns, the heading is changed accordingly by calculating the number of degrees. When the robot moves forward the distance will be calculated. Multiplying distance by time is used to update x and y coordinates by increasing the current position based on the value of the starting position.

​

The start position of the robot is given in the init() method of the PositionController and can be changed depending on where the robot should start in an particular challenge. After the PositionController has been initiated, a thread that updated the robots position and heading is started. For each iteration it checks the time since last update and the current running speed, before using it to calculate the robot displacement since last update. The robot also checks the gyroscope to see if the heading has changed, and update the heading if a change has occurred. 

​

Map

The map is visualized by a matrix where each value in the matrix represent a square of 5x5cm. It is updated by using the current position of the robot and adding this square with a value depending on what the robot discovers. The specified value of a square is used to categories the area as either undiscovered, discovered, movable object, non-movable object, start position or the robots position. The map matrix start with all squares categorized as undiscovered except the starting position. The size of the initialized map matrix is set, but if the robot moves out of the map boundaries the map will adapt by expanding to the robots position. The expanded area is categorized as undiscovered. This makes the robot able to explore any area without knowing the size before it starts.

​

Area discovery

The discovery algorithm is divided in two stages. First the robot will work its way up the course by going from one side to the other. Each turn it does will be accompanied by some movement forward. This movement is shown in Figure 1. When the robot reaches the end of the course, the robot will turn and see a wall in front of it. It will then turn 180 degrees and continue the same procedure as before. Shown in figure 2. This is a time demanding process, but a very thorough one. It ensures that the full width and height of the course is discovered, before it goes in to the next stage. 

 

After a given time the robot will go over to stage two. It will then look at the map it has made of the course so far, and find areas and points that has yet to be discovered. The points found are sorted based on distance from the robot to the point, and then placed in a queue, and visited sequentially. This will go one until the full area has been discovered and the map is finished. Shown by figure 3.

​

Error correction

Errors occur quite often when using the robot. Running speeds on the engines are not always quite the same on both, and when the robot turns it sometimes turn to little or to much. To combat this the robot tries to correct its heading each time it turns, so that it always is heading in the direction it thinks it is. When it is going to run forward, a thread is created that checks with the gyro and sees if the heading has changed while it should run straight forward. If an change has occurred the speed is lowered on one engine and increased on the other to combat the change in the heading.

Missing functionality

Because of limited time to work on the project the last weeks caused by a lot of other projects. Not all the functionality that where planed have been implemented. These include the ability to spin around 360 degrees and measure the distance to possible object before updating the map.

Figure 1

Figure 2

Figure 3

Figure 4

bottom of page