Introduction: CupBot - 3D Printed Robotics Platform

About: Born as a farmer, studied electronics ,working as a Consultant and a 3D printing enthusiast by night..

Here is a great weekend robotics projects that you can undertake called CupBots based on the Raspberry Pi and the BeagleBone Black which are credit card sized computers and also includes 3D Printing ..

Most of the 3D printed parts are common for both the version of the CupBot and are based on earlier version of the CupBot that I posted about a couple of weeks back that you can find at CupBots - 3D Printed Robotic platform for Arduino and Raspberry Pi , which contains an Arduino obstacle avoiding bot and Raspberry Pi Keyboard version.Which mean using the common 3D printed Cup Holder base and the wheels you have make 4 version of the robot as shown in the video below.

You will also need a large cup which you will use to protect the electronic components , hence the name CupBot. In my case, I am using aVenti Cup from Starbucks which i saved after enjoying my ice coffee.

By following this instructable you can make first two version of the CupBot which are controlled by a web app using Python-Flask, as shown in the video's below.

#1 Raspberry Pi version of the CupBot- using a Web App Controller

#2 CupBot - BeagleBone black version

In addition, follow the steps in the instructable "CupBots - 3D Printed Robotic platform" to make

#3 Arduino Uno based Obstacle avoiding CupBot.

#4 Raspberry Pi Keyboard controlled CupBot


Step 1: Things You'll Need to Make CupBot

Here are the components you'll need to complete the build

  • 2 Gear Motors
  • 2 Wheels
  • 4 AA battery holder - try and get one with an on/off switch so that you can easily switch power to the motor drivers.
  • 4 AA battery
  • Power bank to power the Raspberry Pi/BeagleBone
  • Machine screws and nuts , I picked mine up at the local hardware store called Home Depot
    • 4-40X1 - 5 numbers (used hold the motors to the 3D printed parts )
    • 4-40 X3/4 - 7 numbers(used to hold the 3D printed parts and electronic components)
    • 4-40 nuts - 12 numbers

In addition you will need the following tools

  • Scissors
  • Zip ties to hold the Battery holders to the 3D printed part
  • Screw driver
  • Soldering Iron and solder if you don't have wire soldered to the motors

Step 2: 3D Print the Common Base and Back Wheel

Download the STL files attached and using 3D printing software slice and 3D print the files.If you don't have a 3D printer handy you can use one at your local maker club or library or use a 3D printing service like 3D hubs(use the pint using 3D hubs button).

If you plan to print with PLA ,here are suggested slicer setting for all the 3D printed

  • Layer height 0.3
  • Infill - 20 %
  • Nozzle Temperature - 200-210 C

Printing all the parts should take about 2 hours and is dependent on your 3D printer settings

Step 3: 3D Printing Wheels (Optional)

To 3D print 2 wheels , just in case you have not bought the wheels that go with your gear motors,download the STL files attached .If you don't have a 3D printer handy you can use one at your local maker club or library or use a 3D printing service like 3D hubs(use the pint using 3D hubs button).

If you plan to print with PLA ,here are suggested slicer setting for all the 3D printed

  • Layer height 0.2
  • Infill - 30 %
  • Nozzle Temperature - 200-210 C

Step 4: Polishing the 3D Printing (Optional)

Now if you want to impress your friends by adding shine to you robot, spray paint the 3D printed parts Rust-oleum painters touch.

Once you spay the part you will have to leave then to dry for at-least about 4 hours, this is an optional step, but is a great way to finish 3D printed part Rust-oleum painters touch - Gloss clear version from my local hardware store (Home depot) for about 6.99 $

In addition I also found with two coats it made the part more flexible and stronger.

Step 5: CupBot - Raspberry Pi Version With Web App Controller

Here is a great way to show off, your Raspberry Pi/python programing skills by making Python-Flask web App controlled CupBot.

Flask is a micro framework for Python based on Werkzeug, Jinja 2 ..For more info about flask refer to

http://flask.pocoo.org/

You can modify the code and add more functionality to CupBot , say add a new button to run the CupBot in a loop for 30 seconds..

Step 6: Electronic Components You Will Need

Here are the list of electronic compenets you will need to complete the build for the Raspberry Pi CupBot

  • Raspberry Pi B+/ 2
  • Adafruit DC & Stepper Motor HAT for Raspberry Pi
  • Wireless Keyboard for the Pi
  • Wi-Fi USB adapter
  • Micro SD card
  • 4 AA batteries and a battery holder
  • Power bank to power the Pi

Step 7: Preparing the SD Card

If you have just bought a Raspberry Pi, download Raspbian which is operating system for the Raspberry Pi from the link

https://www.raspberrypi.org/downloads/

Follow the installation link to prepare your SD card from the img you just downloaded

https://www.raspberrypi.org/documentation/installa...

Insert the SD card in the slot of the Pi and boot the Pi up, follow a couple of tutorial to get familiar with the Pi, follow the link below

https://www.raspberrypi.org/resources/learn/

Now for the Adafruit Capacitive Touch HAT to talk to the Raspberry Pi , you will have to enable I2C on your Raspberry PI. In you Terminal window on the Pi type in the following command

pi@raspberrypi ~ $ sudo raspi-config

and enable I2C in the advance options

pi@raspberrypi ~ $sudo reboot

Now to install python-smbus and to run the commands below you will have have the Pi connected to the Internet , basically run the Pi headless using a Wi-Fi dongle. Or if you have another Raspberry Pi B,B+or 2 that is already connected to the Modem/router via a LAN cable, pop the SD card and run the commands below.

pi@raspberrypi ~ $sudo apt-get install python-smbus

type Y to accept the changes, and then install the i2c-tools using the command below

pi@raspberrypi ~ $sudo apt-get install i2c-tools

Follow the learning guide to download and setup the required software for the DC motor PI hat

https://learn.adafruit.com/adafruit-dc-and-stepper...

Step 8: Adding Motors and Electronic to the 3D Printed Parts

Once you done with setting up the SD card with the latest version of Raspbian and enable I2C, it is now time to add the motors to the 3D printed parts using the 4-40X1 screws and nuts as shown in the first picture above.

If you don't have breadboarding wire soldered to the motors you may want to do that first before adding the Motors to the 3D printed part.

Now attach the wheels and the 3D printed wheels to the parts

Also add the Raspberry Pi with the DC motor Hat mounted to the base holder.

Finally add the parts for the battery holder as shown in the picture above and secure the power bank and the battery holder with Zip ties.

Step 9: Setting Up the Python-Flask(to Host the Web App)

Flask is a microframework for Python based on Werkzeug, Jinja 2.

To install flask you will need to install python-pip using

pi@raspberrypi ~ $ sudo apt-get install python-pip

once done you can now use pip to install flask

pi@raspberrypi ~ $ sudo pip install flask

Step 10: Testing Flask Web App

Since flask is a microframework, which means you should be able to get it up an running for a quick test out if your setup was successful

To do this, save the following python program to a hello.py file

<p>from flask import Flask<br>app = Flask(__name__)</p><p>@app.route("/")
def hello():
    return "CupBot Raspberry Pi web app version!"</p><p>if __name__ == "__main__":
    app.run()</p>

And to start the webserver run the hello.py file using

pi@raspberrypi ~ $ python hello.py

Now to open the website on you laptop/computer browser use thehttp://ipaddress-of-pi (in my case http://192.168.0.27)

Step 11: Copy the Python Code Attached

Now if you are able to open the hello world webpage on you Laptop,Tablet or Phone you are ready to download the CupBotPi.zip , extract it and upload it to the pi using Filezilla.Or if you have SSH'ed into the Pi create the directories and copy paste the code for index.html in the template folder using the nano editor.In addition, you will also have to copy controller.py code outside the template folder as shown in the second screenshot above.

Then run the controller.py program in the folder

pi@raspberrypi ~/CupBotPi $ sudo python controller.py

Now access the website hosted on your Pi using http://ipaddress-of-Pi:800 which in my case in http://ipaddress-of-Pi:800 as shown in the screen shot of the table above.

Step 12: Setting Up the Web Server to Start on Reboot

Now if you are planing to take the CupBot to your living room, still in the Wifi range of your router you will want to setup the program to run automatically when the Pi boots up, using

pi@raspberrypi ~ $ sudo crontab -e

Once the file opens add the following line at the end of the file and hit ctrl+X to save.

@reboot     /usr/bin/python /home/pi/CupBotPi/controller.py &

once done reboot your Pi using

pi@raspberrypi ~ $ sudo reboot

And in a couple of mins you should be able to test the drive by loading the website on your Phone/tablet browser as shown in the picture.

Step 13: CupBot - BeagleBone WebApp Version

For more info on the BeagleBone Black refer to the link below

http://beagleboard.org/support/bone101

Step 14: 3D Print BeagleBone and L298N Holder

Download the STL files attached and using 3D printing software slice and 3D print the files.If you don't have a 3D printer handy you can use one at your local maker club or library or use a 3D printing service like 3D hubs(use the pint using 3D hubs button).

Note: For the STL files for the base, back wheel and battery holder refer Step 2.. In addition you can also print 2 wheels , STL attached in step 2 , just in case you did not buy wheels when you bought the motors.

If you plan to print with PLA ,here are suggested slicer setting for all the 3D printed

  • Layer height 0.2
  • Infill - 20 %
  • Nozzle Temperature - 200-210 C

Printing all the part should take about 1 hours and is dependent on your 3D printer settings

Step 15: Electronic Components You Will Need

To complete the BeagleBone version of the CupBot you will need

  • BeagleBone Black RevC with the latest version of Debain installed
  • Motor Controller - L298N - dual H-Bridge, which is used to control the two motors
  • Male to Female Jumper wire
  • Breadboarding wire

Step 16: Connecting the L298N to the BeagleBone Black

Connect the Motors to the motor ports on the L298N using a screw driver

Using male to female breadboarding wire make the following connection from the L298N to the BeagleBone black

enA on the L298N to P9_21 on the Beaglebone

  • in1 to P9_15
  • in2 to P9_16
  • enB to P8_13
  • in3 to P8_15
  • in4 to P8_16
  • and also connect the GND from the L298N to GND pin that is ,P9_1 on the beaglebone

For details on the pin out for the BeagleBone black RevC refer to the link below

http://beagleboard.org/Support/bone101/#headers

Step 17: SSH Into the BeagleBone

To SSH into the BeagleBone you will have to first figure out the ip address of your Beaglebone.

Connect a LAN cable to you Beaglebone and connect it to your computer you should see a network share drive on you computer.

Now install the drivers for your computer based on the operating system you are using by following the link at

https://beagleboard.org/getting-started#step2

Once done click the link below to launch the cloud9 IDE

http://192.168.7.2

For more info refer to the link at

https://beagleboard.org/getting-started#step3

Once you in the cloud9 IDE , find the terminal tab and type in the following command to get the Ip address of your ethernet connection.

root@beaglebone:/var/lib/cloud9# ifconfig

make a note of your ip address for eth0 as shown in the screenshot above.

once you are done you should be able to SSH into your BeagleBone from your laptop via WiFi and you can also reboot your BeagleBone and connects it power directly to the power outlet.

ssh root@beagleboneIPAddress

Note: if you prefer using Cloud9 IDE terminal tab,you can go ahead and do so to type in the commands in all the steps below.I like to use SSH , it is just a personal preference

Step 18: Setting Up Flask on BeagleBone

Flask is a microframework for Python based on Werkzeug, Jinja 2.

To install flask you will need to install python-pip using

root@beaglebone ~ $apt-get install python-pip

once done you can now use pip to install flask

root@beaglebone~ $ sudo pip install flask

To run a quick test to check if you create a flask simple flask App , create a new file called

root@beaglebone~ $nano flasktwo.py

Copy paste the code below and paste it into the nano editor

<p>from flask import Flask<br>app = Flask(__name__)</p><p>@app.route("/")
def hello():
    return "CupBot! 3D printed robotic platform!"</p><p>if __name__ == "__main__":
    app.run(host='0.0.0.0', port=88, debug=True)</p>

Control+X to save and then run the python program using the following command

root@beaglebone~ $python flasktwo.py

and open your browser and type in http://ipaddressBeagleBone:88

Step 19: Copying the Code Attached and Testing

Now if you are able to open the hello world webpage on you Laptop,Tablet or Phone you are ready to download the CupBotPi.zip , extract it and upload it to the pi using Filezilla.Or if you have SSH'ed into the Pi create the directories and copy paste the code for index.html in the template folder using the nano editor.In addition, you will also have to copy controllerBB.py code outside the template folder as shown in the second screenshot above.

Then run the controllerBB.py program in the folder

root@beaglebone~ $ ~/cupbot $ sudo python controllerBB.py

Now access the website hosted on your Pi using http://ipaddress-of-BeagleBone:88 and run a quick test as shown in the video above to check the direction of the motor.

Note : If you the motors moving the opposite direction swap the wires on the L298N.

Step 20: Setting Up WiFi Moudle

Connect the USB Wifi module before you connect the Beaglebone to power/your computer

Run the following commands when you are conneted via the LAN cable/ or you can use the cloud 9 IDE if you dont have a LAN cable handy First check if the USB wifi moudle is detected

root@beaglebone:~# lsusb

Here is the link for the Wifi module i am using - https://www.adafruit.com/products/814

If your WiFi module is detected run the following command
root@beaglebone:~#apt-get install ntp ntpdate

root@beaglebone:~#apt-get install wpasupplicant

root@beaglebone:~#nano /etc/network/interfaces

here add your Wifi name and password as shown in the screenshot above, you will also have to add the line to auto detect your wifi, that is -- allow-hotplug wlan0

Now restart the wifi interface using

root@beaglebone:~#ifup wlan0

run ifconfig and make a note of you ip address

Now shutdown the BeagleBone ,
root@beaglebone:~#shutdown -h now

disconnect the LAN cable and you should be good to SSH into the Pi using the WiFi ip address

Step 21: Putting Motors, Electronic Components and 3D Printed Parts Together

It is now time to add the L298N to the 3D printed parts using the 4-40X1 screws and nuts as shown in the first picture above and then add the BeagleBone behind the 3D printed part.

If you don't have breadboarding wire soldered to the motors you may want to do that first before adding the motors to the 3D printed part.

Now attach the wheels/3D printed wheels to the motors.

Finally add the parts for the battery holder as shown in the picture above and secure the power bank and the battery holder with Zip ties.

Add a Cup on top of the electronic components to protect the components from damage and power up CupBot and take it for a spin ...

Sensors Contest 2016

Participated in the
Sensors Contest 2016

3D Printing Contest 2016

Participated in the
3D Printing Contest 2016

Robotics Contest 2016

Participated in the
Robotics Contest 2016