Follow-Halls For this practice we have used the simulator gazebo, where we loaded a world that represents the department at the university.
In this scenario, the floor is painted yellow, and other objects (walls, obstacles ..) are quite distinct different color.
The practice is that the robot will navigate down the aisle through the information that gives the webcam. That is, the robot receives the image from the webcam, analyze it to know where the corridor and take the appropriate decisions to move it.
Data received by the webcam found on one-dimensional array called imagenRGB.
This matrix contains the number of colors (red, green and blue) of each pixel that observes the camera.
This matrix has the following structure:
observed - Each pixel is represented with three cells of the array in which the first is for blue, green second, and third red.
- Then the red pixel, the next cell represents the blue color of the next pixel observed. Should be the same line the pixel is the next right, if the line is finished the pixel is the first pixel to the left of the bottom row.
That is, the array is traversed from left to right and top to bottom storing information of each pixel in 3 adjacent cells.
Therefore to know the position in the array occupies a particular color in a row and column I created a function called get_posicion, which receives the row number, column number and the color (0, 1 or 2) and returns an integer indicating the position the array.
Once this is done is to analyze the image to move correctly.
need to control the speed at which it progresses, and the speed at which it turns to one side or another robot.
The robot
rotation is performed in terms of what this is focused on the corridor.
For this review a particular row, obtaining the point where it begins and ends yellow, and calculate the midpoint. That is, look where the center of the aisle in that line. Subsequently compared with the center of the screen, since the intention is that the robot will always be the center of the hall.
So do the operation velocidadGiro = the center of the screen, therefore not change the sign of velocidadGiro.
However, if the center of the corridor is more right than the center of the screen (centroPasillo> centroPantalla) replace the sign velocidadGiro so that instead of turn left turn right.
The feedrate
the calculation also of what the robot that is focused on the corridor.
I used the following formula:
speed = 1100 - even to stop (later I find that speed is not a negative number).
must now consider several special cases
.
The corridor widens as you near the walls.
The robot can not find the passage in the selected line.
If you did not take into account the first, the robot was going too fast when approaching the end of a hallway, and gave him no time to turn, so often hit a wall, or braking too late and stop seeing the corridor.
solve at each iteration to check if the whole line that I notice is yellow, that is, every corridor. If that's the case under the speed to 400 to give you more time to react.
- The second case can occur when the robot gets too close to a wall or corner and fails to see the hall.
In this case I've done is look for on lines that are below. Ie I look at a particular line, but I notice hallway encounter a line that is below, if I still entontrar hall, set me back down, and on three occasions. -
lines I have chosen are:
If meeting hall, I look at the line of the screen 4.5/5.5
If the above passage I have found I look at the line 5 / 6 of the screen
If the above passage I have found I look at the line 8 / 9 screen -
If the above passage I have found I look at the 11/12 line on the screen -
Finally if there is no passage in any of the above the robot performs a random rotation to find the passage in any of the above. -
Problems: -
Apart from the above special cases I found that the robot was acting strangely when accelerating so quickly to pass very quickly from 0 to 1100. This made the robot bumps into corners or undertake some sharp turns, so to solve I opted to give smoother acceleration so if the forward speed of the robot real (v) is less than the speed at which I make progress (v less than speed) increase the actual speed 30mm / s in each iteration.
Below you can see a video of the robot walking around the department and out of dead end. The actual speed is greater than that seen in the video, but to make the recording and the computer slowed down the speed of gazebo.