The project is a Raspberry Pi based vehicle that implements automatic road tracking, Bluetooth joystick controlled movement, and obstacle avoidance.
python main.py --help
All relevant GPIO pins, vehicle standard speed, vehicle CarStatus, and processing frequency are defined in config.py. It can be modified today to meet other requirements.
- Raspberry Pi 3
- CSI Camera
- Infrared Sensors
- Ultrasound Sensors
- Car Skeleton
- Four Motors
- Other Accessories
The camera on the raspberry pi needs to be enabled in advance. Picamera is used to get data from the camera and process it accordingly. The settings for the camera section are in camera.py.
We are using Picamera to get the raw data and process it into jpeg format for web display.
The infrared sensors are installed on the left and right front of the vehicle and can be
used to monitor the presence of obstacles in the corresponding direction. The default
value of the sensor is int
, to make it more readable, it is converted to bool
and
returned via a Tuple
. It is defined in infrared.py.
Ultrasonic sensors are installed in front of the car and can be used to obtain the distance between the obstacle and the car. The accuracy is poor for places with more obstacles. It is defined in ultrasound.py.
A simple web page based on Flask
is provided to display the current camera shot as
well as the car's sensor specific parameters and the vehicle's CarStatus
at the time.
Please visit http://ip:8080
to fetch the data. You can modify it in main.py
.
We only use the camera for line tracking. By splitting the image into left and right parts, we can determine the position of the left and right track lines and make a straight and turning decision based on the track line position.
All related codes are in track.py.
The controller provides interaction with the xbox one gamepad to control movement via the left stick, and RB and LB button provide deceleration and acceleration functions respectively.
We ara using xpadneo to drive the gamepad and python-evdev to read the status of gamepad. Please follow the guide of xpadneo to connect your gamepad to Raspberry Pi and adjust setting in controller.py to match your gamepad.
Obstacle avoidance is based on ultrasonic sensors and infrared sensors. Motion decisions are made based on these two data, with the ultrasonic sensor data playing a dominant judgment role due to the close detection distance of the infrared sensor. The processing logic is defined in obstacle_avoid.py.
This project is open sourced under MIT license, see the LICENSE file for more details.