Last year we demonstrated the first application server running on a Raspberry Pi with the Liberty profile. Later in the year we demonstrated running the Liberty profile on a mobile phone. Now we’ve gone even further and have a Liberty profile server running on and controlling a radio controlled car! Introducing the truly mobile application server!
What is the Liberty Car?
How do you control the car?
The web application running on the Liberty profile presents a simple Dojo web page that lets you control the car (see left).
The main part of the UI is a Dojo 2D grid – the x axis controls the car’s steering and the y axis controls the car’s speed – both are variable with very granular controls (200 different angles for steering are registered which is more than enough). Every 100ms the UI sends a POST request to the web application on the car with the current steering and speed values which the car then sets itself to. If the UI doesn’t send the car a new set of speed/steering values 300ms after the last transmission then the car applies the breaks and stops moving – this prevents the car racing away if you lose control.
Each device connected to the car is given a unique user ID based on the users’ IP address – through an admin panel for the car you can grant/remove control rights from any users on the fly to allow as many or as few people control rights at the same time as you like – if you tell the admin panel to let all users control the car then everyone can control it at once leading to a “race by committee” mode where the users all fight for control of the car which will try and average their commands to decide where to go.
The car contains:
- Raspberry Pi (the ‘brain’ of the car that runs the Liberty server and web application that controls the car)
- Servo (for steering)
- Motor (for driving the car)
- ESC with UBEC (for controlling the motor and providing power to the servo)
- PWM board (to let the PI control the servo and ESC directly – each needs 1 PWM signal and the GPIO on the PI only has 1 hardware PWM out) – we used one from Adafruit
- GPIO ribbon cable and breakout board (not functionally needed but having a ribbon cable makes it much easier to attach/detach the Pi from the car without worrying about wiring it all up correctly)
- Step down power regulator (to take the 7.2V from the battery and turn it into 5V for the Raspberry Pi)
- USB powered wifi router (in access point mode to allow lots of connections to the Pi’s wifi without worrying about trying to set the Pi up as a wifi access point)
- 7.2V battery pack (standard remote control car NiMh battery)
- Y splitter cable for battery pack (to split power between the Pi and the motors)
How does the web application drive the motors on the car?
The web application sends I2C messages out to the PWM board from the Raspberry Pi’s GPIO pins– the web application makes these calls and so directly controls the PWM signals which control the servo for steering and the ESC controlling the motor for speed.
How responsive is the car?
The car is very responsive – I can’t perceive any lag in the car when controlling it which makes sense as signals are sent every 100ms and processed extremely quickly – the biggest latency is the time it takes for the motors to react (approximately 400ms to move from full lock left to full lock right when steering).
What makes this different to the other Raspberry Pi controlled cars?
Many Raspberry Pi controlled cars have the Pi replacing or controlling the radio transmitter with the car still having a radio receiver – this means the car is still radio controlled and so you have limitations on how many cars you can control in an area due to the number of different frequencies available – this setup replaces the radio receiver so your limitations are the number of wifi devices in the area. The other main difference is that the car is controlled from a web page presented from an application server running on the car – you don’t need a specific mobile app or other application to control the car beforehand (although you can write your own if you want) so anyone can connect and control the car from a web browser making it a lot more flexible. Due to the fact it runs on an application server it also means that it can be controlled over the internet – we have been able to drive the car which was located in the UK from a mobile phone in Germany.