ros2-web-bridge は ros2 で rostopic を web 経由でやりとりするためのパッケージです.
ros1 の時の ros-bridge_suite や roswww の代わりとして使えそうなので,今回試してみました.
基本的に Readme の通りに実行すれば大丈夫です.ここからは日本語で振り返ってみます.
まずは ros2-web-bridge をワークスペースに clone します.
cd <ros2-workspace>/src
git clone https://github.com/RobotWebTools/ros2-web-bridge.git
次に Node.js と Node.js のパッケージ管理用の npm をインストールします.Readme ではオフィシャルサイトからインストールしていますが,今回は apt でインストールしました.
sudo apt install nodejs npm
続いて,ros2-web-bridge に必要な Node.js のパッケージをインストールします.
cd ros2-web-bridge
npm install
node-gyp でエラーで出ましたが, 再起動したら通ったので詳細は不明です.
通信用(ブリッジ用)のサーバーを起動します.
node bin/rosbridge.js
次に examples ディレクトリに移動して,ブラウザからアクセスするサーバーを別のターミナルから立ち上げます.
cd examples && node index.js
この状態で,ros2-web-bridge を実行しているPCのブラウザからhttp://localhost:3000/html/publisher.html
にアクセスすると,ブラウザからトピックの配信ができます.
なお,別のPCからアクセスしようとすると失敗します.解決方法は次の Issue に投稿したので,ご確認ください.
Connection fail with browser from external PC · Issue #154 · RobotWebTools/ros2-web-bridge
I have connection error to publish from browser. I logged in my ros pc (raspberry pi 4 installed foxy) with ssh and executed following command. Terminal 1: node...
コメント