Introduction: Do-it-yourself Autonomous Tiny Robot

Picture of Do-it-yourself Autonomous Tiny Robot

Say hi to Naboris!!

I've built a cheap robotics platform capable of autonomous movement with modern and readily available parts you can find online. Follow this guide if you want to build a robot but feel limited by platforms like Mindstorms, VEX, and Tetrix but don't have enough money for professional platforms (I assuming most of us don't have $20k laying around to spend on projects).

Code used for this project: https://github.com/Woz4tetra/Naboris

Let's dive in!

Motivation

There's a lot of cool expensive robots out there (e.g. Boston Dynamics' Atlas and Spot, CMU's Boss and CHIMP). Unfortunately, most of us don't have access to millions of dollars of grant money. If you're like me, you'd still like to build your own robot with all the power of huge research labs but with minimal costs.

Ever since I left FIRST robotics, I've wanted to build my own robot from scratch. However, I quickly discovered how difficult that was. FIRST has laid out the kits you can use and constrains the problem tightly for you. These two steps are honestly the most difficult parts.

In this guide, I'm constraining my robot to navigating indoor environments autonomously (flat surfaces, no ledges or stairs) and that's it (no manipulation of the environment). From this, I could constrain my kit more effectively.

Enough jabber. On with the guide!

Step 1: Hardware Is Hard: Finding the Parts

When designing this robot, I started with the components I had and attempted to build a chassis around it. Once I had something kind of working, I assessed whether my components were adequate. When I discovered they weren't, I picked new ones and tried again. One key note to make here is I only used 3D printed and off the shelf parts. No machine shop required!

This is the final list of parts I used (I wouldn't advising buying all of these at once) I've also attached a BOM (bill of materials) document for your convenience:

  • Raspberry Pi 2 model B+ (a 3 would work just as well)
  • Raspberry Pi Zero W
  • 4 Pololu Micro motors (+ brackets): https://www.pololu.com/product/997
    • I had a relatively extensive motor selection process. I used the attached tool from pololu. Originally it was written in MATLAB. I've translated it to python. Its dependencies are matplotlib and numpy if you're savvy with installing python modules with "pip"

See this guide for the types of USB cables: http://www.cablestogo.com/learning/connector-guid...

Non-robot parts

  • A USB keyboard and mouse for the raspberry pi set up
  • An HDMI display (or any display so long as you have an HDMI adapter)
  • Mini-HDMI to HDMI converter: Raspberry pi zeros don't have a regular HDMI port since they're too small. I'd highly recommend getting one of these if you're working with this tiny tiny computer.
  • 2 SD cards. Minimum 8GB. I'd recommend 16 or 32GB to be safe. These may come with your raspberry pi or they might not. The raspberry pi's in this guide use micro SD cards.

Some advise about buying parts

These parts have been accumulated over a four year time span for various other projects. But together, this equipment cost me ~$400. However, if you only bought the essentials, you could reduce it to ~$200. Most of the cost is sunk by the motors (~$80). If you find cheaper motors, beware that the motors may not be powerful enough. Try running my python script with the motor specs you find. If your robot doesn't move, this project stops in its tracks literally and figuratively.

I would start with a raspberry pi, an arduino, a battery, and maybe some motors with the motor controller. Move to the next step and, if you feel the parts are sufficient, come back to this step and order more parts. Any mechanical project has long iteration cycles.

Hand analysis and choosing your motors

There are quite a few techniques in mechanical engineering for analyzing the effectiveness of motors. For an introduction for those who haven't taken a physics class, this site has a good intro: http://hyperphysics.phy-astr.gsu.edu/hbase/torq.h...

Essentially, estimate the load (torque in this case) on your motors and pick the ones that match your power source and can overcome this load. Indoor applications need a lot less torque since the robot only needs to overcome its own weight and friction with the ground.

Step 2: Hardware Is Hard: Designing

Picture of Hardware Is Hard: Designing

This step is pretty flexible since it depends on your goals. Because of this, I will provide drawings and the final CAD files as well as the general guidelines I followed while designing the 3D printed parts. You will need Solidworks 2017 to edit the files but I have also provided STLs of the final design in the "Export" folder.

Constrain your system

Given my goal of creating a robot that navigates flat indoor environments only, my design might be more limited than what you want to build. However, constraints like these really help a project along. No single system can navigate and solve the universe's problems on its own.

Some issues I encountered

The posted drawings are of my original designs for this robot. As you can see it's very different from the final product. A few issues came up. I discovered the stepper motors from adafruit were not powerful enough, if I wanted to make the multi-shelf design, I could only have one or two shelves if I wanted to fit all the components. I also discovered the raspberry pi zero w wasn't powerful enough for running localization. I also decided to only use a camera and no other sensors. Once I took these things into consideration, I had way less parts to confuse myself with. As mentioned in the previous step, my battery regulates 5 volts at 3 amps. There were many times I exceeded this limit and everything just shut off. Since I didn't have access to better batteries, I was forced to regulate my power usage in software (i.e. don't suddenly change the motor's direction on a dime).

Some takeaways

  • Make sure you choose your power source wisely. If you can't power your stuff, game over.
  • Make sure your motors have enough torque and they don't overload your power source
  • Make sure your drive train can handle the terrain. On flat indoor surfaces, almost anything works. Outdoor robots are a whole different game.
  • Decide what sensors and components you want to mount ahead of time. Keep in mind, when creating a small robot, it's surprisingly difficult to put more than six or seven things on it
  • Determine if your main computer has enough processing power to run the software you want. For me, the raspberry pi 2 was sufficient (I considered upgrading to a 3)

Next I'll go over the specific steps I took to design and print this robot.

Step 3: Hardware Is Hard: CADing

Picture of Hardware Is Hard: CADing

Some notes

I used Solidworks 2017 thanks to the CMU book store (they sell keys for $25 if you're a student). If you don't have access to this software, tinkercad, Autodesk, or any CAD software will suffice. I mostly used simple shapes.

I won't go through every step I went through to get this design. There are plenty of tutorials and courses on the internet for that. If you're new to CAD and Solidworks, the basic principle is you draw 2D sketches and apply features such as extrudes and cuts. If you can, try downloading a CAD software and try modeling objects from your surroundings. That helped me a lot. CAD can be frustrating, but this is one of the most crucial steps since it's more difficult to fix hardware than software.

My Approach

My general approach to creating this model was to measure each component I was using with a nice set of digital calipers, model the component in Solidworks, position them generally where I wanted them in the model, and fill in the gaps with 3D printable parts. In the attached photo, I actually stacked the parts vaguely in the arrangement I wanted before modeling them. This helps with visualizing the final part while CADing. 2D projections on a screen or paper can only capture so much.

Printing my parts

In the attached zip file, there's a folder called Export. The three parts you'll want to print are:

  • Connecting Part 1.STL
  • Connecting Part 2.STL
  • Camera Mount 2.STL

PLEASE NOTE: I tolerance'd this part for my Monoprice 3D printer (0.007" spacing between contact points). This is because the printer isn't extremely precise and the plastic swells or shrinks slightly. If you're not using this printer, please change the tolerance required to make your printer have joinable parts. Print some test parts to try it out.

Designing your own parts

If you are considering building your own version of this, I'd highly recommend getting your hands on a 3D printer. Having to wait two or three days between iterations slows down the process a lot. I'd recommend the Monoprice Select Mini 3D printer. It's cheap (~$220) and produces surprisingly high quality parts. Otherwise, there are plenty of online 3D printing services such as https://www.3dhubs.com

Just know that if you print a part for the first time, it's 100% guaranteed that it won't be exactly what you want. I went through 4-5 major iterations of this design before reaching the final one and it's still not perfect. There's always something unexpected that doesn't quite suit your needs or something you forgot to add.

Step 4: Assembly: Setup the Arduino

Picture of Assembly: Setup the Arduino

Part used in this step:

  • Adafruit motor controller
  • Arduino Uno/Adafruit Metro
  • Pololu USB breakout
  • Soldering iron kit
  • Micro USB cables
  • Breadboard wires
  • Connecting Part 2.STL

After you have all your parts together and printed, it's time to assemble the robot and start setting up the software. If you design your own parts, you've created your own build instructions! These instructions are mostly setting up the electrical components and mounting them to the parts I designed. As a disclaimer, I constructed this robot long before making this guide, so forgive me if the pictures aren't the best. I wasn't tempted to completely deconstruct my robot.

Set up the motor controller

Adafruit has a great guide on setting up their motor controller: https://learn.adafruit.com/adafruit-motor-shield-... Read the "Install Headers & Terminals" and "Using DC Motors" to get started. You'll need to solder wires onto the micro motors. I used long wires from the jumper cable box (give yourself more slack than you think you need. You can always cut it off later). Don't screw the wires into the motor controller yet. It'll make attaching the 3D printed parts easier.

Solder the components

I used this motor controller because it has a protoboard built into it. I used this mini protoboard for soldering the pololu USB breakout. I connected the pin labelled "VBUS" to the Arduino's "VIN" pin. My apologies for the poor photographs.

The resistors you see in the photos are voltage dividers. I attempted to measure the battery's charge by measuring its voltage. Unfortunately since it's a USB phone charger, it regulates its output to 5V no matter how full it is. There's a wealth of knowledge on voltage dividers and measuring battery capacity on the internet.

Step 5: Assembly: ​Screw on the Motors

Picture of Assembly: ​Screw on the Motors

Parts used in this step:

  • Pololu micro motors and hubs
  • Connecting Part 1.STL
  • Connecting Part 2.STL
  • Mecanum wheels

Attach the pololu micro motor mounts and motors to Connecting Part 1 (the bottom piece). The mounts should come with screws that fit into the holes. The rear motor screws should be more difficult than the front (one of the improvements for the next iteration). With a small philips head screwdriver and some wiggling, you should be able to put all the screws on.

The micro motors from pololu have motor hubs you can buy. These white plastic pieces cover the gear boxes. The front of the motor should be flush with the plastic.

With a 1/16" hex driver, screw the Mecanum wheels onto the micro motor shafts.

Step 6: Assembly: Attach the Boards

Picture of Assembly: Attach the Boards

Parts used in this step:

  • Four 3-56 screws
  • Arduino Uno/Adafruit Metro
  • Connecting Part 2.STL
  • Raspberry Pi 2 B+
  • Raspberry Pi Zero W

Slot Connecting Part 1 and 2 together. I didn't have much trouble sliding it on (as compared to the second to last iteration). It's press fit so it won't slide off unless strongly encouraged.

Using the 3-56 screws, attach the Arduino Uno or Adafruit Metro to Connecting Part 2 (the top piece). There should be four feet holes that the Adafruit Metro can slot into. Adafruit Metros come with attachable rubber feet now. The screw holes are a bit sketchy on this part (yet another improvement).

Slot the motor wires into the nearest screw terminal on the motor controller. I hooked the motors up in the following order:

  • Top left - M2
  • Top right - M1
  • Bottom left - M3
  • Bottom right - M4

Test the motors as you attach them to make sure the polarity isn't reversed.

The Raspberry Pi Zero W attaches to the backside of the "Naboris" sign. The Raspberry Pi 2 B+ sits on of the four "legs" sticking out the top. The holes for pi 2 should be self threading (as in when you drive a screw into them, the screw cuts threads into the plastic, creating a firm hold). I missed some of the pi's pins when designing this part so make sure not to screw it on too hard.

Step 7: Assembly: Attach the Camera Turret and Lights

Picture of Assembly: Attach the Camera Turret and Lights

Parts used in this step:

  • Camera turret
  • Camera Mount 2.STL
  • Breadboard wires
  • Pi camera V1.3 + the cable
  • Neopixel ring
  • Soldering iron
  • Four 5-32 screws

Camera turret

When attaching the turret, the holes aren't perfectly aligned. There's a chamfer on the holes so they have a better time sliding into place. Put two screws at diagonal holes on the turret. Put the other two screws in at angles and they should slide into place. I managed to make the screws flush with the camera turret's surface without too much difficulty.

Neopixel ring

I soldered the three wires in the locations that best suited the wires and the part I had printed out. Check out the attached photos and Adafruit's Überguide on Neopixels: https://learn.adafruit.com/adafruit-neopixel-uber...

I attached the data output (the top-most wire) to pin 6 on the Arduino and PWR (bottom right) to the battery's 5V not the Arduino's 5V. Solder the PWR wire in parallel with the motors.

Pi Camera

Use the four 5-32 screws to attach the camera to the printed Camera Mount 2.STL part. The camera isn't centered, but that isn't an issue. I might change this in a future iteration. Attach the camera cable to the pi camera and the Raspberry Pi 2 B+. The printed part should slot nicely onto the camera turret. Use two zip ties to attach the Neopixel ring (make sure the cable is threaded behind the ring).

Step 8: Assembly: Final Attachments

Picture of Assembly: Final Attachments

Parts used in this step:

  • Micro USB cables
  • X-Mini speaker
  • Alfa wifi usb adapter
  • Ourlink wifi usb adapter
  • USB OTG adapter

Lastly, attach the Alfa wifi usb adapter as it appears in the photo. Plug the Arduino and the Ourlink wifi usb adapter into the Raspberry Pi 2 B+.

The X-Mini was somewhat of a last minute addition. I created a bird nest with its long cable. I zip tied the cable down and plugged it into the speaker. This makes for a surprisingly secure connection.

If you made it to this step, congrats and thank you for sticking with this guide for so long! Bar the software, you have a fully able robotics platform in your hands. ?

Step 9: Developer Environment: Initial Raspberry Pi Set Up

The next few steps will be setting up the raspberry pi's to be the ideal software development environment. No one likes clunky software and slow testing times after all!

For these steps, you'll need an HDMI display (or any display so long as you have an HDMI adapter), a USB keyboard, a USB mouse, a mini HDMI to HDMI adapter, a stable wifi connection, and another computer with an SD card slot (so much stuff I know...).

Once you've accessory'd up, follow this guide for setting up your raspberry pi: https://www.raspberrypi.org/help/noobs-setup/2/

It should be the same for all raspberry pi's. Once you get a boot screen, select Raspbian (it'll probably be the only option). Let that sit for ~30-60 minutes. Do this for both raspberry pi's. If you have trouble, google any error messages you see or comment here. I'll do my best to answer.

Step 10: Developer Environment: Raspberry Pi Zero W As an Access Point

We're going to turn a raspberry pi zero into, essentially, a wifi router. It will broadcast a wifi network that any device can connect to so long as you know the password. The raspberry pi zero will search the area for other connectable networks. If it finds a network it knows about, the pi zero will redirect any traffic requested from its own access point to the connected wifi network.

Attached is a guide on how to set this up. This guide has been the culmination of many forum pages and hours of web searches. This is not guaranteed to work since this system is a little jank and by no means completely secure. I wouldn't put personally significant data on a raspberry pi anyway.

Please download the attached PDF for the guide.

What does this mean?

The router you have at home broadcasts itself under a name which you can see in your wifi settings. When you connected to it for the first time, you entered a magic password and bam you had internet (unless your cable company sucks). We'll be recreating that here on the raspberry pi except the pi doesn't have a landline connection to the internet.

Why would anyone want this?

This is because we'll be using our raspberry pi "headless" or without a display.

Most of the time when you're developing on a raspberry pi you have a display. It's extremely difficult to develop without a display or some means of quick feedback. Since this a mobile robot, it's not likely you'll have a display attached to this thing. It's also annoying having to unplug and replug display cables every time you want to make a change. In addition, when you plug a device into a raspberry pi, you're at a significant risk of causing a power surge. This cases the raspberry pi to reboot. This happened a lot while I was setting these devices up.

SSH

There are ways of connecting to a raspberry pi without a display which we will be taking advantage of. The most popular command line interface is SSH. You may have used it before. It essentially lets you log into another computer via the internet or your local router.

If SSH exists, then why bother setting this up? Wouldn't having the ability to log in via wifi be enough? It would if you were expecting to stay on the same network. What if you wanted to try this robot in another building or outside? If you move to another location, you'd have to know the password and wifi name ahead of time or trust that they have a display you can use.

By making the raspberry pi an access point, we can create a wifi network that's guaranteed to be available. Thus, we can connect to our robot and develop from anywhere!

Connecting to the internet

But that's not quite enough for me. I need the internet when I develop. I need to look at forums, documentation, videos, etc. I could switch between networks but that's a real pain. So, I made my access point into a wifi redirector. Any internet requests I make get pushed through the raspberry pi to whatever router its connected to. I get all the normal features of a wifi router in combination with the reliability of having a network to connect to my robot through.

Why two pi's?

This can be done with one raspberry pi, but I personally like to separate the two functionalities of wifi router and robot controller. The raspberry pi doesn't need to worry about handling a network while its doing hardcore computer vision computations.

Please download and read the guide to set this up.

Step 11: Developer Environment: File Transfer

Picture of Developer Environment: File Transfer

Once you have both raspberry pi up and running with the access point (which might take a while), it's time to finish off the development environment.

Connect your personal computer and the Raspberry Pi 2 B+ to the new access point. You'll have to check the Raspberry Pi 2 B+'s ip address with the external display. This should be a one time thing. You can do this by typing "ifconfig" into the terminal. For unix based operating systems (macOS and Linux), log into your raspberry pi with "ssh pi@<insert your ip address>". Replace pi if you changed your username. For windows you'll want to install PuTTY.

SFTP

Since we're working headless (without a display), we'll mostly be working with the command line. Working the command is fine but I'll quickly abandon it for a graphically interface. Using a protocol called SFTP, we can edit file remotely. For Mac, I use Transmit from Panic. It's not free but it's one of the best out there. There are plenty of free SFTP clients out there. You'll need to search around. PuTTY already comes with SFTP functionality. I haven't used SFTP on linux or ubuntu systems, but FileZilla is free.

VNC

If this isn't graphical enough, you'll want to look into VNC. This service allows the raspberry pi to stream its desktop over the internet. This guide from adafruit is great: https://learn.adafruit.com/adafruit-raspberry-pi-... It's pretty laggy but it works.

Awesome! So now we can access our raspberry pi from anywhere with our access point, control it via SSH, see its files with STFP, and control the desktop with VNC.

Step 12: Conclusion

Congrats!! If you made it this far, then you've successfully created a robotics platform. There are many others like it, but this one is yours.

The next step is software development. This step is really up to you and what you want to do with the robot. You could develop in ROS and write your own ROS nodes for this robot, write your own code from scratch, or you can use the code I wrote for this robot's setup.

The code I developed for this robot is available here: https://github.com/Woz4tetra/Naboris

I'll be adding comments, tutorials, and install guides as I continue to work on this robot. Pop by that site for the code. If you have git installed, you can download it by typing: "git clone https://github.com/Woz4tetra/Naboris". It will create a folder called Naboris and populate it with the repository.

Comments

ChinoPisces (author)2017-06-07

Video?

Woz4tetra (author)ChinoPisces2017-06-18

Video's been posted! Share with your friends: https://www.youtube.com/watch?v=e5529u88afc

Woz4tetra (author)ChinoPisces2017-06-07

It's on the way!

DIY Hacks and How Tos (author)2017-06-03

Cool robot. I like the ring light feature. I haven't seen that on a robot camera before.