Wifi controlled Raspberry PI 2 Rover

This is my first project posted on LMR as well as my first robot project ever. I started it about 8 months ago in my spare time.

I'm a programmer at my day job so all electronic stuff & Robots is new for me. This project was mostly to learn & help me go to the next level. My initial goal was to make a robot based on the 6WD Dagu Wild Thrumper but I decided to begin with a cheaper frame to experiment.

 

 


 

Goals

My goal right now is to created a Wifi Rover that could be controlled from anywhere in the world over the internet (video feed included) and also to "gamify" the experience at the same time. I might as well give it a 3G connection and drive it out of my Wifi coverage, in the neighborhood. Robots anywhere :)

Step 1:
Make the experience a little more "FPS" like. (e.g. Battlefield) That mean, directly controlling the Rover with a video stream and HUD to display various data.

Step 2: (If I ever make it this far)
Make the Rover autonomous and control it like a RTS game (e.g. Starcraft). Ideally, I would like to be able to select the rover with the mouse on a generated map of what the Rover "scanned" and right-clic where I want the Rover to go. The Rover should then use a path-finding algorythm to go where I asked on the "scanned map" the more efficient way. Ideally (but that will involve a lot more work if I go this far) many rovers could be active at the same time and "share" their position & revealed portion of the same map so they all know where they are relative to each other and they won't crash if I ask them to move all at the same time.

I know these goal are far fetched but I think to make great thing you have to aim even higher. So even if I don't make it, I'll have learned a lot and made a lot of fun.

 


Mini Rover Frame & Parts

So my first step was to make the Rover. I began with a small 20$ Rover chassis from Robotshop.

 

The Raspberry PI & USB Wifi came for a CanaKit bundle I bought earlier from Amazon

I also bought other stuff at Adafruit:

And finally a Polulu dual motor driver & voltage regulator to step up a 3.7V lipo:


Some stuff I received from Adafruit


Gearbox assembly


Installation of the motors & tracks


Raspberry PI installed on top of it. (It was a B+ Model at the time)


Connected camera (Take note that it wasn't bolted to the frame yet in the picture) I managed to fix it to a little hole at the front


First video stream test working using MjpgStreamer :D

That video part was of great importance to me because I wanted to use the power of the raspberry PI to stream the feed over Wifi instead of using a wireless camera. That way, I could use the Rover over Wifi, and, most importantly, the PI could eventually "see" the image and use it in the logic part. (Maybe with OpenCV)

After searching a bit I decided to use MJpgStreamer to stream video. I found this special distribution which allowed me to use MJpgStreamer with the Raspberry PI Camera: 
https://github.com/jacksonliam/mjpg-streamer


Then came the code part

I decided to use the Microsoft XNA framework on the PC side (* more on that later) to allow me to display the camera feed and add additional HUD part over it. Note that the PC is only a client. No complex logic is happening on the PC. The Raspberry PI part is programmed in Python (I had to learn from scratch but well, it wasn't that hard)

 


HUD Widgets

The first video shows the result with already a lot of HUD widgets:

  • Camera feed in the back
  • Game-like compass not working but still displayed in the top (Working in video 2 and 3)
  • Top image of the rover displayed bottom left of the screen with "power bars" that light up depending on each motor throttle position.
  • Visor. Nothing special here except it looks great. Help to determine where zoom would take place
  • Software zoom with small text display on the right working (Display "1x" usually but changed to 2x when zoom is enabled)
  • Speed display on the right but it's not working since I don't have motors with encoders. (I learned afterward that I need special motors to determine speed)
  • Battery displayed but faked for now (I didn't installed my current sensor yet so I can't "fuel gauge" the battery)
  • Headlight indicator at bottom-right of the screen working (and communication done to the PI that I was lights on or off) but no light is installed on the Rover yet (I want to be able to light them up and navigate in the dark)


Screenshot of the video showing the HUD of my Raspberry PI Rover.


Upgraded chassis / Pan & Tilt kit

Then I realized I wanted to be able to PAN & Tilt the camera which was impossible with the small chassis I had, so I upgraded to a bigger Rover Chassis Kit.

This Rover chassis is a little more expensive but allow way more place for my project and come predrilled with holes for a Pan & Tilt kit

I also decided to upgrade my battery to 7.4V to have more power for my motors (I wanted more speed) and to make sure the servo get enough power. My step-up voltage regulator would not be strong enough and stepdown regulators are more efficient.

I also added a servo hat to drive the servos for the Pan & Tilt camera.

 
The chassis upgrade with pan & tilt 


Here we can see the Raspberry PI, under the the Adafruit Servo Hat, under the Polulu dual motor driver hat and the voltage regulator.

However I wonder if that 25W switching regulator was a bit overkill for the task. The Servo hat has a connection point to add a capacitor but I didn't have to install one and the servo still run fine. Maybe I could have bought a smaller regulator but soldered a capacitor instead.

 


 

Software upgrade / XNA Discontinued

While working on my project, Microsoft launched Windows IoT for the Raspberry PI. Since I'm more familiar with C# and that could be easier to maintain, I began to think about trying this for my Rover project. However, to install Windows IoT on the Raspberry PI, I needed Visual Studio 2015 and Windows 10. I therefore went ahead with the upgrades but as soon as I started my project with VS2015, I quickly realized that Microsoft does not support XNA anymore. (It refuse to install on Vs 2015) Bummer. I managed to install it anyway using some hack I found on the net but I think I might have to port my code to Mono XNA to ensure better support in the future.

And while Windows IoT is promissing, the Raspberry PI Camera still don't work with it. So I'm learning about this OS but my Rover will stay in with Python / Linux.


 

Everything installed

Here is a couple of picture of the Rover with everything installed

 


 

Current parts list


 

The hardware part from a software developer perspective

While making the project, I quickly realized that while the software part was easy for me, the hardware part was another story. My soldering skill was awful and, even worse, I ordered stuff and never realized there was any soldering to do...until I received the first batch of products home.


One of my first soldering project. This Adafruit LCD board suddently stopped working and I have no idea why. ;)

But hey, I'm here to learn so I went ahead anyway and luckily, my skills quickly improved:


I suppose that's probably not ideal for a veteran but it's way better than my first tries.

Also, I had no idea that "stacking headers" ever existed. 


On this version of the Rover, w
e can see the compass connections were done with a bit of soldering on the tip of the wires because the header pins that came with the motor controller "hat" were too short. I had a hard time not accidentally disconnecting them while working on the Rover.

That project was clearly out of my zone of comfort but, overall, I can say that I learned a LOT through this project and that it's a lot of fun to work on it. I recommand anyone who is interested in robotics but lack knowledge to just go ahead and hope for the best. :) It's not as hard as it seems and the only thing I regret is not trying it sooner.

 


 

* update 2016-02-20

Source

https://github.com/irDrake/RemoteBotClient
https://github.com/irDrake/RemoteBotServer

Gamified remote controlled Rover with telepresence

  • Actuators / output devices: pan and tilt system, tamaiya dual gearbox and tracks
  • Control method: WiFi
  • CPU: Raspberry Pi 2
  • Operating system: Raspbian Linux
  • Power source: 7.4v LiPo 2000mAh
  • Programming language: C#, Python
  • Sensors / input devices: compass, accelerometer, Raspberry Pi camera module
  • Target environment: indoor

This is a companion discussion topic for the original entry at https://community.robotshop.com/robots/show/wifi-controlled-raspberry-pi-2-rover

This project is very

This project is very impressive. In the second video you mentioned that you corrected the slight pull to the left. How did you accomplish this? Did you use pwm, encoders, other?

Once again very nice project. 

Thanks!

Thank you very much wilsorob! 

Since it’s my first robot, I was nervous to see my first feedbacks. :slight_smile:

For the slight pull it was more a hardware problem and had something to do with the gearbox. I didn’t have to change anything in the code. I had to disassemble the gearbox to adapt to the new frame & longer tracks so I decided to try to put more grease on the gears at the same time. It’s that simple :slight_smile: I suppose I could have achieved the same result with the previous smaller chassis.

 

 

Very nice post!

Wow - very nice post indeed!

Awesome bot!

Do you have the source code available?

You mention a current sensor for monitoring the battery. But measuring the battery voltage might be both simpler and more effevtive if you have any chips that can read analogue voltages. Certainly the voltage of a lipo battery is something you would want to monitor to avoid damaging the battery.

Yeah I ordered an analog to

Yeah I ordered an analog to digital IC and luckily, the Adafruit Servo controller include some kind of semi-permanent breadboard. I migth use that. I think the next Raspberry PI version should include some analog pins. :wink:

I am planning to move my client code from Microsoft XNA to Mono XNA and then I’ll put my code on github. I’ll update my post when it’s done. (Because installing Microsoft XNA on VS 2015 was done with some kind of hack. I don’t want that to be permanent)

Very Nice!

Nice project! Excellent write-up too. Welcome to LMR and thanks for sharing your project!

Nice to see another software guy in this forum - though in my case I was a hardware guy and switched into software, so at this point I guess I am semi-comfortable in both worlds. :slight_smile: Your 2nd video was mentioned by someone else here, nice that a little lube fixed yours, oftentimes that works but sometimes one has to compensate either in the software or hardware or even both - pwm with a wheel encoder is an example of “both” (for those unfamiliar with the concept, it is essentially counting ticks of the wheel encoders and adjusting the pwm on both sides till the counts on both sides are coming in at an equal rate). Sometimes it can be rather difficult to get a robot to follow a straight line for long distances.

I assume at sometime you may venture to make this either semi or fully autonomous? In any case, you’ve got a great start here. Welcome aboard!

-DB

 

 

Nice job

Very nice write-up.

  1. Can you provide some details of the compass?
  2. On a much cruder but similar robot, I have been able to replace the front sproket mount with an optical encoder module. Not the greatest bearing but ok for my use.

 

 

Thanks! :slight_smile:

Thanks! :slight_smile:

Interesting. I don’t have

Interesting. 

I don’t have encoders for the moment. I wonder if I can retrofit one of find a motor that would fit and has one.

That could help for my speed display. :slight_smile:

My compass

I used this Adafruit board for the compass:

Triple-axis Accelerometer+Magnetometer (Compass) Board - LSM303

It’s not exactly working as I expected. Instead of simply returning the north position, I get raw reading as X, Y and Z. I then need to figure the north position with some math. It’s not very complicated with the sample code and that usually work but if my rover is not on a flat surface, readings are sometimes odd.

Nice work

It is a great idea and it looks like it worked out great from my perspective! I’m also a software guy getting into this robot thing.

Keep up the great work! You should set up a GitHub account and share your code :slight_smile:

Will do. :slight_smile:

Will do. :slight_smile:

I’ve just taken a look at

I’ve just taken a look at your rover and I want to say that I’m impressed!

Particuliarly with the camera feed and the HUD.

Quite amazing!  I’ll have to try it in my future rovers…

 

Thanks!

Thanks Kadersin!

There was a lot of test & trial to make it work but I’m happy with the end result.

Source code Available

If anybody is curious, I uploaded my code here:

Python Code
https://github.com/irDrake/RemoteBotClient

.Net Client
https://github.com/irDrake/RemoteBotServer

Hello. on my google

Hello. on my google search,this is by far ,the best wifi remote controled bot that i saw. tha hub on screen is marvelous.

My problem it’s i’m good in hardware and eletronics but bad in software :P  .

Did you wrote any software tuturial?  i don’t know how exactly install this “pile” of code.  It’s my first pi work ,and new on python (i came from arduinos).

Really interesting !

Thank you for your detailed post - it inspiring me to work faster on my future “Mark 3” where I want to implement staff very closed to yours, but on Android platform.

Working on my “Mark 1” I had a lot of hardware problems too, because I am much more software-man, so I am understand you completely :slight_smile: Migrating from MIcrosoft is very good idea, I believe - it will save a lot of time and nerves to you.

Wish you good luck with this project - please keep us informed how the things are going.  

what do you use to stream

1. mjpeg streamer is fast ? I used motion for webcam streaming.

2. what do you use to power the raspberry pi ?

3. what do you use to control the robot from the internet ? as for me, I used a vpn server with public ip then I just use a vpn client to connect the robot via internet, meanwhile from my pc somewhere else, I used a vpn client to connect to that vpn server. vpn is pretty much secure since communication channel is encrypted

Yes mjpeg streamer is quite

Yes mjpeg streamer is quite fast. With the Raspberry PI 3, it looks real time. That’s the fastest method I found.

I used 7.4V batteries to power the rover, and a step-down voltage controller to power the raspberry pi

I did not control the robot from Internet yet. I’m still on my LAN for now.