13
13

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 5 years have passed since last update.

【Mac】vagrantでrosを使えるまで

Last updated at Posted at 2016-03-06

ubuntu 14.04 LTS
virtualboxを使います

Vagrantfile
Vagrant.configure(2) do |config|

  config.ssh.forward_agent = true

  config.vm.hostname = "ros"
  config.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
  config.vm.box = "ubuntu14.04"
  config.vm.network "private_network", ip: "192.168.33.10"
  config.vm.network :"forwarded_port", guest: 3000, host: 3000
  config.vm.network :forwarded_port, guest: 80, host: 8080
  config.vm.provider :virtualbox do |vb|
    vb.customize ["modifyvm", :id, "--memory", "4096", "--cpus", "4", "--ioapic", "on"] # cpuとメモリの割り当て量。お使いのPCのスペックに応じて変えてください
    vb.gui = true
    vb.customize ["modifyvm", :id, "--accelerate3d", "on"]
  end
end

vagrant立ち上げ&ログイン
vagrant up vagrant ssh

GUI設定(rosでguiを見れるようにする)

sudo apt-get install xfce4 sudo add-apt-repository ppa:gnome3-team/gnome3 sudo apt-get update sudo apt-get install gnome-shell sudo apt-get install ubuntu-desktop sudo apt-get install gdm sudo dpkg-reconfigure gdm

exit

vagrant reload vagrant ssh

GUIのパスワードはvagrant

virtualbox.png

ROSのインストール

時刻設定
sudo apt-get install chrony sudo ntpdate -q ntp.ubuntu.com

ROSリポジトリをros-latest.listに追加
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

公開鍵追加
wget https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -O - | sudo apt-key add -

パッケージリストとインストール済みのパッケージを最新化。
sudo apt-get update && sudo apt-get upgrade

ROS Indigo Iglooとrqt関連をインストール
sudo apt-get install ros-indigo-desktop-full sudo apt-get install ros-indigo-rqt*

rosdepを初期化
sudo rosdep init rosdep update

rosinstallをインストール
sudo apt-get install python-rosinstall

環境変数をロード
source /opt/ros/indigo/setup.bash

作業フォルダの作成と初期化
mkdir -p ~/catkin_ws/src cd ~/catkin_ws/src catkin_init_workspace cd ~/catkin_ws/ catkin_make source ~/catkin_ws/devel/setup.bash

ROSの環境設定
vi ~/.bashrc

.bashrc
source /opt/ros/indigo/setup.bash
source ~/catkin_ws/devel/setup.bash

export ROS_HOSTNAME=192.168.33.10
export ROS_MASTER_URI=http://${ROS_HOSTNAME}:11311
export DISPLAY=:0

alias cw='cd ~/catkin_ws'
alias cs='cd ~/catkin_ws/src'
alias cm='cd ~/catkin_ws && catkin_make'

ROS_HOSTNAMEはvagrantのnetwork設定による
guiを使う時にcannot connect to X serverでエラーになるのでexport DISPLAY=:0しておく

環境変数をロード
source ~/.bashrc

ROS&GUI確認(別ターミナルで全て立ち上げ)
マスタノード立ち上げ
roscore

亀さん立ち上げ
rosrun turtlesim turtlesim_node

亀さんを十字キーで移動操作
rosrun turtlesim turtle_teleop_key
kame.png

13
13
2

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
13
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?