2
0

More than 1 year has passed since last update.

MacBook に Docker を使って ROS 環境を構築するまで

Last updated at Posted at 2022-10-03

Docker のインストール

 こちらのリンクからDocker Mac 用をダウンロードしてインストールする

Xquartz のをインストール

 こちらのリンク から XQuartz-x.x.x.dmg "x にはバージョンナンバーが入ります" をダウンロードする。

コンテナを立ててその中で ROS を動す

このコマンドを実行して ROS noetic コンテナを Mac に入れる

ROS noetic コンテナを入れる
docker run -p 6080:80 --shm-size=512m tiryoh/ros-desktop-vnc:noetic

tiryoh/ros-desktop-vnc:noetic はこの GitHub の noetic ディレクトリから持ってきた

これで必要なパッケージや細々したものを自動的に Pull してくれる。気長に待とう。

エラー

このようなエラーが出たら、Docker を起動してもう一度試す。

docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.

問題?エラー?

 エラーというか問題と言えばいいのか…上記のコマンドを実行してこの状態から全く動かなくなった。

Unable to find image 'tiryoh/ros-desktop-vnc:noetic' locally
noetic: Pulling from tiryoh/ros-desktop-vnc
a70d879fa598: Already exists 
c4394a92d1f8: Already exists 
10e6159c56c0: Already exists 
54ce6fc330e9: Pull complete 
1956e2222f9d: Pull complete 
1c994628a0c6: Pull complete 
e56a311ab0d9: Pull complete 
df940afc45d1: Pull complete 
bde7b6ec42ef: Pull complete 
8891fc46bfb9: Pull complete 
1679b9375f7b: Pull complete 
2e75818e91cb: Pull complete 
4fd36cdf8f48: Pull complete 
12f1b55b746c: Pull complete 
575e236b4892: Pull complete 
500d3bfc756e: Pull complete 
d86459404036: Pull complete 
24192db3d93f: Pull complete 
2ef47aa69a69: Pull complete 
534875413a89: Pull complete 
9fa919089b46: Pull complete 
Digest: sha256:e6030e7f57e71b77a7be98a335e8a7d084a096210c47c1c5fc02685913ed2735
Status: Downloaded newer image for tiryoh/ros-desktop-vnc:noetic
* enable custom user: ubuntu
useradd: user 'ubuntu' already exists
  set default password to "ubuntu"
cp: cannot stat '/root/.config': No such file or directory
2022-10-01 00:32:51,675 CRIT Supervisor is running as root.  Privileges were not dropped because no user is specified in the config file.  If you intend to run as root, you can set user=root in the config file to avoid this message.
2022-10-01 00:32:51,676 INFO Included extra file "/etc/supervisor/conf.d/supervisord.conf" during parsing
2022-10-01 00:32:51,692 INFO RPC interface 'supervisor' initialized
2022-10-01 00:32:51,693 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2022-10-01 00:32:51,694 INFO supervisord started with pid 21
2022-10-01 00:32:52,699 INFO spawned: 'nginx' with pid 23
2022-10-01 00:32:52,704 INFO spawned: 'web' with pid 24
2022-10-01 00:32:52,707 INFO spawned: 'xvfb' with pid 25
2022-10-01 00:32:52,710 INFO spawned: 'wm' with pid 26
2022-10-01 00:32:52,715 INFO spawned: 'lxpanel' with pid 27
2022-10-01 00:32:52,720 INFO spawned: 'pcmanfm' with pid 28
2022-10-01 00:32:52,725 INFO spawned: 'x11vnc' with pid 29
2022-10-01 00:32:52,731 INFO spawned: 'novnc' with pid 30
2022-10-01 00:32:53,418 INFO  Listening on http://localhost:6079 (run.py:87)
2022-10-01 00:32:53,706 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-10-01 00:32:53,707 INFO success: web entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-10-01 00:32:53,707 INFO success: xvfb entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-10-01 00:32:53,867 INFO success: wm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-10-01 00:32:53,867 INFO success: lxpanel entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-10-01 00:32:53,867 INFO success: pcmanfm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-10-01 00:32:53,867 INFO success: x11vnc entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-10-01 00:32:53,867 INFO success: novnc entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

 というか上記にイメージが見つからなかったって書いてあるが、参考資料のターミナルにも同じ表記があった。これは僕のパソコンのスペックの問題なのだろうか?
 試しにこのまま次に進んで実行してみる。

LocalHostポート6080 を開く

Safari、Chrome などから以下の URL を開くと GUI が表示される

  • http://127.0.0.1:6080/
    GUI 画面が表示されたら このホスト上でコンソール?ターミナルもどきを立ち上げる。ターミナルはここにある。
    ターミナルの場所.png
    そしてターミナル上で roscore を実行する
    roscore実行.png
    動いた
    どうやら Mac 本体でのターミナルの状態で何も故問題はなかったみたい。なんかよくわからない進捗が表示されていた。

Turtle_sim を動かしてみる

 ROS 定番の亀さんを動かしてみる。ローカルホストの方のターミナルを Cntrol + Shift + T でタブを増やし、turtle sim node を実行する

rosrun turtlesim turtlesim_node

クラッシュが現れた
turtle_si.png
あとは新しくターミナルを開いてこのコマンドを実行すればカメを動かすことができるようになる

rosrun turtlesim turtle_teleop_key

USB 認識させたい

 docker VNC サーバーから USB デバイスを認識できるようにしたい。将来的にルンバを Mac につなげたいからだ。ただ、Mac では Docker 経由での USB アクセスはできないみたい。残念

2
0
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
2
0