This project was for Oregon State University’s ROB 421/521 class on robots. The overall goal of the project was to be able to build a cornhole robot that could launch bean bags into a hole, along with document progress in a website.
The main people who worked on this project were Sridhar Thiagarajan, Ashwin Vinoo and Miles Young. Sridhar and Ashwin focused on the mechanical parts and some of the electrical work, while Miles focused on the electronics, code, wireless teleoperation, microcontrollers, and sensors.
An example of this robot in action is available as a gif (9 MiB file) or on Google Drive.
This demo is about a general view that the operator could see when operating the robot.
The launching demo goes through each step of the beanbag launching setup automatically.
The sonar demo shows when objects are detected in the front (red), back (yellow), both (orange), and no objects (blue) for the operator.
Downloads used for this project: Ubuntu Mate 16.04 for ROS and Raspbian for drivers.
Raspberry Pi Setup
Note: Only for 3B+ (source).
Copy the following files from Raspbian to Ubuntu Mate:
- For Booting: copy bootcode.bin, fixup.dat, start.elf, bcm2710-rpi-3-b-plus.dtb and kernel7.img
- also start_cd.elf, fixup_x.dat, and start_x.dat
- For keyboard/mouse: copy /lib/modules/4.9.80-v7+ (root partition)
- For network: copy the contents of /lib/firmware/brcm/ (root partition)
If you want to boot from USB:
- edit cmdline.txt, change root=/dev/mmcblk0p2 to root=/dev/sda2 (boot partition)
- edit etc/fstab, change/dev/mmcblk0p2 to sda2 and /dev/mmcblk0p1 to sda1 (root partition)
Copying files to SD card
unxz --keep <file>
extracts the xz file to be able to be used.To copy: use
fdisk -l <file.img>
<br >
- get boot sector size (512 bytes, etc)
- get value of offset (size * start, ex 512 * 2048)
To then be able to mount the image (to copy files to it), use
sudo mkdir /media/path/img
andsudo mount -o loop,offset=<offset> <file.img> /media/path/img
. For example, the starting offset could be 2048*512 = 1048576, and the ending offset of 131072*512 = 67108864.To be able to copy files, use
cp
orsudo cp <files...> /media/path/img/path...
in the source folder to be able to copy multiple files. If copying folders,cp -r
needs to be used.To unmount the image, use
sudo umount /media/path/img/
.The process to copy an image to be able to be used first requires using
fdisk -l
to print all of the disks. Then find the /dev/mmcblk*** partition (could be /dev/sd** if USB) to then use the commanddd bs=4M if=<file.img> of=/dev/*** status=progress
.Warning: using the wrong /dev/*** could destroy your computer/OS (dd is sometimes called disk destroyer). This process may also take a bit of time.
Ubuntu Mate setup
Turn off auto updates System -> administration -> software & updates -> updates tab -> automatically check for updates: never
Software
To uninstall software, first open a terminal (
ctrl + alt + t
). The commandsapt list --installed
lists all of the installed packages,sudo apt autoremove
removes packages not needed by other packages.sudo apt update
updates the package sources and is needed before updating packages withsudo apt upgrade
,sudo apt install <package>
installs a package, andsudo apt remove <package>
removes a package.The packages that can be removed include: sudo apt purge youtube-dl youtube-dlg thunderbird libreoffice-core libreoffice-common minecraft-pi brasero transmission-common deja-dup atril hexchat account-plugin-* galculator gnome-orca shotwell-common plymouth snapd squeak-*
Other changes to have a faster desktop include installing the lxde windows manager with
sudo apt install lxde lxde-common lxsession-logout lxdm
and removingsudo apt purge mate mate-optimus
. Then, useupdate-alternatives --config x-session-manager
to change the default windows manager.To be able to update the time, the command
sudo date -s "YYYY-MM-DD HH:MM:SS"
updates the current time. This value is only updated while the Rasberry Pi is on due to it not having a real time clock to keep track of the time while off.Another nice tool is readlink, which is able to get the location of a file with
readlink -f <file>
.Bootloader
To edit the boot options, do
sudo nano /boot/cmdline.txt
, and remove “quiet splash” and “plymouth.ignore-serial-consoles” to show things loading instead of an animation.Also necessary is the ability to access the camera and ssh, which can be changed by running the command
sudo raspi-config
and in interfacing options -> turn on camera and ssh.One option is to reduce the CPU frequency to reduce the power of the system, which can be done with
sudo nano /boot/config.txt
and editing the line toset arm_freq=1200
.If there is a problem of a long shutdown (due to cups-browsed), the command
sudo systemctl stop cups-browsed.service && sudo systemctl disable cups-browsed.service
can disable the service.Finally, to be able to decrease the default timeout, do
sudo nano /etc/systemd/system.conf
and on the lineDefaultTimeout{Start/Stop}Sec=90s
change it to 10s.ROS setup
Instructions from the ROS wiki Setup sources.list:
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
Then set up the keys used to verify the software with
sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
. An alternate hkp server that can be used would be hkp://pgp.mit.edu:80 or hkp://keyserver.ubuntu.com:80Then update the sources with
sudo apt-get update
. Finally, install the Desktop-Full (ROS, rqt, rviz, robot-generic libraries, 2D/3D simulators, navigation and 2D/3D perception) withsudo apt-get install ros-kinetic-desktop-full
.Then install ROSARIA, which is located at github.com/reedhedges/AriaCoda. This code can be installed with
make install
. If using catkin_make, use catkin_make -j 1 to limit the number of threads or else the system becomes very slowWifi Hotspot setup
To be able to SSH into the Raspberry Pi when having a Wifi hotspot mode, it is helpful to know the IP address, which can be found using
hostname -I
. Then, on a different computer connected on the same network (or using the setup.sh script below), it is possible to SSH into the Raspberry Pi withssh ros-p3@10.x.x.1
, where 10.x.x.1 is the ip address (which can be different). If wanting to also have GUI access, usessh -X
to allow the program to send graphics to a linux computer.To decrease the amount of services running, use
sudo raspi-config
, and inboot options
enablecli boot
. To start a GUI in command line mode, usestartx
.To be able to autostart the wifi, edit the file
sudo nano /etc/rc.local
and addbash /home/<username>/setup.sh &
where username is the current username.&
allows the script to run in the background. Next, create the filenano /home/<username>/setup.sh
, and add the following lines:
!#/bin/bash nmcli dev wifi hotspot ifname wlan0 ssid <ssid> password "<password>"
.
Finally, allow the file to be executed withchmod +x /home/<username>/setup.sh
.ROS
For the USB serial connection, first run the command
sudo usermod -a -G dialout $USER
, which allows access to usb serial output with the following rule:
Open the file (sudo nano /etc/udev/rules.d/50-myusb.rules
) and add:
KERNEL=="ttyUSB[0-9]*",MODE="0666" KERNEL=="ttyACM[0-9]*",MODE="0666" SUBSYSTEM=="tty",DRIVERS="pl2303",SYMLINK+="tty_robot" SUBSYSTEM=="tty",DRIVERS="ch341-uart",SYMLINK+="tty_arduino"
The SYMLINK lines allow for a system link even if the ttyUSB change after a reboot. Use
udevadm info --attribute-walk --path=/dev/ttyUSB*
to get this information from the parent class of the device.To start ROS, use
roscore &
androsrun rosaria RosAria _port:=/dev/ttyUSB0 &
, which could be in a bash script with sleep timers.Streaming video
First, check the camera with
vcgencmd get_camera
, and then run the commandraspistill -o file.jpg
to be able to test the camera. To view the image (even over ssh when usingssh -X
), usexdg-open file.jpg
.The command (on the raspberry pi)
raspivid -fps 20 -w 1280 -h 720 -vf -hf -t 0 -o - | nc -l -p 5000
starts the video streaming, and can be placed in a bash script. Then, the command (on the sshing computer)netcat <ip address> 5000 | mplayer -fps 60 -cache 512 -
can be used to view the image, where theis the ip address that the computer is ssh'ed to.