Install Script!

There is now a script to install everything.
First install Ubuntu.

Then just run this script:

and you are done!

To update your code just run the same script again and it will pull down and compile anything new without erasing custom settings.

After that you’ll just need to edit the config files as noted by the script,
and then set up your Propeller Code for Arlobot.

As always, please let me know if you find any problems!

Merge!

I’ve been working in a dev branch of my Arlobot code for a long time now, and today I marged it into Master so there is a lot of new code there.
Hopefully it all works, but obviously I am the only one who tests it before you do.

A few of changes are:
1. I made a bunch of changes to the C code that runs on the Propeller Activity Board to try to make it more generic. You will have to answer a bunch of questions and comment out a bunch of #define lines to “customize” it for your setup, but hopefully it will be easy to do.
2. The automatic explore function should be functional now.
3. I’ve added some more smarts to the propeller_node.py script to make it more robust and give myself more ability to adjsut settings while the robot is running.
4. I added my code to make use of an XV11 “Neato” vacuum cleaner scanner that I bought.

At this point I’m also working a lot in my Metatron package to createa a nice GUI for interacting with the robot’s functions.

My next step once this is working will be to create a new setup routine that includes installing both the ArloBot and Metatron packages and bringing up the entire package.
It should work as either a monolithic “application” with a GUI or as a nifty set of convenience scripts along with access to all of the basic ROS functions that you can use on a TurtleBot. Whichever you prefer.

So head over to https://github.com/chrisl8/ArloBot and check out the commit history to see what is new and give the new code a spin if you are brave!
Or wait a week or two to see if anyone else discovers a major bug! 🙂

Wiring Photos

Please see this Parallax forum post for a good diagram of how to wire the HB-25’s, motors and encoders:
http://forums.parallax.com/showthread.php/153150-Arlo-Batteries-and-Charging?p=1234335&viewfull=1#post1234335

It is worth looking at the ActivityBot setup too: http://learn.parallax.com/activitybot/electrical-connections which explains the server connections, which are also used for the motor controllers, and the use of pull-up resistors.

Also this thread has some good information on the the “ActivityBot”code that I use to control the motors:
http://forums.parallax.com/showthread.php/152636-Run-ActivityBot-C-Code-in-the-Arlo!

TODO: Write up a full wiring description with diagrams of every component . . .

The rest is just a collection of high resolution photos of the robot’s wiring. I hope these may help others imagine how to wire their ArloBot!

Click on each image for a full resolution version. Download them as you see fit and if you build a wiring diagram of your own please let me link to it! Or I can host it of course if you want.

FullyWired

DSC_8165

DSC_8164

DSC_8163

DSC_8162

DSC_8161

DSC_8160

DSC_8159

DSC_8158

DSC_8157

DSC_8156

DSC_8155

DSC_8154

DSC_8153

DSC_8152

DSC_8151

 

Prevent Propeller Activity Board from running on USB Power

If you have an Arlo Power Distribution Board, and you frequently leave your Activity Board plugged into a notebook computer when you turn off the Arlo Power Distribution Board, you may have noticed that the Activity Board stays on.
Furthermore, anything connected to the 5 volt supply on the Arlo Power Distribution Board stays on also.
The Activity Board is getting power from the USB port on the computer, and then it is passing this 5 volts on to other devices via the barrel connector.

Parallax has kindly provided instructions on how to prevent the Activity Board from drawing any power from the USB Port:
http://forums.parallax.com/showthread.php/160774-quot-Reverse-quot-power-flow-in-Arlo-Power-Supply?p=1326069&viewfull=1#post1326069

I performed both steps 7 and 8 to ensure that mine would not run from USB power under any circumstances, because I never want it to do that on my robot.

Now your Activity Board will turn off when you turn off the Arlo Power Distribution Board and everything else will shut off too!

This also opens up the possibility to power cycle the Activity Board with the USB Relay Board. I have not done this yet, because I knew it was pointless as long as the Activity Board would continue to draw power from the USB port. I might try it now though, because sometimes I think a power cycle would be the most reliable way to force a reset on the Activity Board. All it would take is running the 6.5 volt wire through one of the relays before going to the Activity Board.

Use a Raspberry Pi and Asterisk to turn an old Alarm System into a Home Monitor

If you have an old alarm system that is capable of calling a remote monitoring station, and you want to just turn it into a fancy “chime” instead that can notify your phone.
Please note that this is not reliable enough to be considered a “security” system. But if you don’t even use your alarm system anymore, or quit paying for the monitoring service, this will add some fun features!

The orginal source for the Raspberry Pi intall of Asterisk is here: http://nerdvittles.com/?p=3026

Here is how I connected it all to my old alarm system.

First, you need an alarm system.
I have an old GE Interlogix Simon 3 Wireless Security System, so these instructions work for this model.
Simon
In theory this will work with any alarm system that can dial out to a monitoring station via plain old telephone lines.
The secret sauce is in a file called app_alarmreceiver.c You may have to replace and/or edit and recompile this file to get it to work with your particular system.
I will cover that later.

Second, you need either a dedicated Linux computer to run Asterisk, or a Virtual Machine running Asterisk 24×7,
or a Raspberry Pi B or better! You do not need the latest model, just make sure it has 512 MB of memory and it will work.

Third, you need an “ATA”. An ATA is a box with phone jacks and an Ethernet connection. It allows you to plug a normal phone into it and receive dial tone, accept touch tones and send them over TCP/IP to anywhere in the world.
I am using the Grandstream GS-HT702 Handytone 2-FXS Port Analog Telephone Adapter from Amazon, so if you want one that is tested for this, use that.
You do not need two phone jacks though, so you could use a cheaper single jack model. I got the two jack model so that I could experiment with other uses on the second line.

Note that I will not be covering any setup of external VoIP providers or anything here, but in theory you can do all kinds of things with this box once it is done.

Install PBX In A Flash:
Download incrediblepi-3.6.tar.gz from http://sourceforge.net/projects/pbxinaflash/files/IncrediblePi-1.x-Debian-6/
NOTE: Watch the versions! I am still on version 3.6!
Version 3.7 *MIGHT* work, but I am sure nothing newer will!
The 3.11.x versions use Asterisk 11 and those did not work for me. Only try them if you are interested in experimenting, otherwise stick with 3.6.

Extract the files (I used the 7zip 64 bit install on my Windows box)
Use win32 Disk Imager to write the image to the SD card
Put the SD into my Raspberry Pi, plug in TV, and Ethernet and power and watch it boot up!
The Pi should read its IP address out loud if you have speakers or headphones plugged into it!

NOTE: When I say “ssh” you can use PuTTY if you are on Windows.

ssh root@ip-address-of-your-pi

Password: raspberry

Hit Enter to let it start downloading updates.

Set new root password!

Set Timezone (America, Chicago) or whatever yours is.

Run:
/root/update-my-pi
(should show nothing to update, since it just did this on login)

Run:
raspi-config

This will give you lots of fun options, use this anytime, but now is best for some things.

Select: “expand_rootfs”
Then go to “Finish” when it is done, and tell it “Yes” to reboot.

ssh root@ip-address-of-your-pi
ctrl-cl to skip updates

# For some reason the install doesn’t include vi!
apt-get update
# This only updates the local package index, it doesn’t change anything, so “update” is safe.
# Without it you get errors about not finding stuff because it has been moved around
apt-get install vim

vi /etc/profile.d/helloworld.sh
#/root/update-my-pi
# So it doesn’t ask you to update on every login!
echo “/usr/local/sbin/status”
# So it doesn’t run this and clog up logins

IP & Hostname:
IF you want to set up a static IP on the Raspberry PI do this.
Your ATA will need to talk to the Pi, so it is good if the IP does not change, although it can use a hostname.
Also, using Google’s DNS servers works well for me.
Source: http://pbxinaflash.com/community/index.php?threads/static-ip-for-raspberry-pi.14364/

I’m using 192.168.1.1 here, but use an address that works on your network!

vi /etc/network/interfaces
iface eth0 inet dhcp
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
gateway 192.168.1.254
dns-nameservers 8.8.8.8 8.8.4.4
Set IP to 192.168.7.2 in Router’s Static config.

To change the hostname to “Pi” run:
hostname Pi

vi /etc/hosts
# replace all instances of incrediblepbx with Pi
vi /etc/hostname
# Replace incrediblepbx with Pi
shutdown -r now

Open up iptables for SSH from outside:
add this line to /etc/network/iptables and reboot:
iptables -A INPUT -p tcp -m multiport –dports 22 -j ACCEPT
Run this to list active entries:
iptables –list

Put http://192.168.1.1/ (or whatever IP you chose) in your web browser and click on FreePBX Administration

Username: admin Password: admin

1. Changing FreePBX admin Password and Default Email.
From the main FreePBX GUI,
click Admin => Administrators.
Click on admin user in the far-right column.
Enter a new Password and click Submit Changes button.
Then click the Apply Config button.
Next, set your default email address at the bottom of Settings -> General Settings.
Repeat the procedure above to save your entry.

Set up 701 for use with ATA
Applications->Extensions->701
secret: 13n38j (You may want to set your own, just keep it consistent!)
dtmfmode: In band audio
allow: ulaw
permit: 192.168.1.0/255.255.255.0
submit
apply config

Set up your ATA:
The HT702 manual is here: http://www.grandstream.com/products/ht_series/ht701/documents/ht70x_usermanual_english.pdf

Hook it up to the network, power and plug in a phone.
pick up the handset and dial ***
then dial 02
It should announce its IP address.

Enter it into a web browser.
The default password is “admin” for admin use.

First thing is to get the latest firmware!

Download latest firmware from http://www.grandstream.com/support/firmware

NOTE: I am on firmware version 1.0.4.11 I have found that sometimesa version does not work, so once you get it working, don’t upgrade it again unless you have time to debug!

Upload firmware through Advanced Settings:

INSTRUCTIONS FOR UPLOAD FROM LOCAL DIRECTORY:
1- Download the firmware file from Grandstream web site
2- Unzip it and copy the file in to a folder in your PC
3- From the HT70X web interface (Advanced Settings page) you can browse your hard drive and select the folder you previously saved the file (ht70xfw.bin)
4- Click “Upload Firmware” and wait few minutes until the new program is loaded.

Note: Always check the status page to see that the program version has changed.

To reset to defaults:
Basic Settings->Reset Type: Full Reset->Reset

Basic Settings:
Set a new End User Password and record it.
Time Zone: GMT -06:00 (Central Time) or whatever yours is.
(If this doesn’t account for Daylight Savings, then define a custom one)
“Update”

Advanced Settings:
Set an Admin Password and record it.
#Firmware Server Path: firmware.grandstream.com
CHECK – Always Skip the Firmware Check
Syslog Server: 192.168.1.1 (Your Pi’s IP address)
Syslog Level: INFO
“Update”

FXS PORT1
Primary SIP Server: 192.168.1.1 (Your Pi IP Address)
SIP User ID: 701
Authenticate ID: 701
Authenticate Password: 13n38j
Name: 701
“Update”

FXS PORT2
Primary SIP Server: 192.168.1.1 (Your Pi IP Address)
SIP User ID: 702
Authenticate ID: 702
Authenticate Password: 13n38j
Name: 702
Preferred DTMF method: Set all 3 to “In-audio”
Offhook Auto-Dial: 85764 (This makes it VERY fast, because it dials immediately, just set the alarm to dial a #, which is normally redial, but the ATA forgets the last number dialed every time you reset it, also, this means that if you don’t know how to change the number that your alarm system dials out, it doesn’t matter, the ATA will dial for it and ignore whatever phone number the alarm system tries to dial!)
“Apply”
Reboot

Direct incoming calls to extension 701:
Connectivity -> Inbound Routes -> Default.
In the Set Destination section of the form, change the target to Extensions and then select 701 from the list.
Then clickSubmit and Apply Config.

Set up Extension 702 on Asterisk for Alarm System:
http://www.freepbx.org/forum/freepbx/users/alarmreceiver-howto-get-it-to-work

Edit /etc/asterisk/extensions_custom.conf and add this at the bottom
; Alarmreceiver
[custom-myalarmreceiver]
exten => s,1,NoOp(Alarm received)
exten => s,n,System(/etc/asterisk/PreAlarmNote)
exten => s,n,Answer
exten => s,n,AlarmReceiver
exten => s,n,Hangup

NOTE: /etc/asterisk/PreAlarmNote is a script I wrote that sends me a PushOver notice and plays a sound from the Pi whenever an alarm notice comes in.

In FreePBX go to Admin, Custom Destinations

Enter in Custom Destination this custom-myalarmreceiver,s,1
In Description enter Alarm Receiver
Submit Changes
Apply Config

Set up Alarm Receiver:
Download:
alarmreceiver.conf
AlarmCommand
PreAlarmNote
from my GitHub Repository,
and put them in /etc/asterisk
cd /etc/asterisk
chmod +x AlarmCommand
chmod +x PreAlarmNote
mkdir /eventArchive/
chmod a+w /eventArchive/

PreAlarmNote and AlarmCommand are stripped down copies of my scripts.
You need to open them and edit them to match your system and do things for you. As they are now, they will not do anything.

In Web admin interface:
Applications->Extensions->Add Extension
Generic SIP, Submit
User Extension: 702
Display Name: 702
secret: 13n38j
dtmfmode: In band audio
nat: Yes
Submit
Click on 702 again
allow: ulaw
permit: 192.168.1.0/255.255.255.0
submit
apply config

Applications->Misc Applications
Add
Description: Alarm Call Center
Feature Code: 85764
Destination: Custom Destinations:Alarm Receiver
“Submit Changes”
“Apply Config”

Recompile Asterisk with with new alarmreceiver:
This is the important part that made my system work.
It is possible that YOUR system does not need this step,
or that you will have to make more or different changes to app_alarmreceiver.c for your particular system.

Reference: http://www.pbxinaflash.com/community/index.php?threads/dropped-calls-after-15-minutes.7604/#post-82159

amportal stop
cd /usr/src
wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-1.8.17.0.tar.gz
tar zxvf asterisk-1.8.17.0.tar.gz
rm asterisk-1.8.17.0.tar.gz
mv asterisk-1.8.17.0 asterisk

cd asterisk/apps/
mv app_alarmreceiver.c /root/ORIGapp_alarmreceiver.c

Download:
app_alarmreceiver.c
from my GitHub Repository,
and put it here in /usr/src/asterisk/apps/

cd ..
make clean
./configure
# Make your putty window full screen, or you will get an error about minimum terminal size
make menuselect
# Select “res_config_mysql”, “app_mysql” and “cdr_mysql” from the top item “Add-ons”
make
make install

NOTE: This output was seen, but it did not appear to cause any problems:
Your Asterisk modules directory, located at
/usr/lib/asterisk/modules
contains modules that were not installed by this
version of Asterisk. Please ensure that these
modules are compatible with this version before
attempting to run Asterisk.
app_flite.so
cdr_sqlite.so
chan_mgcp.so
res_config_sqlite.so
WARNING WARNING WARNING

amportal start

You can go to the Linux prompt and run
asterisk -vvvvvvvvvvr
to get a an Asterisk command line and watch the log

That is it! Plug in your alarm system’s phone line to the ATA port 2, arm it, and see if it starts talking to your Asterisk install and making things happen!
Note that most systems only dials out when they are ARMED, so you have to leave it armed for this to work. The two options are to disable all sirens and use it as a sort of “chime” system, or only get notices when the system is armed. Either way, you have to arm it to test it now.

FreePBX Module Updates
FreePBX will tell you about modules that need to be updated, and you should do these.
Be ware of anything that says it will update Asterisk though,
and don’t install anything new unless you know what you are doing.
But the updates for the installed modules should be installed for security issues.

Below are some issues that came about as I updated things:

Ensure FreePBX Admin page works:
Reference: http://www.freepbx.org/forum/beta-program-issues/menus-are-not-displaying-correctly-image-attached
Sometimes the menu at the top of the FrePBX Admin pages looses all of its buttons and turns into small text with small text drop downs that are very hard to use, not to mention a lot of other bits of the page are malformed.
Do this to prevent that:
http://192.168.1.1/ (or whatever your IP is)
FreePBX Administration
Settings->Advanced Settings
Disable Mainstyle CSS Compression: True
Apply

That should fix/prevent that problem.

udptl_custom.conf
Reference: http://www.freepbx.org/forum/general-help/help-please-symlink-from-modules-failed
I started getting this error in FreePBX after some updates:

retrieve_conf failed to sym link:
/etc/asterisk/udptl.conf from core/etc (Already exists, not a link)
This can result in FATAL failures to your PBX. If the target file exists and not identical, the symlink will not occur and you should rename the target file to allow the automatic sym link to occur and remove this error, unless this is an intentional customization.
Added 4 minutes ago
(retrieve_conf.SYMLINK)

The solution appears to be:

mv /etc/asterisk/udptl.conf /etc/asterisk/udptl_custom.conf

Then do an “apply changes” in the FreePBX admin (you may have to fiddle with something to get the “apply changes” to appear.

Note that the /etc/asterisk/udptl.conf should now be a link to /var/www/html/admin/modules/core/etc/udptl.conf and that includes udptl_custom.conf

Default ARI Admin password Used
Somewhere in the FreePBX updates we got an “ARI Password” in amportal.conf
I *think* that this is used for the “Voicemail & Recordings (ARI)” page.

root@Pi:~# grep ARI /etc/amportal.conf
ARI_ADMIN_USERNAME=
ARI_ADMIN_PASSWORD=ari_password

But DO NOT change it here, instead go to Settings->Advanced Settings and set it!

Default Asterisk Manager Password Used
You are using the default Asterisk Manager password that is widely known, you should set a secure password
Added 94 weeks, 5 days, 23 hours, 48 minutes ago
(core.AMPMGRPASS)

This you should be able to set in Settings->Advanced Settings
I set it to the same ad the FreePBX password from LastPass (admin/)

Test Obstacle Detection without Leaving my Chair

All of the bright colors are the graphical representation of ROS’s “Local Planner”. That is the part of the program that decides how to get from one place to another.

Making a map is one thing, but finding your way around an ever changing sea of obstacles is another.

Here I am simply testing whether the planner is detecting, marking and then clearing obstacles.

Stairs!

DalekVsStairs
A couple of weeks ago it finally happened, my precious robot drive right down the stairs. Well, it drove over the threshold and tumbled down.

Amazingly the damage was limited.
The front caster was bent badly and no longer functioned properly.
A few bolts and screws were bent.
A few of the PING/IR sensor holders were shattered.

Thanks to Parallax though, my robot is already back in shape and on to new things!

Cliff Avoidance
I’ve done two things to reduce the possibility of this hazard.
1. I have a home brewed “home monitor” system that emails me when a door is opened.
So I added a sensor to the basement door and set it to place a file on the ArloBot’s hard drive. The safty_controller will monitor for this file and stop the robot if it exists:
It would be nice, though, to build a dedicated device for this purpose, because my home monitor system is very slow. I need something that can run on battery power and send messages over Wifi.

2. I added cliff sensors:
IR sensors works better for this than PING sensors because of their very narrow focus, which is what you want when you are just watching the floor.
Cliff Sensor
If you look carefully you can see that there is one on each side of the front PING/IR sensor. They are simply taped to the surface with double sided 3M Auto Body Molding Tape so that it aims down slightly.

And I have modified the code that runs on the Propeller board to stop the robot if the distance on this sensor is too great:

I have not done very much testing with this yet. The biggest issue is that the robot needs to be aware of the cliff soon enough to stop and reverse before falling off of the edge. A sensor on the bottom pointing straight down is very reliable, but the robot will tumble before it has time to stop. By setting the sensor at an angle this gives more time to stop.

ROS <remap> tag

This shouldn’t be rocket science, but up until just this moment I never comprehended the <remap> tag.

However, due to a problem I was having I had the opportunity to track it down, in action, and also to see the result.

First, this is documented, but the documentation never made sense to me: http://wiki.ros.org/roslaunch/XML/remap

or for more confusion: http://wiki.ros.org/Remapping%20Arguments

So here is my explanation to myself:

If you look inside of my ArloBot propellerbot_node.py you will see that it listens to the topic cmd_vel:

rospy.Subscriber("cmd_vel", Twist, self._handle_velocity_command)

However, if you start up my ArloBot:

roslaunch arlobot_bringup minimal.launch --screen

and start driving it around with TeleOp:

roslaunch arlobot_teleop keyboard_teleop.launch

You will see NO cmd_vel topic!

In ROS there is so much going on that it is easy to chalk things up to “magic”, but when you actually write the Python code to listen to cmd_vel, and there is no cmd_vel topic, no amount of “magic” suffices. Obviously something is wrong!

The solution is <remap>, and the lesson is that this tag works on an individual node at the time we run it!

We called propeller_node.py with minimal.launch, and it includes the file mobile_base.launch.xml:

<include file=”$(find arlobot_bringup)/launch/mobile_base.launch.xml” />

and inside of this file is the “magic”:

The exciting line is this one:

<remap from="cmd_vel" to="mobile_base/commands/velocity" />

This says that when the node we are calling (propellerbot_node.py) tries to subscribe to “cmd_vel” give it “mobile_base/commands/velocity” instead!

Mystery solved, because that topic does exist!

Furthermore, if you run or create a node that sends data on the “cmd_vel” topic, nobody is going to listen to it!

I don’t know why these remaps were so confusing to me before. Probably because a lot of them are only used in the TurtleBot code that I borrowed from. Only when I had a clear situation where a third party node was talking on cmd_vel and nothing was happening did I realize that there IS NO cmd_vel topic in my normal setup, and yet it worked.

Question 2:

If I have a launch file that I want to start, and I know the node it starts will broadcast to a topic I don’t listen to, either directly or due to remapping, what can I do about this?

Based on this now less confusing documentation of argument remapping: http://wiki.ros.org/Remapping%20Arguments

You can also use remap when you run a node directly, so that this:

(This is based on a command from the great ROS by Example INDIGO book that you really should buy!)

rosrun rbx1_nav calibrate_linear.py

becomes:

rosrun rbx1_nav calibrate_linear.py cmd_vel:=mobile_base/commands/velocity

Because I know from experience (run the command and then run “rostopic list” to get that same experience) that this node broadcasts on “cmd_vel”, and from my previous discussion based on launch files and the output of “rostopic list” that my robot’s controller node listens on mobile_base/sensors/core

ROS by Example for Indigo

One of the motivations for building my robot was to be able to follow the tutorials and examples made for and written by ROS experts.

One of the best resources for ROS is ROS By Example – Volume 1 by R. Patrick Goebel. I’ve been waiting though for the “Indigo” version to be complete, because working with documents aimed at older versions of ROS is frustrating and time consuming.

Now it is here!
http://www.pirobot.org/wordpress/indigo-revision-of-ros-by-example-volume-1-available/

I plan to purchase this book and work through it with my ArloBot to become more familiar with ROS and learn to add more functionality to my robot.