0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

WSL2でROS(1)の初期設定まとめ

Last updated at Posted at 2021-05-23

背景

ROSの環境設定に毎度時間がかかってしまうので、検索時間を短縮するために参考にしたサイトをステップごとに残します。

はじめに

kinetic/melodicのインストールであれば、

WSL2の有効化・Ubuntuのインストール

GUIの設定

xeyesで正しく設定できているか確認する

エラーが出るとき

ROSのインストール(build系のインストールはしない)

kineticまたはmelodicのインストールであれば、
ROS講座サンプルコード内にある ros_lecture/install/install_ros_(ディストリビューション) をsourceで実行することでビルド可能な状態まで設定してくれます。(ありがとうございます。)

※Melodic以降、rosdepのインストールが自動ではなくなったので、apt-cache search ros-melodic の後にsudo apt-get install python-rosdep を追加すると良いと思います。

もしくは公式の手順を参考にしましょう。

catkin buildを使う

catkin buildがどうしても失敗する場合は.bashrcに
source ~/catkin_ws/devel/setup.bash
があるか確認しましょう。

Ubuntuの環境設定の最終形

~/.bashrcのファイル末尾に以下の5行が追加されていればOK

~/.bashrc
export LIBGL_ALWAYS_INDIRECT=""
export GAZEBO_IP=127.0.0.1

export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0.0
source /opt/ros/noetic/setup.bash
source ~/catkin_ws/devel/setup.bash

おまけ - VSCodeでWSL2を使う

  1. VSCodeをインストール
  2. WSL上で code . と入力

これだけで必要な設定が適用され、次回以降はVSCode上からもWSLを起動できます。

おまけ2

このページも参考に

最後に

対処したのにビルドが上手くいかないときはsource ~/.bashrc 忘れかもしれません。
快適な環境構築を最短で行いたいものです・・・

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?