This is the car of our team for CoVAPSy (Course de Voitures Autonomes Paris-Saclay). CoVAPSy is a race for 1/10-scale autonomous cars on an indoor track. The car uses a 360° LiDAR, a Raspberry Pi 5 and an STM32 microcontroller. The software is in Python and C, without ROS.
Architecture
The Raspberry Pi does the perception and the decisions. It reads the LiDAR and calculates the steering angle and the speed 15 times per second. It also runs the race state machine.The STM32 does the time-critical tasks:
It generates the 50 Hz PWM signals for the steering servo and the motor controller.
It arms the motor controller at start-up.
It reads the rear distance sensor, the wheel encoder and the IMU.
It shows the status on an OLED display.
The Raspberry Pi and the STM32 communicate through a serial line with text commands. For example, S12 sets the steering angle to 12°, V0.8 sets the speed to 0.8 m/s and X stops the car. The STM32 sends an acknowledgement for each command. Every 500 ms, it also sends a status line with the pulse widths, the rear sensor value, the heading and the wheel speed.The STM32 has a watchdog. If it receives no valid command for 250 ms, it stops the motor and sets the steering to the centre position.
Driving
One Python function, gap_follow(), calculates the steering angle and the speed from each LiDAR scan:
It makes each obstacle wider by half the width of the car plus a margin.
It adds a safety bubble around the nearest obstacle.
It finds the widest gap in front of the car.
It aims halfway between the centre of the gap and its deepest point.
It decreases the speed when the steering angle increases or when the clearance decreases.
In a dead end, the car reverses toward the side with more space. It reverses only if the rear sensor shows that the area behind the car is clear.The Webots simulation uses the same function without changes, with one car or with four cars. Ten unit tests check the function with synthetic scans.
The car moves only when the LiDAR sends scans. The last scan must be less than 0.5 s old.
If the car receives a forward command but the wheel does not turn for 3 s, the car is stuck. It then reverses at full steering angle for 1.5 s.
The car reverses only when the rear sensor data is new. The software treats old data as an obstacle.
When the program stops for any reason, it sends a stop command.
Limitations
The speed control is open-loop. The value "0.8 m/s" is a pulse width for the motor controller, not a measured speed, because the wheel encoder is not calibrated. The camera detects only when the car goes the wrong way. It uses the colours of the track borders for this. It does not change the steering.