概要

ROS通信機能の利用

Windows

ROSのインストール

ROSTransportのビルド

C++での実行

Pythonでの実行

Ubuntu

ROSのインストール

以下はUbuntu 20.04で実行するコマンドを掲載しています。

> sudo sh -c 'echo "deb <http://packages.ros.org/ros/ubuntu> $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
> sudo apt install curl
> curl -s <https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc> | sudo apt-key add -
> sudo apt update
> sudo apt install ros-noetic-desktop-full
> sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential
> echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
> source ~/.bashrc
> sudo rosdep init
> rosdep update
> mkdir -p ~/catkin_ws/src
> cd ~/catkin_ws/
> catkin_make

ROSTransportのインストール

OpenRTM-aistのインストール時に-e rosのオプションを付けてください。

> bash <(curl -s <https://raw.githubusercontent.com/OpenRTM/OpenRTM-aist/master/scripts/openrtm2_install_ubuntu.sh>) -l c++ -e ros

C++での実行

事前準備として、ROSのPublisher、Subscriberのチュートリアルで作成するtalker、listenerのメッセージ型をstd_msgs/Int32型に変更したROSノードをビルドして起動します。

> cd ~
> git clone <https://github.com/Nobu19800/testROSTransport> 
> cp -r ~/testROSTransport/beginner_tutorials ~/catkin_ws/src
> cd ~/catkin_ws
> source ~/catkin_ws/devel/setup.bash
> catkin_make

roscore、linstenerを起動してください。

> roscore