I haven’t posted on my RC car since a while; but I have made a lot of improvements :
- Stability and security improvement
- iOS app is now universal
- Added support of game controller in iOS app.
- Added video streaming from camera
Stability and security improvement
I improved a lot the stability on both side, and it is now much more secured; disconnection is detected on both car side and iOS side, and the car stops immediately.
iOS app is now universal
The iOS application is now universal and works on iPhone and iPad (but I almost only use it on iPhone now).
Support of game controller in iOS app
I added the support of bluetooth game controllers on the iOS app. I have a Mad Catz micro CTRL and I must say it changes everything; it is now very easy and natural to control the car with it.
Also thanks to Apple and its Game Controller framework, it took me only maybe 1h to add this feature in my app, it is very easy to use.
Video streaming from camera
And yes, after all I added the video streaming from the Raspberry Pi to the iOs app. This was a big challenge. First I tried to use vlc to stream from the RPi, but I add a terrible latency, something like 2 seconds, which was not acceptable to be able to control the car remotely ! So after some research, I found GStreamer, it is an open framework which offers lots of feature regarding video live streaming, and it can have a very low latency for streaming ! GStreamer is available on all OS (Linux, Windows, iOS, Androïd). So I have gstreamer on both side, one arch linux version on my RPi, and one iOS library on my app.
Unfortunately, the pre-build versions available are outdated a lot, so I had to build my own version for iOS. I won’t detail how to do so, this blog does it well : https://tausiq.wordpress.com/2014/12/11/ios-gstreamer-framework-custom-build/. The only problem I still have with the iOS library is that it does not support iOS 8 sdk, it only support iOS 6, so I have to build my whole app for iOS 6, and this is not very convenient; I hope the gstreamer guys will fix this soon.
On the Raspberry Pi application, once the car is connected to an iOS app, I launch the gstreamer command line utility gst-launch (with execvp in a child process), with rpicamsrc as a video source, it is a gstreamer plugin made to use the Raspberry Pi camera as a video source. So my parameter on the raspberry pi are (the host is the iOs app ip address and I change the port on every new connexion, so I never have troubles with disconnection/reconnections) :
gst-launch-1.0 rpicamsrc bitrate=2000000 preview=0 rotation=180 ! video/x-h264,width=640,height=480,framerate=48/1,profile=baseline ! queue ! h264parse ! rtph264pay config-interval=1 pt=96 ! udpsink host=192.168.1.xx port=xxxxx
On the iOS app, I use the gstreamer sdk; I won’t detail how I use it, I just did as in the tutorials and examples you can find on the web; but I just give my parameter to create the pipeline (because this was were I had to try lots of different configurations, so if anyone wants to do the same, you can use my parameters on both sides, it works well) :
udpsrc port=xxxxx ! application/x-rtp,encoding-name=H264,payload=96 ! rtph264depay ! h264parse ! avdec_h264 ! autovideosink sync=false
And this is it, the streaming works well, with a very low latency (and I am on a wifi connection !) and a quite good quality, it is enough to be able to drive the car with only the view from the camera !
More to come soon…
Yes, more to come soon (or at least I hope). I totally re-designed the hardware on the car.
- I changed the power regulator from a linear to a pwm one, so I hope my battery will last a little bit more time.
- I added a DSPIC33 on the board, it will manage the motor regulation loop (from the sensor I have for my brushless motor and I don’t use yet), and both the brushless motor and servomotor control. The communication with the RPi will be done by SPI.
- I added a battery monitor; it is also connected to the DSPIC.
- I added some LEDs on the board to be able to have a status without having to connect on ssh !
- It is now a real dual layerPCB, not just a veroboard !
The PCB design is finished, I just sent it for manufacturing, and I might receive it in 3-4 weeks, so more news then …
I almost forgot, but if you are looking for a new (maybe longer) ribbon cable for the Raspberry Pi camera, there is a good chance you cannot easily find one with 15 contacts. In facts I found out those ribbon cables come from Würth Elektronik, you can find them here : http://katalog.we-online.de/en/em/686_7xx_xxx_001
And as usual, I didn’t detail everything, but if you are trying to do something similar to me, and are facing the same problems, do not hesitate to ask, I spend a lot of time on this project, so I would by glad that my experience can help someone else.