[PYTHON] Install ROS and ROS module for Roomba on RaspberryPi3 and try to run it

Introduction

I installed Ubuntu-16.04, ROS Kinetic on Raspberry Pi 3 and tried running the sample.

Overview

--Installing Ubuntu-16.04 --OS initial settings --Installing ROS kinetic --Installing roomba_500_series --Package creation ――Try to move

procedure

Install Ubuntu-16.04

Download & unzip

Reference: Using Ubuntu 14.04 with Raspberry Pi 2 Reference: Burn Raspberry Pi OS image on Mac OS X-@ledsun blog

Download the Ubuntu-16.04 image (ubuntu-16.04-preinstalled-server-armhf + raspi3.img.xz) from below ARM/RaspberryPi - Ubuntu Wiki

Unzip below.

$ xz -dv ubuntu-16.04-preinstalled-server-armhf+raspi3.img.xz

SD card identification and burning

Identify the SD card with diskutil list etc. This time / dev / disk2

Burn to SD card.

$ diskutil unmountDisk /dev/disk2
$ sudo dd if=ubuntu-16.04-preinstalled-server-armhf+raspi3.img of=/dev/rdisk2 bs=1m

Connect with SSH, initial setting

Wireless LAN settings

The IP address of RPi for Roomba is assumed to be fixed at 192.168.0.1.

$ sudo apt-get install -y wpasupplicant wireless-tools linunx-firmware
$ sudo vi /etc/network/interfaces.d/wlan.cfg
$ sudo vi /etc/wpa_supplicant/wpa_supplicant.conf
$ sudo vi /etc/default/networking
$ sudo ifup wlan0

text:/etc/network/interfaces.d/wlan.cfg


auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
    address 192.168.0.1
    netmask 255.255.255.0  #In your own environment
    gateway 192.168.0.254  #Set together
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

/etc/wpa_supplicant/wpa_supplicant.conf


update_config=1
network={
	proto=WPA2
	key_mgmt=WPA-PSK
	pairwise=CCMP TKIP
	group=CCMP TKIP
	ssid="your_ssid"
	psk=**************** #See below
}

/etc/default/networking


CONFIGURTE_INTERFACES=no

** Reference ** The passphrase generation is as follows

$ sudo sh -c "wpa_passphrase your_ssid > /etc/wpa_supplicant/wpa_supplicant.conf"
# reading passphrase from stdin
pass_phrase
network={
	ssid="your_ssid"
	#psk="pass_phrase"
	psk=****************
}

ROS installation

Reference: Install ROS kinetic on Ubuntu 16.04 LTS of Raspberry Pi3 | GarretCafe

It is almost the same as Try running ROS sample easily on a virtual machine.

Time setting

$ sudo apt-get update
$ sudo apt-get install -y chrony ntpdate
$ sudo ntpdate ntp.nict.jp

Added ROS repository and public key

$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
$ wget http://packages.ros.org/ros.key -O - | sudo apt-key add -

ROS installation

$ sudo apt-get update
$ sudo apt-get install -y ros-kinetic-ros-base # No GUI tools
$ sudo rosdep init
$ rosdep update
$ echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
$ source ~/.bashrc
$ sudo apt-get install -y python-rosinstall

Workspace settings

$ source /opt/ros/kinetic/setup.bash
$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/src
$ catkin_init_workspace
$ cd ~/catkin_ws/
$ catkin_make
$ source ~/catkin_ws/devel/setup.bash

ROS preferences

$ vi ~/.bashrc
$ source ~/.bashrc

.bashrc


source /opt/ros/kinetic/setup.bash
source ~/catkin_ws/devel/setup.bash

export ROS_IP=192.168.0.1
export ROS_MASTER_URI=http://${ROS_IP}:11311
export DISPLAY=:0

alias cw='cd ~/catkin_ws'
alias cs='cd ~/catkin_ws/src'
alias cm='cd ~/catkin_ws && catkin_make'

Installation of roomba_500_series

Reference: Run Roomba with ROS (catkin compatible) --cryborg Robotics blog Reference: Catkin Super Introduction (Part 3) -Use the rosbuild package: Bouquet for Hanaoka

Repository: https://github.com/NetBUG/roomba_500_series

Once, catkin_make or catkin_make install fails, but if you run it several times, it will eventually succeed.

$ cd ~/catkin_ws/src
$ git clone https://github.com/NetBUG/cereal_port
$ git clone https://github.com/NetBUG/roomba_500_series
$ rosdep install cerial_port
$ rosdep install roomba_500_series
$ cd ~/catkin_ws
$ catkin_make
$ catkin_make install

Creating a package

Package creation

$ cd ~/catkin_ws/src
$ catkin_create_pkg roomba rospy std_msgs

Creating roslaunch files and operating programs

roscore starts without permission even if it is not described.

$ roscd roomba
$ mkdir launch
$ mkdir scripts
$ vi launch/roomba.launch
$ vi scripts/sample.py

roomba.launch


<launch>
	<node pkg="roomba_500_series" name="roomba560_node" type="roomba560_node" />
</launch>

sample.py


#!/usr/bin/env python

import rospy
from geometry_msgs.msg import Twist

rospy.init_node("sample")

pub = rospy.Publisher("cmd_vel", Twist, queue_size=10)

while not rospy.is_shutdown():
    vel  = Twist()

    direction = raw_input("f: forward, b: backward, l: left, r: right, s: stop,  q: quit > ")

    if "f" in direction:
        vel.linear.x = +0.1

    if "b" in direction:
        vel.linear.x = -0.1

    if "l" in direction:
        vel.angular.z = +1.0

    if "r" in direction:
        vel.angular.z = -1.0

    if "s" in direction:
        vel.linear.x = 0.0
        vel.angular.z = 0.0

    if "q" in direction:
        break

    print vel

    pub.publish(vel)

Give execute permission

$ roscd roomba_ctl/scripts
$ chmod 755 sample.py

catkin_make

$ cd ~/catkin_ws
$ catkin_make
$ source ~/catkin_ws/devel/setup.bash

Try to move

roslaunch

$ roslaunch roomba roomba.launch

Direct transmission of rostopic

$ export ROS_IP=<Your IP address> #Check with ifconfig
$ rostopic pub -1 cmd_vel geometry_msgs/Twist "[0, 0, 0]" "[0, 0, 0.1]" && rostopic pub -1 cmd_vel geometry_msgs/Twist "[0, 0, 0]" "[0, 0, 0]"

Or below (operate from sample.py)

$ export ROS_IP=<Your IP address> #Check with ifconfig
$ roscd roomba
$ ./sample.py

Recommended Posts

Install ROS and ROS module for Roomba on RaspberryPi3 and try to run it
How to install OpenCV on Cloud9 and run it in Python
How to install Fast.ai on Alibaba Cloud GPU and run it on Jupyter notebook
Install selenium on Mac and try it with python
Install Docker on Arch Linux and run it remotely
Install and run dropbox on Ubuntu 20.04
Install fabric on Ubuntu and try
Install and run Python3.5 + NumPy + SciPy on Windows 10
Step 2 to install Xenomai on RaspberryPi 3 model B +
(For myself) AWS_Flask_3 (Install / Run Flask on AWS)
How to install Cascade detector and how to use it
Install Python and libraries for Python on MacOS Catalina
If you try to install Python2 pip after installing Python3 pip and it is rejected
Install PyCall on Raspberry PI and try using GPIO's library for Python from Ruby
Make it easy to install the ROS2 development environment with pip install on Python venv
Until you can install blender and run it with python for the time being
Install Apache 2.4 on Ubuntu 19.10 Eoan Ermine and run CGI
How to install Git GUI and Gitk on CentOS
Compile and install MySQL-python for python2.7 on amazon linux
Install tweepy with pip and use it for API 1.1
I tried to install scrapy on Anaconda and couldn't
Try to make it using GUI and PyQt in Python
Install pyenv on MacBook Air and switch python to use
[ROS] How to write Publisher and Subscriber on one node
Install module on Anaconda (Mac)
[ROS] Install ROS (melodic) on Ubuntu (18.04)
Install Ubuntu 18.04 on MacBook Pro Touchbar model and connect to WIFI
Quickly install OpenCV 2.4 (+ python) on OS X and try the sample
How to run Jupyter and Spark on Mac with minimal settings
How to install pandas on EC2 (How to deal with MemoryError and PermissionError)
How to block ads for free on iPhone and iPad apps
Disguise the grass on GitHub and try to become an engineer.
Could not install python3.8.1 grovepi module on RaspberryPi Model 3B (solved)
Install Anaconda on Mac and upload Jupyter (IPython) notebook to Anaconda Cloud
[TensorFlow] If you want to run TensorBoard, install it with pip
Install lp_solve on Mac OS X and call it with python.
It's time to install DB with Docker! DB installation for beginners on Docker
Prepare a machine learning project format and run it on SageMaker
Commentary on unbiasedness and consistency for those who don't like it