Software Backend/ros2

install ros2 galactic & test

light_meal 2023. 3. 18. 11:15
728x90

Create Docker & exec

docker run -itd --rm --name ros2_test ubuntu20.04 /bin/bash

 

  • 접속
docker exec -it ros2_test bash

 

Add User & exec user

adduser testuser

 

  • sudo 설치 및 권한 부여
apt install sudo
usermod -aG sudo testuser

 

  • exec user
su - testuser

 

Install ROS2 galactic

  • Document

https://docs.ros.org/en/galactic/Installation/Ubuntu-Install-Debians.html

 

Ubuntu (Debian) — ROS 2 Documentation: Galactic documentation

Debian packages for ROS 2 Galactic Geochelone are currently available for Ubuntu Focal. The target platforms are defined in REP 2000 Make sure you have a locale which supports UTF-8. If you are in a minimal environment (such as a docker container), the loc

docs.ros.org

 

  • set locale
locale  # check for UTF-8

sudo apt update && sudo apt install locales
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

locale  # verify settings

 

  • setup source
    • check ubuntu universe repository
    apt-cache policy | grep universe
    
    # return
    500 <http://security.ubuntu.com/ubuntu> focal-security/universe amd64 Packages
         release v=20.04,o=Ubuntu,a=focal-security,n=focal,l=Ubuntu,c=universe,b=amd64
     100 <http://archive.ubuntu.com/ubuntu> focal-backports/universe amd64 Packages
         release v=20.04,o=Ubuntu,a=focal-backports,n=focal,l=Ubuntu,c=universe,b=amd64
     500 <http://archive.ubuntu.com/ubuntu> focal-updates/universe amd64 Packages
         release v=20.04,o=Ubuntu,a=focal-updates,n=focal,l=Ubuntu,c=universe,b=amd64
     500 <http://archive.ubuntu.com/ubuntu> focal/universe amd64 Packages
         release v=20.04,o=Ubuntu,a=focal,n=focal,l=Ubuntu,c=universe,b=amd64
    

    • enable universe repository
    sudo apt-get install -y software-properties-common
    
    sudo add-apt-repository universe
    

    • add ros2 apt repository
    sudo apt-get update && sudo apt-get install -y curl gnupg lsb-release
    
    sudo curl -sSL <https://raw.githubusercontent.com/ros/rosdistro/master/ros.key> -o /usr/share/keyrings/ros-archive-keyring.gpg
    

    • add deb source
    echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] <http://packages.ros.org/ros2/ubuntu> $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
    
  • Install Ros2 Package
sudo apt update
sudo apt install ros-galactic-desktop

# or
sudo apt update
sudo apt install ros-galactic-ros-base
sudo apt install ros-dev-tools

 

  • sourcing setting script
source /opt/ros/galactic/setup.bash

 

  • test

1 terminal

source /opt/ros/galactic/setup.bash
ros2 run demo_nodes_cpp talker

2 termianl

source /opt/ros/galactic/setup.bash
ros2 run demo_nodes_py listener

728x90