Close

TKIRV ROAMS FREE - Control over cellular network!

A project log for SOLARBOI - A 4G Solar Rover!

SOLARBOI is an attempt to build a land vehicle that can operate indefinitely in the wild, remotely controlled over the mobile network.

tkTK 09/15/2016 at 00:490 Comments

TKIRV - now controllable over the internet! Because hell yes. Check out the orange wheeled monster in action...

From the beginning, the goal of this project has been to build an R/C car that can travel far and wide. This necessitated a way of controlling the vehicle remotely at a far greater distance than is normally possible with typical radio control setups. Thankfully, humanity has seen fit to develop high speed cellular internet connections which are perfect for this very purpose. We had a lot of work to do, but we cracked it.

ccc

There were issues using a cellular connection, of course. Unfortunately, unless you're using very specific business-grade plans, telecom companies here won't give you a public IP and you'll struggle to get your cellular connection to accept incoming connections. This was a problem for us; TKIRV runs a Python program as a "server", which we connect to from a laptop "client" to issue drive commands. We also need to be able to SSH in to the Raspberry Pi controlling the show. The easiest way around this is to set up a VPN server on your home connection, and have the cellular remote station connect back to it. Then you can work as if both machines are on a local network. I used OpenVPN to achieve this and it was relatively painless. It's very well documented and there's plenty of great guides on how to use it with the Raspberry Pi and also Windows. However I did have problems with the webcam stream later on.

One basic, yet very important step was to add a USB hub to the Raspberry Pi Zero. We needed to connect a webcam, a mobile internet dongle, WiFi for occasional troubleshooting, and even a keyboard & mouse at times, so we needed more ports. I went for the Stackable Raspberry Pi Zero hub from Makerspot. Four ports, no issues. With some extra polycarbonate mounting hardware I bought, I was able to bolt this up and mount the whole Pi Zero assembly to TKIRV without any problems.


Next on the agenda was to get a webcam stream up and running on TKIRV. I found a Microsoft Livecam VX-2000 for $7 and that seemed as good a choice as any. Thankfully for me it's got good Linux compatibility and thus works great with the Raspberry Pi. However, I quickly learned that streaming a webcam in the manner I wanted wasn't actually so easy.

It's easy to get a webcam feed running off virtually any computer these days. Whether you want just a still shot updated every few seconds or if you want video, it's not hard at all. However, we needed to be able to DRIVE using the webcam, and so latency was a huge issue. We needed to be streaming as close to real time as possible. At that point things became a massive headache. After a huge amount of research, I happened across a tool called MJPEGstreamer. It took me a full 10 hours to get it compiled and running properly, and suddenly - huzzah! I had a webcam stream with less than 500ms latency running over a 3G cellular modem. But even that wasn't good enough. For one reason or another, MJPEGstreamer doesn't drop frames when the connection varies in speed. This means that you may start at 500ms latency, but if throughput temporarily drops, it starts cueing up frames for delivery, making sure every last one gets sent - and gets further and further behind live updates. After just a minute or two I was seeing over six seconds latency! I suspect this is due to MJPEGstreamer using TCP over UDP but I can't be sure. All I knew was I needed another solution.

I then happened across gstreamer. It's an incredibly flexible program, but it's also one of the most complicated and arcane pieces of software I've ever used. That's the price you pay for power, but damn. I think perhaps one of the bigger problems is it's not super well documented as far as I could see; I eventually patched together a working send and receive "pipe" after assembling scraps off different forums from people doing the same as me. The biggest headache I had was getting gstreamer to run over the VPN connection. My laptop base station was able to connect to the RPi stream but wouldn't actually display anything. After hours spent pulling my hair out, I realised that as the stream was an outgoing connection from TKIRV, I could simply squirt it directly at my laptop over the internet, ignoring the VPN entirely. All I then needed was to set up a Dynamic DNS so that TKIRV can always find my laptop over the internet, and I was good to go. Now I had a stream running over 3G with less than 300ms lag on a good day! Finally.

Alex, wondering why he was spending ANOTHER Sunday standing around in the driveway...


So it came time to test. During development we'd used an Optus 3G USB dongle for our cellular connection. We fired up the webcam stream and got the control program hooked up, but we were suffering huge lag and frequent dropouts. The stream was buggy and our Python command and control app kept losing connection. I suspected it was a bandwidth issue, so we ran a quick test using my mobile phone as a 4G WiFi hotspot. Things improved enough that we rushed out and bought ourselves a 4G hookup. Unfortunately there weren't any 4G USB dongles at the supermarket and everything else was closed for the weekend, so we settled with a 4G WiFi hotspot to keep us going for now.

TKIRV with its new 4G WiFi unit taped on because it was late and damn it, we needed a result!

Did it work? OH BOY DID IT WORK.

TKIRV cutting some mad shapes on the street at night.


It was absolutely elating as Alex walked the car out to the pavement - the video was smooth and responsive, and we could actually drive! The first night we did have some issues with the main motor drive, which we later tracked down to low battery voltage which was easily fixed. The feeling of being able to drive this thing as far as possible was totally electric.

Sooner or later, they all have to leave the nest.


We took turns driving and walking with TKIRV, doing a shakedown of all systems. We did identify some issues. Maximum resolution we can currently run the webcam at smoothly is 160x120; any more than that and we run into bandwidth issues. I suspect this is due to the inefficiency of streaming our webcam's native MJPEG format; we may be able to run higher resolution with an h.264 native webcam if we can get one cheaply somewhere. We also had problems with the webcam mount being knocked around during crashes, so that's a prime candidate for improvement.

TKIRV on a grand adventure, driving off into the sunset...


Another main target for improvement is control. Currently our main drive is hard forward or hard reverse; our steering is hard left or hard right. This makes controlling the vehicle difficult in tight spaces, particularly when webcam and control latency comes into play as well.

We've got a long list of upgrades to do to get the platform up to a more robust and reliable state.

After we've finished this and got some more driving under our belt, we'll look at implementing the next stage - solar hardware for indefinite mission operation. I can't wait to actually do some serious, long drives with this beast.

Till next time - TK out.

Discussions