Install Subsystem for Linux version 2 (WSL 2)

Download version: https://www.microsoft.com/ko-kr/software-download/windows10

  1. Open PowerShell as Admin and enable WSL
    dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
    
  2. Set default version as 2
    wsl --set-default-version 2
    
  3. Open MS store and install Ubuntu 20.04: https://www.microsoft.com/store/apps/9n6svws3rx71

  4. Check WSL version
    > wsl --list --verbose
    
  5. Set WSL with version 2
    wsl --set-version Ubuntu 2
    

Reference: https://docs.microsoft.com/ko-kr/windows/wsl/install-win10

ROS2 in WSL 2

  1. Update existing packages
    $ sudo apt update
    
  2. Let apt use packages in HTTPS
    $ sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
    
  3. Add GPG key for official Docker repo into our system
    $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    

Reference: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-20-04

Install Docker in wsl2

  1. Installing docker in wsl2
    $ sudo apt-get update
    $ sudo apt-get install docker.io
    $ sudo ln -sf /usr/bin/docker.io /usr/local/bin/docker
    
$ docker pull ubuntu:16.04
// Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
// --> means docker service not executed

// check service status

$sudo systemctl status docker
// System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
$sudo /etc/init.d/docker start

Reference: https://index.ros.org/doc/ros2/Installation/Foxy/Linux-Install-Binary/

Install ROS 2

  1. Add the ROS 2 apt repository
    • You will need to add the ROS 2 apt repositories to your system.
    • Authorize our GPG key with apt ```bash $ 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 - gpg: can’t connect to the agent: IPC connect call failed

    // Solution Option 1.

    apt remove gpg ( follow the instructions) apt install gnupg1 (follow the instructions)

    Option 2.

    sudo apt remove gpg sudo apt-get update -y sudo apt-get install -y gnupg1

    $ curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add - //OK ```

  2. Add the repository to your sources list
    $sudo sh -c 'echo "deb http://packages.ros.org/ros2/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list'
    
  3. Downloading ROS 2
    // Update your apt repository caches after setting up the repositories.
    $ sudo apt update
    // Desktop Install (Recommended): ROS, RViz, demos, tutorials.
    $ sudo apt install ros-foxy-desktop
    
  4. Env setup
    $ source /opt/ros/foxy/setup.bash
    // help auto ccomplete (optional)
    $ sudo apt install python3-argcomplete
    
  5. ROS1 (melodic dge
    $ sudo apt update
    $ sudo apt install ros-foxy-ros
    dge
    
  6. TEST
    // terminal 1
    $ source /opt/ros/foxy/setup.bash
    $ ros2 run demo_nodes_cpp talker
    // terminal 2
    $ source /opt/ros/foxy/setup.bash
    $ ros2 run demo_nodes_py listener
    

Reference: http://pyrasis.com/book/DockerForTheReallyImpatient/Chapter02