--raspi4 + ubuntu20.04 + Let's build an environment for ROS (foxy). --Completely a memorandum. --Updated - 2020/06/16
-Download to my PC from Official Page
--For mac, you can easily get it with homebrew
- brew cask install raspberry-pi-imager
--Launch Raspberry Pi Imager
--Select ubuntu 20.04 LTS for operating system ――Let's take 64bit as a place to install ROS2
--Specify SD card and press WRITE --Remove the SD card and finish
-Insert the SD card with the image written in (2) into raspi and start it (connect the power supply) ――It takes time for the first time ...?
ubuntu
--Default password ubuntu
[Reference site](https://denor.jp/ubuntu-20-04-focal-fossa%E3%81%AE%E5%88%9D%E6%9C%9F%E8%A8%AD%E5%AE % 9A-ip% E3% 82% A2% E3% 83% 89% E3% 83% AC% E3% 82% B9% E3% 80% 81% E3% 83% 9B% E3% 82% B9% E3% 83 % 88% E5% 90% 8D% E7% AD% 89)
sudo hostnamectl set-hostname ooo
sudo timedatectl set-timezone Asia/Tokyo
sudo vim /etc/netplan/50-cloud-init.yaml
--Reference file --192.168.xxx.1 is the IP of the router --192.168.xxx.yyy is the IP of raspi
python
network:
ethernets:
eth0:
dhcp4: false
addresses: [192.168.xxx.yyy/24]
gateway4: 192.168.xxx.1
nameservers:
addresses: [192.168.xxx.1]
version: 2
--After editing, reflect the settings on netplan
sudo netplan apply
sudo reboot
--There are various versions -Previous version --This time, we will use ROS2 foxy that supports ubuntu 20.04 LTS.
--Basically, if you copy and paste according to Installation procedure on the official page, it will end. .. Should be. --This time, I went to ** Install argcomplete (optional) ** on the official page.
--Set the OS character code to UTF8
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8
(2) Setup Sources --Add ROS2 apt repository
sudo apt update && sudo apt install curl gnupg2 lsb-release
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://packages.ros.org/ros2/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list'
--There are two types, base and desktop, but this time install base
sudo apt update
sudo apt install ros-foxy-ros-base
source /opt/ros/foxy/setup.bash
echo "source /opt/ros/foxy/setup.bash" >> ~/.bashrc
sudo apt install python3-argcomplete
--This time, execute the code for python
--The test code (rclcpp) for C language is also installed, so I will delete it this time.
mkdir -p ~/ros2/src
cd ~/ros2
git clone https://github.com/ros2/examples src/examples
cd ~/ros2/src/examples/
git checkout $ROS_DISTRO
rm -rf rclcpp
-Installation reference page -Page about colcon --About colcon --A build tool that can be built even if both versions of ROS1 and ROS2 are mixed. --The ROS1 package is built by calling ** catkin **, and ROS2 by calling ** ament **.
sudo apt install python3-colcon-common-extensions
cd ~/ros2
colcon build --symlink-install
source ~/ros2/install/setup.bash
echo "source ~/ros2/install/setup.bash" >> ~/.bashrc
--Publisher on terminal (1)
ros2 run examples_rclpy_minimal_publisher publisher_member_function
--Subscriber on terminal (2)
ros2 run examples_rclpy_minimal_subscriber subscriber_member_function
By the way, fantastic! !! !!
--Terminal (1) Publisher
--Terminal (2) Subscriber
--Click here for the test code executed this time
Recommended Posts