-
Notifications
You must be signed in to change notification settings - Fork 3
Setup
This page documents the steps to get this app working on a AlphaBot.
The official user guide and assembly guide do a good job of explaining how to assemble the chassis and sensors. At the moment, this app only uses the wheel encoders, and other sensors are ignored. You don't need to connect the other sensors. Their docs call the wheel encoder 'speed tester', which I guess it is, kinda.
The bot, as supplied, has its jumpers configured to route all signals to the Arduino. We aren't using an Arduino here, so you'll have to move them over to route signals to the Pi. The jumpers are yellow in colour, and are marked '22' in the manual on page 9. You'll have to ensure that they on the right side of the column of pins, and not on the left. So, the jumpers should short all the middle (signal) pins to the pins on right (Pi). If you don't do this, the Pi will still power up and work normally, but it won't be able to control any of the hardware on the bot.
Before you screw everything together, you might want to set up the Raspberry Pi first.
This doc assumes:
- You have a Raspberry Pi (3, preferably) with a recent copy of Raspbian.
- Its WiFi is already connected to your network.
- You have
ssh
access to it.
Installation takes time, so do the following in preparation:
-
Disconnect the Pi from the rest of the bot, and power it using wall power - a USB phone charger will do the job. Don't do the setup while powered using the supplied batteries. Batteries will be drained, its voltage will drop, the Pi will brownout, and your OS will end up in a weird corrupted state. Guess how I know.
-
During the install, it might be a good idea to connect the Pi to an ethernet cable to take advantage of any possible speed improvements. The installation process seems to download the entire Internet, so any speed improvement you can get is worth it.
-
Update everything.
sudo apt-get update && sudo apt-get upgrade -y
. -
Optional, but recommended: Enable mDNS by installing avahi. mDNS will let you address your AlphaBot with a
alphabot.local
address, instead of using its IP address which can change frequently.-
sudo apt-get install avahi-daemon
. - Modify
/etc/hostname
to contain justalphabot
, or usesudo raspi-config
and modify the hostname. This is thehostname
part ofhostname.local
, so feel free to add your flair. - Add a line to your
/etc/hosts
that says127.0.1.1 alphabot
. Substitute alphabot with the hostname you chose, if you chose a different one.
If your dev machine is a Mac, you already have mDNS support on your machine. If you are using Windows or Linux, you might need to install software to use mDNS.
If you do not want to set up mDNS, you might find it useful to set up a static IP in your router for your bot. The rest of this wiki assumes that you have mDNS configured. If you don't, substitute
alphabot.local
with the bot's IP address.(Ok, I didn't want to tell you, but since you insist - the hostname I've used for my bot is
botty
, short for Botty McBotface. I conducted an imaginary Internet poll, and Botty emerged as the most popular name. I decided to stick with it.) -
-
Install node.js:
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - # security warning, of course sudo apt-get install nodejs
-
Install this app.
wget https://github.com/rakeshpai/alphabot/archive/master.zip unzip master.zip rm master.zip cd alphabot-master npm install # This will take a while
-
Optional: Set up LIRC. This lets you control the bot using the supplied remote.
sudo apt-get install lirc liblircclient-dev
- Edit
/etc/modules
to add the following lines:lirc_dev lirc_rpi gpio_in_pin=18
- Edit your
/boot/config.txt
to adddtoverlay=lirc-rpi,gpio_in_pin=18
- Modify
/etc/lirc/hardware.conf
to be as follows:# /etc/lirc/hardware.conf # # Arguments which will be used when launching lircd LIRCD_ARGS="--uinput" # Don't start lircmd even if there seems to be a good config file # START_LIRCMD=false # Don't start irexec, even if a good config file seems to exist. # START_IREXEC=false # Try to load appropriate kernel modules LOAD_MODULES=true # Run "lircd --driver=help" for a list of supported drivers. DRIVER="default" # usually /dev/lirc0 is the correct setting for systems using udev DEVICE="/dev/lirc0" MODULES="lirc_rpi" # Default configuration files for your hardware if any LIRCD_CONF="" LIRCMD_CONF=""
- Replace
/etc/lirc/lircd.conf
with the following:# Please make this file available to others # by sending it to <[email protected]> # # this config file was automatically generated # using lirc-0.9.0-pre1(default) on Tue Sep 19 19:32:37 2017 # # contributed by # # brand: CARMP3 # model no. of remote control: # devices being controlled by this remote: # begin remote name CARMP3 bits 16 flags SPACE_ENC|CONST_LENGTH eps 30 aeps 100 header 9102 4472 one 617 1625 zero 617 544 ptrail 616 repeat 9104 2204 pre_data_bits 16 pre_data 0xFF gap 108163 toggle_bit_mask 0x0 begin codes KEY_CHANNELDOWN 0xA25D KEY_CHANNEL 0x629D KEY_CHANNELUP 0xE21D KEY_PREVIOUS 0x22DD KEY_NEXT 0x02FD KEY_PLAYPAUSE 0xC23D KEY_KPMINUS 0xE01F KEY_KPPLUS 0xA857 KEY_FN 0x906F KEY_0 0x6897 KEY_1 0x30CF KEY_2 0x18E7 KEY_3 0x7A85 KEY_4 0x10EF KEY_5 0x38C7 KEY_6 0x5AA5 KEY_7 0x42BD KEY_8 0x4AB5 KEY_9 0x52AD KEY_FN_1 0x9867 KEY_FN_2 0xB04F end codes end remote
- Reboot the Pi.
sudo shutdown -r 0
.
That's it! Everything should be set up correctly.
To run the app, simply type in sudo npm start
, and go to http://alphabot.local/ in your browser.
This app already carries its development environment with it. All you need is an editor. You don't even need to run anything else. Just run the app as usual using sudo npm start
and keep that running in a terminal. Then modify files as you please, and everything else Just WorksTM. Any necessary build steps are run automatically, the app is restarted automatically, and if you made UI changes, the browser is refreshed automatically.
The rest of this is optional, and is a matter of preference. You can skip this if you have some other way of working with remote files.
During development, I like to have the files available on my local machine (as opposed to lying on the Pi), so that I can use my preferred editor on my machine to modify files. I'm using Linux as my dev machine, so I use sshfs
to mount the app folder from the Pi to my machine.
On my development machine, I type in the following:
mkdir alphabot
sshfs [email protected]:/home/pi/alphabot-master ./alphabot
This creates a local folder called alphabot
, which is used as a mount point for the alphabot-master
folder on the robot.
The remote folder is unmounted when the Pi is shutdown, or when you type in the following:
sudo fusermount -u alphabot
I'm sure similar solutions exist on Windows and Mac. Please feel free to update this doc with any steps you can provide.