The brain of your robot is the Raspberry Pi, it connects everything to LetsRobot.tv and runs all of the hardware. The first step is to set up your Pi.
Start by flashing an 8GB microSD card on your PC or Mac. You will need a micro SD card reader, or an adapter and a standard SD card reader.
For these instructions we are using the non GUI (Graphical User Interface) and instead setting things up using the command line. The reason for this is so that you begin to familiarize yourself with programming and navigating the brain of your robot this way. There are many ways to do this part but learning to navigate the terminal and command line will be important for your learning process.
If it is your first time with a Raspberry Pi you should connect an HDMI monitor and keyboard as well as power the Pi with a quality micro USB cord with a power supply that is providing 5V and at least 2.0 amps. The official Raspberry Pi power supply provides 5V 2.5 amps.
Raspberry Pi Power Requirements
One of the major issues most robot builders come across is poor quality USB Power packs and USB cables. Many batteries will not actually provide the amperage they say they are rated for. The Raspberry Pi should optimally be run at a steady 5V 2.4amps.
Common Raspberry Pi Commands
Welcome to Linux, here are the basics of understanding common commands
Enter raspi-config by entering the following at the command prompt:
Commands line prompts
The above format will be used whenever there is a command to enter at the command line prompt. Simply copy and paste this into the command line prompt.
Setup Locale, Timezone, and Wifi Country
As soon as you start raspi-config it will prompt you to set these.
This is very important as others can break into your network simply by using your robot as the gateway.
If that fails to connect try these instructions.
Add your wifi SSID and Password
You will want to be able to connect to your robot using your computer (if for no other reason to copy and paste the command line instructions to avoid typos)
You may want to also enable I2C here if you plan on using the Adafruit Motor Hat
Exit the Raspi-config and reboot
To exit use your right arrow key to move and select <Back> , hit enter.
Then do the same thing to select the <Finish>
Type the following into the command prompt:
When you reboot to the command line your IP address should be shown in the last few messages before the login prompt. Write it down.
Open the Terminal program on your PC or Mac.
Then enter your login:
username: pi password: the new password you just set
You can now copy and paste all of the commands below into the terminal instead of typing them arduously line by line.
sudo apt-get update
Make sure you don’t get any errors in the console when doing the step below. If you have an issue, you can run this line again, and that will usually fix it!
sudo apt-get install ffmpeg python-serial python-dev libgnutls28-dev espeak python-smbus python-pip git
Download the Let’s Robot / Run My Robot software from our github
git clone https://github.com/runmyrobot/runmyrobot
Go into the /runmyrobot directory
sudo python -m pip install -r requirements.txt
Load LetsRobot.tv and select sign up / log in on the upper right of the page.
Login or create an account
Navigate to your profile and click + Add a new Robot!
Now edit your new robot.
Fill out the Name and Description, then select the recommended resolution (if using the C920).
Enter a Stream Key and BE SURE TO SAVE
Write this down, you'll need it!
Write this down also.
Choose File Button
Click this to upload a picture of your robot.
Click this after you upload a picture of your robot.
Robot Page Link
This link will allow you to access your robot page if it is set to private.
Robot Setup Page Link
Bookmark this for a quick way to get back here.
Your robot's display name.
A small description that appears below your robot name
Sorry this feature is not enabled
Sorry this feature is not enabled
640 x 480 - Lowest resolution setting common for cheaper webcams
768 x 432 - Recommended mainly for the C920 Logitech webcam
1280 x 720 - Not recommended as it usually doesn't work with most webcams.
This is your private key that will be added in your start_robot file later and will connect your send_video.py script to your LetsRobot.tv profile. Keep this private for security.
Streamlabs Donation Widget Url
Add your Streamlabs info for donations through Streamlabs. This is optional.
Your robot will be listed publicly or available only using your Robot Page Link.
Allows anonymous users to control your robot.
Filters some profanity
Connects your robot to all the other robots chat or keeps your robot users chatting only on your robot(s).
show exclusive control button
Sorry this feature is not enabled
Turns on/off the trigger for TTS on your robot.
Turns on/off the mic on your robot
Enables only you to be able to control your robot.
Enables additional function or features buttons on the robot control user interface.
Save Robot Settings
DON'T FORGET TO SAVE!!!!!
Back on the Pi once you have accessed it by SSH again, copy the start_robot script to your home directory.
cp ~/runmyrobot/scripts/start_robot ~
You will need to edit start_robot in order to sync it with your robot:
Once you open it up, it will look something like this:
#!/bin/bash # suggested use for this: # (1) Put in the id's for your robot, YOURROBOTID and YOURCAMERAID # (2) use sudo to create a crontab entry: @reboot /bin/bash /home/pi/start_robot cd /home/pi/runmyrobot nohup scripts/repeat_start python controller.py YOURROBOTID &> /dev/null & nohup scripts/repeat_start python send_video.py YOURCAMERAID 0 &> /dev/null &
You are using the linux text editor "nano". It does not recognize your mouse so you will need to use your arrow keys to navigate with the cursor.
To Save: Cntrl + O Then Press Enter
To Exit: Cntrl + X
You will need to replace “YOURROBOTID” and “YOURCAMERAID” with the numbers generated from the site for your robot. You also need to add your stream key. If you haven’t done that step, go to your letsrobot.tv profile and add a robot (Be sure to click the SAVE button).
Move your cursor to the bottom and delete/backspace everything in this file. Copy and Paste the following:
#!/bin/bash # suggested use for this: # (1) Put in the id's for your robot, YOURROBOTID and YOURCAMERAID # (2) use sudo to create a crontab entry: @reboot /bin/bash /home/pi/start_robot # cd /home/pi/runmyrobot nohup scripts/repeat_start python controller.py YOURROBOTID --type none --filter-url-tts --tts-volume 80 --female --voice 1 &> /dev/null & nohup scripts/repeat_start python send_video.py YOURCAMERAID 0 --stream-key YOURSTREAMKEY --audio-device-name C920 --pipe-audio --mic-channels 2 &> /dev/null &
This has all the arguments (--ARGUMENT <variable>) to set up the a bot with the C920 camera with onboard stereo mic and the USB speaker. This disables the motor controller. You'll change the --type <argument> to the correct motor controller or serial input command.
In order to exit the nano editor, control + x
Once you have your start_robot file filled in appropriately to have it run on startup run the following:
Note: If you accidently use the wrong editor try
EDITOR=nano crontab -e
and insert the following text at the bottom
@reboot /bin/bash /home/pi/start_robot
# Edit this file to introduce tasks to be run by cron. # # Each task to run has to be defined through a single line # indicating with different fields when the task will be run # and what command to run for the task # # To define the time you can provide concrete values for # minute (m), hour (h), day of month (dom), month (mon), # and day of week (dow) or use '*' in these fields (for 'any').# # Notice that tasks will be started based on the cron's system # daemon's notion of time and timezones. # # Output of the crontab jobs (including errors) is sent through # email to the user the crontab file belongs to (unless redirected). # # For example, you can run a backup of all your user accounts # at 5 a.m every week with: # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/ # # For more information see the manual pages of crontab(5) and cron(8) # # m h dom mon dow command @reboot /bin/bash /home/pi/start_robot
Now just plug in the Camera and USB Speaker and reboot
Hopefully you’ll hear your robot say “OK” and everything will be working!