This guide is meant to aid in installation of Ubuntu and ROS for the Raspberry Pi Uboats
- Clone image of Ubuntu Mate 16.04; uncompress with
gzand copy to disk usingdd - Boot into Pi and follow installation sequence
- Use username
piand the lab password - Use hostname without hyphens (underscores okay) - preferably cl1, cl2, ...
- Enable ssh:
sudo systemctl enable ssh.service - Ensure internet is connected (
nmtuimakes this simple) - Install ROS Kinetic:
sudo apt-get install ros-kinetic-desktop
- Follow setup instructions from http://wiki.ros.org/kinetic/Installation/Ubuntu
- Follow workspace instructions from http://wiki.ros.org/catkin/Tutorials/create_a_workspace
mkdir ~/bagfiles(This is where rosbag entries will be placed)- Add line to
~/.bashrc:source ~/catkin_ws/devel/setup.bash(#TODO Is this necessary?)
- Install dependencies:
sudo apt-get install libi2c-dev ros-kinetic-camera-info-manager-py ntpdate(#TODO possibly alsopython-smbusfor depth module) - Copy from repository:
~/.profile~/mac_addresses.sh~/.minimu9_ahrs_cal~/catkin_ws/src(recursive)/etc/driftNodeStartupROS.sh/etc/init.d/coorperative_localization.sh/etc/network/interfaces->/etc/network/network.adhoc(#TODO Is this the correct file from the original?)
source ~/catkin_ws/devel/setup.bashandcd ~/catkin_ws && catkin_make- In
/etc/init.d/cooperation_localization.sh:
- Modify line to
sudo ntpdate ntpserverfrom whatever server is being used (ntpserver will be defined in/etc/hosts) - For testing on wifi, add line after
ifconfigdown/up lines:sudo dhclient - Change line beginning with
current_client_subnet_ip=to have a filterhead -n1 |before thesedfilter (To make sure only one ip is used) (#TODO better wording and make sure it always works)
- In
/etc/hostsother submarines:
- Add line
<server ip> ntpserverwhere the two items are separated by a tab and<server ip>is the ip address of your ntp server (for testing on wifi, time.google.com:216.239.35.0can be used as<server ip>)
- Optional local ntp server (can be replaced by a remote ntp server like time.google.com)
- Install and set up as service
ntpon date server (may be one of the drones; unnecessary if using remote ntp server like time.google.com) - Give
ntpservera static ip:<static ip>from above
- Use
raspi-configInterfacing Options to enable Camera and I2C - Disable xserver
- Run
sudo systemctl set-default multi-user.target
- Remove sudo password requirement
- Make backup of sudoers:
sudo cp /etc/sudoers /etc/sudoers.bak - Using
sudo visudo, append the linepi ALL=(ALL) NOPASSWD:ALLto allow pi to execute all sudo commands without password
- Enable autologin of user pi on tty1 (must be run while tty1 is up)
- Run
sudo systemctl edit getty@tty1and add lines:
[Service]
ExecStart=
ExecStart=-/sbin/agetty -a pi --noclear %I $TERM
- In file
/boot/cmdline.txtremovequiet splashto make bootup process more informative
- Install scipy to python2:
pip install scipy(may require installinglibatlas-base-devvia apt-get)- The alternative is to copy the simpler
minimu9-ahrs-calibratorscript from https://github.com/DavidEGrayson/minimu9-ahrs.git (The newer script just does raw mins and maxes instead of using scipy and funky math)
- The alternative is to copy the simpler
roscd minimu9_ahrsto cd into the installed version- Modify
src/minimu9_ahrs.cppso that there is a command line argument for number of iterations and make that count apply when mode is raw (in functionstreamRawValues)- It's nice to have infinite by default so nothing old breaks
- Modify
minimu9-ahrs-calibrateso that instead of calling installed scripts it callsrosrun minimu9_ahrs minimu9_ahrswith the command line argument of number of iterations; make same change forminimu9-ahrs-calibratorin case it does not call from that directory; removehead -n2000because the count is already specified; add arg-b/dev/i2c-1to the calibrate script - Create file
~/.minimu9_ahrscontaining onlyi2c-bus=/dev/i2c-1 - Run
rosrun minimu9_ahrs minimu9-ahrs-calibrateand the rest is trivial - Or, we could simply clone a new version from the git repository mentioned above and install it separately from ros then copy the calibration file over to a ros-suitable location
- #TODO Add the code which uses the calibration to add a calibrated magnetometer reading
- Use the onboard camera to take a recording showing various angles of a checkerboard sized 10x7 (these numbers count the number of intersections on of squares so this would have 11x8 squares) with squares 0.02 meters wide. (These numbers can easily be changed in the script)
- Using
apt-getinstallros-kinetic-camera-calibration - Use the script
bag2tar.shto create a yaml calibration file from the bag (this may take a while for longer bags)- #TODO Add the option to delete every nth frame for quicker calculation
#! /bin/sh
# bag2yaml.sh
if [ "$#" -ne 3 ]; then
echo "Usage: bag2yaml.sh <bag file> <node name> <output yaml>";
exit 1;
fi
tmptar=tmp.tar
./bag2tar.sh ${1} ${2} ${tmptar}
./tar2yaml.sh ${tmptar} ${3}
rm ${tmptar}#! /bin/sh
# bag2tar.sh
if [ "$#" -ne 3 ]; then
echo "Usage: bag2tar.sh <bag file> <node name> <output tar file>";
exit 1;
fi
tmp=tmp
cur=$(pwd)
mkdir ${tmp}
rosrun bag_tools extract_images ${tmp} jpg /${2}/camera/image_raw/compressed $1
rename 's/_[0-9]+//' ${tmp}/*
rename 's/image/left/' ${tmp}/*
cd ${tmp}
tar -cf ${cur}/${3} *
cd ${cur}
rm ${tmp}/*; rmdir ${tmp}#! /bin/sh
# tar2yaml.sh
if [ "$#" -ne 2 ]; then
echo "Usage: tar2yaml.sh <tar file> <output yaml>";
exit 1;
fi
ost=ost.ini
rosrun camera_calibration tarfile_calibration.py $1 --mono -s10x7 -q0.02 > ${ost}
rosrun camera_calibration_parsers convert ${ost} $2
rm ${ost}- Fix network unreachable error