ROS Robot

Introduction

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.

Robot Images

UI/Schematic

UI demo

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.

Schematic

Software Setup

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:

If you want to boot from USB:

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 >

To then be able to mount the image (to copy files to it), use sudo mkdir /media/path/img and sudo 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 or sudo 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 command dd 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 commands apt 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 with sudo apt upgrade, sudo apt install <package> installs a package, and sudo 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 removing sudo apt purge mate mate-optimus. Then, use update-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 to set 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 line DefaultTimeout{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:80

Then 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) with sudo 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 slow

Wifi 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 with ssh 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, use ssh -X to allow the program to send graphics to a linux computer.

To decrease the amount of services running, use sudo raspi-config, and in boot options enable cli boot. To start a GUI in command line mode, use startx.

To be able to autostart the wifi, edit the file sudo nano /etc/rc.local and add bash /home/<username>/setup.sh & where username is the current username. & allows the script to run in the background. Next, create the file nano /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 with chmod +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 & and rosrun 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 command raspistill -o file.jpg to be able to test the camera. To view the image (even over ssh when using ssh -X), use xdg-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 the is the ip address that the computer is ssh'ed to.