- 1 Racing Car (RC 1/10th Car)
- 1 Servo (for steering control)
- 6 Ultrasonic Sensors HC-SR04 (for detecting distance)
- 1 Arduino MEGA2560 (for code and processing)
- 1 DC motor (speed control)
- Move Forward
- Stop
- Turn Left
- Turn Right
Based on testing with distance sensors, there was a margin error of 0.2cm.
With respect to the vehicle's velocity, it was concluded that keeping the variable velocity at 101 was safe enough for the vehicle to react on time and change trajectory.
After testing the front sensors with velocity at 101, the RC Car is able to safely stop without causing a collision once it detects an obstacle within 45cm of distance.
The variables for the front sensors are
distance3anddistance4.
There are a massive amounts of scenarios on how the car would or should move. For the sake of this project, we focused on fundamental scenarios.
The vehicle should turn only when it detects a close obstacle on the sides. If an obstacle is too close to the left, it should avoid a collision by turning right. Analogously, the vehicle should turn left if it is too close to the right. To solve this problem, add the distances from each side:
distance1+distance2= sum of distance on leftdistance5+distance6= sum of distance on right
Note: It is better to avoid dividing by 2 to decrease the number of operations, which could slow down the vehicle reaction time
Based on the results of some testing, it was concluded that the safe distance would be 5cm. In the model, that would imply the following:
-
Safe distance on sides:
distance1+distance2< 10
(The same applies todistance5anddistance6) -
If the obstacle crosses the safe distance --> turn on the other side
Using degrees, by how many degrees should the vehicle turn? this varies based on the vehicle's distance to an obstacle and the vehicle's velocity. For the sake of this project, the change in angle will be constant and 30 degrees to either side.
- If we want to turn left --> set angle to 90 - 30 = 60
- If we want to turn right --> set angle to 90 + 30 = 120
It was necessary to establish a vehicle's safe area. The code was designed so that if an obstacle is detected WITHIN the safe area then the vehicle has to take action to avoid it.
The functions and algorithm were designed with the intent to reduce the number of operations. Still, there could be potential improvements and optimized models that may require further research.
A delay was included in the code to prevent the buffer from being overloaded with detected information from sensors.
Currently, the change in angle is discrete with a constant value. Using a differential equation or a change that is non-constant would improve steering smoothness and vehicle's ability to avoid obstacles on complex scenarios.

