In this lab section, the research group have prepared for the first demo function which is the emergency braking system. In this function, the car will use the sonar distance sensor as an emergency detector. The sonar distance sensor returns one hundred distance information to the pi and the pi will decide whether it is should stop and prevent hitting.
In detail, the research used python to write the program. In this function, the user could control the car as scheduled and the car could avoid the car hit a barrier. We used a while loop constantly and put all the judgement statement inside the loop, which runs following the following logic.
The users start the car and control the car by pressing the control keys. The sonar returns distance data by the microsecond. If the data begin to be smaller than 15 centimetres, the car stops automatically and move backwards for 15 centimetres to keep a safe distance and handle the control back to the users.
Problems:
The sonar distance sensor has a considerable error which may cause several mistakes. For example, during a test, when the car is moving in a path free of barriers, it stopped and said that the front distance is 35 centimetres. According to the codes, the car can only stop when the distance is smaller than 15 centimetres.
To solve this problem, we have to go back to the codes that check whether the distance is smaller than 15 centimetres, which means the sonar distance must have returned a data that is smaller than 15 centimetres. Then, the research group checked the sonar and have it return one hundred data in a second while printing the data on the screen. It shows that there could be several random data appear in normal data. Some errors are large while some are smaller than 15 centimetres, which could lead to the wrong reaction.
Having found the problem, we did some changes on the codes and have a list of returned value checked. Only if all the inputs are smaller than 15 centimetres, the car will react to the system.
In detail, the research used python to write the program. In this function, the user could control the car as scheduled and the car could avoid the car hit a barrier. We used a while loop constantly and put all the judgement statement inside the loop, which runs following the following logic.
The users start the car and control the car by pressing the control keys. The sonar returns distance data by the microsecond. If the data begin to be smaller than 15 centimetres, the car stops automatically and move backwards for 15 centimetres to keep a safe distance and handle the control back to the users.
Problems:
The sonar distance sensor has a considerable error which may cause several mistakes. For example, during a test, when the car is moving in a path free of barriers, it stopped and said that the front distance is 35 centimetres. According to the codes, the car can only stop when the distance is smaller than 15 centimetres.
To solve this problem, we have to go back to the codes that check whether the distance is smaller than 15 centimetres, which means the sonar distance must have returned a data that is smaller than 15 centimetres. Then, the research group checked the sonar and have it return one hundred data in a second while printing the data on the screen. It shows that there could be several random data appear in normal data. Some errors are large while some are smaller than 15 centimetres, which could lead to the wrong reaction.
Having found the problem, we did some changes on the codes and have a list of returned value checked. Only if all the inputs are smaller than 15 centimetres, the car will react to the system.
Comments
Post a Comment