INTRODUCTION:
The objective of this task is to perform a PID reactive control capable of following the line painted on the racing circuit.
In my case, I decided to implement a PID controler for the angular speed and I have left 2 constants speeds: one for straight lines and other for curves.
IMAGE FILTERED:
In this task the only information we were able to use is the camera and so, I had to obtain all information from it. To obtain that information I decided to use Opencv library:
Using Opencv and HSV values, I was able to get the red mask I was looking for. I have used : cv2.cvtColor, cv2.inRange and cv2.bitwise_or.
CENTER POINT:
After getting the mask where red line was caught, I took cv2.moments to get the moments of the image and draw a green circle. Down below, you can find a snippet of what I am trying to explain:
That point will be our reference between our real center which is the x coordinate: 329.
Now, after knowing our reference and the center, we can calculate the error to take into account.
err = (center - reference)/ 100
I have decided to divide that error by 100 because the resulting values for the angular speed were really high.
Here we are only taking into account x axis since y axis does not change.
LINEAR CONTROLLER:
In my case, I have finally stated that I will leave a constant speed due to I have struggled with inserting a PID controller for that.
Now, you may have doubts about how I have considered to make the f1 know what is a straight line and what is a curve. To do that I have stated that if the reference (means in x axis) is higher 339 or lower that 299, means that the reference is really far away from the center and it is a curve. The resulting values are set as straight lines.
To make a difference between straight lines and curves, I have set 2 different values:
- Straight lines: HAL.setV(2)
- Curves: HAL.setV(1)
I know that it exists higher values but for all the ones I have tried, are the ones that follow perfectly the read line in the whole circuit.
To conclude I would like to outline that in an average of tries, it takes about 5:30 to do the "Default Line" circuit. Besides, I have had problems with Sim RTF due to its values were about 68 to 80. The video is taken with the simulator in labs so its Sim RTF values were about 95 and the total time improved.
Here you can see a picture of the output.
Down below, you can find a video.
VIDEO:



No comments:
Post a Comment