17
15

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 1 year has passed since last update.

[ROS2] ROS1とROS2を共存させる

Posted at

ROS1もROS2も使いたい.
そういうときは、以下のコードを.bashrcに書き込んでおけばOK!

構成

Ubuntu 20.04
以下のROSディストリビューションがインストールされている

  • ros1 noetic
  • ros2 foxy

ROS1、ROS2切り替えコマンド

.bashrc
# ROS1 環境
function rs1(){
  PYTHONPATH=/opt/ros/noetic/lib/python3/dist-packages
  source /opt/ros/noetic/setup.bash
  source ~/ros1_ws/devel/setup.bash
}

# ROS2 環境
function rs2(){
  export PYTHONPATH=/opt/ros/foxy/lib/python3.8/site-packages
  source /opt/ros/foxy/setup.bash
  source ~/ros2_ws/install/local_setup.bash
}

# 端末起動時のデフォルトのROS環境
rs1 # ROS1
#rs2 # ROS2

書き込んだら、source ~/.bashrc

ROS1に変更したい場合、

rs1

ROS2に変更したい場合、

rs2

これで、端末ごとにROS環境を変更できる.

17
15
1

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
17
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?