Skip to content

Instantly share code, notes, and snippets.

@hdamron17
Last active August 29, 2019 19:05
Show Gist options
  • Save hdamron17/320bca52cda00603ada65f50bc0c0c9f to your computer and use it in GitHub Desktop.
Save hdamron17/320bca52cda00603ada65f50bc0c0c9f to your computer and use it in GitHub Desktop.
Instructions for setting up Raspberry Pi uboats for AFRL research project

Uboat Software Installation Guide

Goal

This guide is meant to aid in installation of Ubuntu and ROS for the Raspberry Pi Uboats

Instructions

  • Clone image of Ubuntu Mate 16.04; uncompress with gz and copy to disk using dd
  • Boot into Pi and follow installation sequence
  • Use username pi and the lab password
  • Use hostname without hyphens (underscores okay) - preferably cl1, cl2, ...
  • Enable ssh: sudo systemctl enable ssh.service
  • Ensure internet is connected (nmtui makes this simple)
  • Install ROS Kinetic: sudo apt-get install ros-kinetic-desktop
  • Install dependencies: sudo apt-get install libi2c-dev ros-kinetic-camera-info-manager-py ntpdate (#TODO possibly also python-smbus for 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.bash and cd ~/catkin_ws && catkin_make
  • In /etc/init.d/cooperation_localization.sh:
  • Modify line to sudo ntpdate ntpserver from whatever server is being used (ntpserver will be defined in /etc/hosts)
  • For testing on wifi, add line after ifconfig down/up lines: sudo dhclient
  • Change line beginning with current_client_subnet_ip= to have a filter head -n1 | before the sed filter (To make sure only one ip is used) (#TODO better wording and make sure it always works)
  • In /etc/hosts other submarines:
  • Add line <server ip> ntpserver where 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.0 can 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 ntp on date server (may be one of the drones; unnecessary if using remote ntp server like time.google.com)
  • Give ntpserver a static ip: <static ip> from above
  • Use raspi-config Interfacing 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 line pi ALL=(ALL) NOPASSWD:ALL to 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@tty1 and add lines:
[Service]
ExecStart=
ExecStart=-/sbin/agetty -a pi --noclear %I $TERM
  • In file /boot/cmdline.txt remove quiet splash to make bootup process more informative

Calibrating minimu9_ahrs

  • Install scipy to python2: pip install scipy (may require installing libatlas-base-dev via apt-get)
  • roscd minimu9_ahrs to cd into the installed version
  • Modify src/minimu9_ahrs.cpp so that there is a command line argument for number of iterations and make that count apply when mode is raw (in function streamRawValues)
    • It's nice to have infinite by default so nothing old breaks
  • Modify minimu9-ahrs-calibrate so that instead of calling installed scripts it calls rosrun minimu9_ahrs minimu9_ahrs with the command line argument of number of iterations; make same change for minimu9-ahrs-calibrator in case it does not call from that directory; remove head -n2000 because the count is already specified; add arg -b/dev/i2c-1 to the calibrate script
  • Create file ~/.minimu9_ahrs containing only i2c-bus=/dev/i2c-1
  • Run rosrun minimu9_ahrs minimu9-ahrs-calibrate and 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

Calibrating Camera

  • 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-get install ros-kinetic-camera-calibration
  • Use the script bag2tar.sh to 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}

TODO

  • Fix network unreachable error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment