PC racing set controlled RC car with video streaming
The project aims to equip standard remote control (RC) car with improved control. Commonly used RC car control joystick is replaced with PC racing set. This improvement ensures more precise driving and exceptional user experience. Moreover camera attached to car enables view from perspective of RC car, e.g, what would a driver in RC car see. User then can watch real time video on PC screen. Two servos enables camera to turn and therefore driver can observe surrounding of the car. Let's see now how it works. Driver controls car with steering wheel and pedals. He can drive out of his field of view, for example behind the corner or to different room because of the camera is streaming on the users screen. Therefore RC car can also be used for scouting.
Project was assigned to a team of 5 people of three different study backgrounds.
Team members and study backgrounds: Jussi Taskinen - electrical engineering, Klaus Kivekäs- mechanical engineering, Tomáš Lazák – mechanical engineering, Pravin Luthada - mechanical engineering, Kääriäinen Lassi – automation and systems technology.
Block diagram of the system is presented below.
Position data was attained by reading potentiometers attached to the racing set with Arduino Uno. An additional Arduino Uno placed on the RC Car. Nordic semiconductor NRF24L01 2.4 GHz radio transceivers were connected to both Arduinos and used to broadcast and read control data. The signals read by on-board Arduino were then used to control actuators on the RC car (three servos and one DC motor). Raspberry Pi in addition to its wifi and camera modules were also mounted on-board the car. Raspberry pi was used to stream the video through wifi to PC next to the racing set for video guided driving.
For the RC car we used an existing model, LRP's S10 Twister Buggy. The rear-wheel drive buggy uses a dc motor for controlling acceleration and deceleration and a servo for controlling the turning of the front tires. We fitted the chassis with a different body because the original body was not suitable for accommodating all the required electronics on the car. The wheel and pedal set used was an old Thrustmaster set from the 1990s. The steering wheel and pedals used potentiometers for position sensing, although, we had to replace the potentiometers in the steering wheel and gas pedal because the old ones had become imprecise.
The vertical and horizontal orientation of the camera was controlled by two servos. The servos were controlled by two potentiometers which were attached to the base of the steering wheel. We attached a steel plate at the rear of the car for attaching the Raspberry Pi and the camera with its servos. The Arduino was attached onto the yellow body of the car. The Raspberry Pi was attached to another steel plate with a wooden plate on top of it. For attaching the servos to the steel plate and for attaching the camera to the servos we 3d-printed some parts which were designed using Creo. The camera assembly with the 3d-printed parts, servos and the camera is shown in the image below.
Two holes were drilled to the wheel module to accomodate servo turning knobs.
The position data of pedals and wheels was determined by potentiometers. We replaced some worn potentiometers with new ones. Both pedals are read by a potentiometer as well as the wheel. Two potentiometers were attached to the wheel module as servo turning knobs. Potentiometers were read by Arduino Uno (ATmega328 microcontroller). Nordic Semiconductor NRF24L01 was used to broadcast the data. Radio operates at 2.4 GHz. Arduino powered via USB cable from PC.
The car was equipped with 1 x Arduino Uno with NRF24L01 radio module connected. All servomotors were directly connected to Arduino, and pulse width modulation was sent to electronic speed controller which controlled the DC motor. Motors were connected via speed controller to a larger 3300 mAh 7.2 V (check values) battery and Arduino was powered via power plug by 1600 mAh (check value) battery. To reduce number of wires, a PCB was made (image of PCB does no longer indicate the correct connection order because Arduino is no longer powered from Vin port).
Raspberry Pi was used to stream the video. Camera module and wifi module were connected to Raspberry Pi. It was powered by a designated battery.
Fig. Transmitter circuit
Fig. Receiver circuit
The coding and uploading was done by using the Arduino development environment. The transmitter Arduino is responsible for reading the potentiometers, scaling and manipulating the control values and sending them to the receiver Arduino. The transmitter Arduino's code starts by including the libraries and declaring the analog read pins for the potentiometers. Both Arduinos are using a third party library called RadioHead. The communication between an Arduino and a NRF24L01 is implememented by using SPI-protocol, therefore SPI library is also needed. In the transmitter Arduino's setup-function radio communication is initialized. It sets the cahnnel, data sending rate and transmit power. The loop-function is executed repeatedly after the execution of the setup-function. In the transmitter Arduino's loop-fuction the values of the potentiometers are read by using analogRead(). Then the values are mapped to are different range of numbers for the needs of the Servo.write-function. Gas variable is used to control the DC motor. The gas variable gets the value of the pedal's potentiometer that is pressed. If both pedals are pressed the gas variable gets constant value of 130 (DC motor stays still). There is also a limit variable that reduces the gas value to reduce the maximum velocity of the car, so it would be better suited for driving indoors. After all that the scaled control values are put in a data vector that is send to the receiver Arduino.
The receiver Arduino is used to write pulse width modulated signal to the servos and the DC motor's speed controller. The receiver Arduino's code starts by declaring variables and by including libaries. In addition to the SPI and the RadioHead library, the Servo library is also included. It's used for writing pwm signal. In the setup-function servo variables are connected to pins and radio communication is initalized. In the loop-function the control values are received by using nrf24.recv-function. The received values are then used to write pwm to the actuators. Pwm signal is generated by using Servo library's write-function.
To get started with Raspberry PI
the things we need to start working with raspberry PI
Raspberry Pi board
SD Card - GB
Display and connectivity cables
Keyboard and mouse
Setting up Raspberry PI
- download Raspbian for Raspberry PI
- flash the extracted image on to the SD card
- Connect everything as mentioned above and turn power supply on
- enter default user name and password and we are ready to get started
- type startx for starting GUI
- create a file in home folder lets say streaming.sh
- click and change the properties of the file as executable
- now right click on the file and click edit
- raspivid -n -t 0 -rot 270 -w 960 -h 720 -fps 30 -b 6000000 -o - | gst-launch-1.0 -e -vvvv fdsrc ! h264parse ! rtph264pay pt=96 config-interval=5 ! udpsink host=***YOUR_PC_IP*** port=5000
save and close the file
|Nordic Semiconductor NRF24L01||6||2 x €3.73 + €17.60 (check)|
|Nordic Semiconductor NRF24L01||4||0, received as replacement parts|
|Raspberry Pi||1||Approximately €30|
|Raspberry Pi Camera Module||1||€36.33 (check value)|
|Raspberry Pi Wifi module||1||€29.14 (check)|
|Arduino Uno||2||0, was readily available|
|Battery for Raspberry Pi||1||€49.90 (check)|
|S10 Twister Buggy||1||0, already available|
|PC racing set (inc. 2 x pedal, 1x wheel)||1||0, available at the start of the project|
|Double layered PCB board||1|
0, received from design factory
|Total price (check)||€170.43|
The car is controlled with the wheel and pedal set via radio communication. The front tires are turned using the steering wheel and accelerating, braking and reversing is done with the pedals. Like in a real car, the right pedal is the accelerator and the left pedal is the brake. However, reversing is also done with the brake pedal. The brake pedal will cause the car to reverse if pressed when the car is not moving forward. It should be noted that beginning reversing has a bit of delay, about one to two seconds, so the user should take caution when starting to reverse.
The onboard camera streams live video to a PC using wifi allowing the user to observe the surroundings of the car remotely and to control the car without it being in line-of-sight. The onboard camera can be rotated horizontally and vertically. The rotation is done by turning the knobs which are attached to the steering wheel's base. The knob that is mounted horizontally to the side of the steering wheel's base controls the vertical orientation of the camera and the knob that is attached vertically on the top of the base controls the horizontal orientation.
The range of the radio communications is about 30 meters. The range of the video streaming depends on the reach of the wifi network being used.
Conclusion and suggestions for improvements
In the end, the system worked quite well. Controlling the car with the steering wheel and pedals was extremely responsive. The camera streaming did have a 0.2 second delay which made it somewhat difficult to control the car using only the video footage. At the start of the project, the lag was significantly higher, in the range of about 1 second, so we did manage to bring that down. This was done by switching the video streaming program from VLC to Gstreamer and by reducing the resolution of the video stream. The delay could be further reduced by making the image black-and-white which reduces the amount of data per frame by approx. 30 %.
There was also another issue with the video streaming on the Mechatronics Circus day because the video stream has to be sent to the PC via a router. On the day of the circus the router at the mechatronics lab had extreme levels of traffic to the point of being overloaded. This meant that the video stream was very laggy as the router failed to process most of the frames. This issue could have been solved by using our own router.
During the project we had severe problems with the radio module that was attached to the Arduino on the car. We burnt a total of seven radio modules before we managed to solve the issues. There was a loose ground connection on our PCB and we also switched the method of supplying voltage to the Arduino from using the Vin pin to using the power supply plug in order to avoid potential issues with the regulator. We also added a capacitor to the voltage input pin of the radio module because at times the module can draw more current than the Arduino can supply it with. These issues could have been avoided by being more careful when creating the electrical connections and by doing more research on the radio module and Arduino.