0
0

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.

husarnetを利用してスマホをROSノードに

Last updated at Posted at 2019-07-16

何がしたいか

IMUとか高性能なカメラとかがついているスマホを遠隔のROSノードとして使えたら色々と嬉しいですよね。
husarnet・hNodeという便利なものがあるみたいです。
セットアップの要点のみを以下にまとめたので、詳細は記事下部の公式ドキュメント等をご覧ください。

ブラウザ上での準備

  1. husarnetのコンソール(https://app.husarnet.com/) にアクセスし、アカウントを作成しログイン
  2. Create Networkから任意の名前のネットワークを作成

Android端末側の準備

  1. Google Playで"hNode"というアプリをインストール
  2. アプリを立ち上げ、右上の︙マークからPair with cloudを選択、Scan QR codeに進む
  3. ブラウザ上での準備で作成したネットワーク下部のAdd Elementからscan QRをクリックし、QRコードを表示
  4. QRコードをスキャンし、成功すると端末の名称を登録でき、ネットワークに端末が登録される

roscoreを走らせる端末側の準備

husarnetのインストール(実行できない場合はrootユーザーに切り替えて実行)

curl https://install.husarnet.com/install.sh | sudo bash
sudo husarnet websetup

以下のようなメッセージが返ってくるので該当ページに移動して端末を使用するネットワークに追加

Go to https://app.husarnet.com/husarnet/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx to manage your network from web browser.

IPv6設定

roscoreやrosnodeを立ち上げるターミナルにおいて以下を実行する

export ROS_MASTER_URI=http://master:11311
export ROS_IPV6=on

roscore立ち上げ

通常通りroscoreを立ち上げる

roscore

ブラウザのネットワークに登録されている端末一覧において、設定した名称を選択し、ポップアップ内でROS masterにチェックを入れUpdateをクリック。
"ROS master (roscore) is not running on (登録名)"と表示されなければ正しくroscoreが認識されていることになる。

動作チェック

  • Android端末のrostopicが正しく表示できていることを確認する(以下はAndroid端末の名称をkagetoraで登録した場合の例)
$ rostopic list | grep kagetora
/kagetora/camera0/image/compressed
/kagetora/camera1/image/compressed
/kagetora/imu
/kagetora/light
/kagetora/magneticfield
/kagetora/pressure
/kagetora/proximity

rostopic hzrostopic echoで返答が返ってこない場合はターミナル上でROS_IPV6がonになっているかを確認する。

  • 上記のうち/kagetora/camera0/image/compressedの中身を確認(無論rviz上で表示させることも可能)
rosrun image_view image_view image:=/kagetora/camera0/image _image_transport:=compressed
  • IPv6アドレスやネットワークとの接続状態は以下のコマンドで確認できる
sudo husarnet status

あとは好きにスマホのカメラ映像やIMU情報を処理することができます。


参考
https://docs.husarnet.com/
https://medium.com/husarion-blog/dont-buy-expensive-sensors-for-your-robot-use-your-smartphone-24380eab521
https://husarion.com/tutorials/ros-tutorials/5-running-ros-on-multiple-machines/

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?