Rapsberry Pi Install ROS
环境
- Raspberry Pi 2B
- Ubuntu Snappy
Install ROS
First we need to download Ubuntu ARM image from
https://wiki.ubuntu.com/ARM/RaspberryPiWrite image to SD card:
find sd card device (mine is /dev/sdg):
fdisk -l
write image to SD card using dd.
Dont forget that image is compressed:
xzcat {image} | sudo dd bs=4M of=/dev/sdg
ensure that image has been written:
sudo fdisk -l /dev/{sdX}
Connect RPi to yor PC using ethernet cable
Wait for a minute or so until RPi finished loading…
Let’s find IP address of connected RPi:
arp -a
Connect to RPi using ssh.
Default user/pass is ubuntu/ubuntu:
ssh ubuntu@{your.ip}
After first login system will ask you to update password
Let’s check if we have connection to Internet
And update all packages:
sudo apt update; sudo apt upgrade
If you don’t use ubuntu cloud,you can remove cloud-init.
This will speed up boot:
sudo apt remove cloud-init
Also remove cloud dirs from /etc and /var/lib dirs:
sudo rm -rf /etc/cloud; sudo rm -fr /var/lib/cloud
Add ROS repository:
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
Setup keys:
wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
Update package index:
sudo apt update
We will install ROS base. It is set of basic packages
for ROS:
sudo apt install ros-kinetic-ros-base
Initialise rosdep:
sudo rosdep init; rosdep update
Set up the ROS environment variables:
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
Modify
/etc/hosts
ubuntu@ubuntu:~$ cat /etc/hosts 127.0.0.1 localhost 127.0.0.1 ubuntu # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters ff02::3 ip6-allhosts
- And check that ROS is correctly installed:
roscore
配置WiFi
wifi_dhcp.sh
ubuntu@ubuntu:~$ cat wifi_dhcp.sh
#!/usr/bin/env bash
sudo apt -y install wpasupplicant
echo "allow-hotplug wlan0" > wlan0.cfg.tmp
echo "iface wlan0 inet dhcp" >> wlan0.cfg.tmp
echo ' wpa_ssid "YOUR_WIFI_SSID"' >> wlan0.cfg.tmp
echo ' wpa_psk "YOUR_WIFI_PASSWORD"' >> wlan0.cfg.tmp
echo "" >> wlan0.cfg.tmp
sudo mv wlan0.cfg.tmp /etc/network/interfaces.d/wlan0.cfg
wifi_static.sh
ubuntu@ubuntu:~$ cat wifi_static.sh
#!/usr/bin/env bash
sudo apt -y install wpasupplicant
echo "allow-hotplug wlan0" > wlan0.cfg.tmp
echo "iface wlan0 inet static" >> wlan0.cfg.tmp
echo ' address 192.168.1.151' >> wlan0.cfg.tmp
echo ' netmask 255.255.255.0' >> wlan0.cfg.tmp
echo ' gateway 192.168.1.100' >> wlan0.cfg.tmp
#because my router is rubbish and doesn't provide DNS service
echo ' dns-nameservers 8.8.8.8' >> wlan0.cfg.tmp
echo ' wpa_ssid "YOUR_WIFI_SSID"' >> wlan0.cfg.tmp
echo ' wpa_psk "YOUR_WIFI_PASSWORD"' >> wlan0.cfg.tmp
echo "" >> wlan0.cfg.tmp
sudo mv wlan0.cfg.tmp /etc/network/interfaces.d/wlan0.cfg