LoginSignup
32
27

More than 3 years have passed since last update.

RustのロボットプログラミングフレームワークOpenRRを使う

Last updated at Posted at 2021-02-19

はじめに

OpenRR は私(@OTL)が代表取締役社長をやっているスマイルロボティクス株式会社が中心となって開発しています。
(Qiita的にこういう宣伝はOKらしいですが念の為)

OpenRRとは

OpenRRはオープンソース(Apache-2)ライセンスのRust用のロボット開発フレームワークです。
Rustはロボットと相性のよい言語だと思います。ご参考:三年前のわたしのQiita記事

OpenRRは arci というロボット仮想化インタフェース(単なるtraitですが)を持っており、ロボットや外部フレームワークに直接依存することなくコードが書ける環境を用意します。
現状ではROS1とurdf-vizでの静的シミュレーション(ビューワー)に対応しています。ROS2への対応も予定しています。

特徴

特徴として、

  • MacOS/Linux/Windows(WindowsのみROS非対応)で動く
  • ROSがインストールされていなくてもROSが使える

なので、 ROSがインストールされていないMacOSからLinux上のROSで動くロボットを動かす ことが出来ます。これは世界初かもしれません。

ただ、これはrosrustがpure Rustで出来ていることに依るところが大きく、ROS2では無理かと思われます。

アーキテクチャ

アーキテクチャ的には↓のような感じで、とにかく arci を使ってプログラム書こうぜ、arci を使った便利ライブラリ、フレームワークが OpenRR本体、って感じです。

architecture.png

最終的なロボットとの通信の実装は仮想化されているのでROS1のプログラムを一瞬でROS2のプログラムに変更することが出来るようになる予定です。

発音

一応公式な発音は「オープナー」です。未来を切り開く的な思いが込められています。

開発状況

OpenRRは公開されているものの、まだまだ開発途中です。Rustのバージョンは通常0.1.0から始まるのですが、0.0.1くらいのバージョン番号をつけています。
ライブラリとして本格的に取り込むには変更が頻繁すぎてリスキーですが、いいものになるように (とくにarciのインタフェースについて) ご意見等頂ければありがたいです。

OpenRR Appsを試してみる

OpenRRを使って作ったアプリがあるので紹介します。

準備

Linuxの人はREADME.mdに従って依存ライブラリをインストールしておいてください。

Rustのインストール

https://rustup.rs/ にアクセスして、コマンドをターミナルにコピペしてrustをインストールしましょう。すでにインストールしてある人は念の為rustup updateしてください。
source ~/.cargo/env も忘れずに。

urdf-vizのインストール

必須ではないですが、ROSがないときのシミュレータ代わりのビューワーとしてurdf-vizをインストールしましょう。URDFファイルを可視化するには便利なツールです。同じくMacOS/Windowsでも動きます。(xacroやrospackが必要なurdf/xacroファイル(メッシュのパスが package:// のもの)はLinuxでしか表示出来ないので、もし表示したければxacroはLinuxで出力し、package://はurdfからの相対パスか絶対パスに編集しておく必要があります。)

cargo install urdf-viz

openrr-appsのインストール

cargo install openrr-apps --features ros

Windowsの場合はROSが使えないので

cargo install openrr-apps

としてください(ROSは使えません)

設定ファイルを用意

現在openrr-appsを使うには設定ファイルが必要です。ここにコンフィグとサンプルURDFを置いたのでこれを使いましょう。

git clone https://github.com/OTL/openrr-apps-config-sample
cd openrr-apps-config-sample

ちなみにコンフィグの中身は↓のような感じです。

[[urdf_viz_clients_configs]]
name = "arm"
joint_names = ["l_shoulder_yaw", "l_shoulder_pitch", "l_shoulder_roll", "l_elbow_pitch", "l_wrist_yaw", "l_wrist_pitch"]

[openrr_clients_config]
# relative from this file or absolute path
urdf_path = "../urdf/robot.urdf"
self_collision_check_pairs = [
    "root:l_gripper_linear1",
    "root:l_gripper_linear2",
    "root:l_wrist_yaw",
    "root:l_wrist_pitch",
    "root:l_elbow_pitch",
    "root:l_shoulder_roll"
    ]

[[openrr_clients_config.collision_check_clients_configs]]
name = "arm_collision_checked"
client_name = "arm"

[[openrr_clients_config.ik_clients_configs]]
name = "arm_ik"
client_name = "arm_collision_checked"
solver_name = "arm_ik_solver"

[[openrr_clients_config.joints_poses]]
pose_name = "zero"
client_name = "arm_collision_checked"
positions = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]

[[openrr_clients_config.joints_poses]]
pose_name = "pose1"
client_name = "arm_collision_checked"
positions = [0.0, 0.5, 0.0, -0.8, 0.0, 0.3]

[openrr_clients_config.ik_solvers_configs.arm_ik_solver]
ik_target = "l_tool_fixed"

openrr_apps_joint_position_sender

まずは urdf-vizを立ち上げます。

urdf-viz urdf/robot.urdf &

スクリーンショット 2021-02-18 16.47.48.png

openrr_apps_joint_position_senderを立ち上げます。

openrr_apps_joint_position_sender config/robot.toml

スクリーンショット 2021-02-18 16.47.55.png

どっかで見たことありそうなGUIですよね。

これはロボットの関節位置をロボットに送るGUIです。
armと表示されているところをarm_collision_checkedにすると、自己干渉チェックが行われてから姿勢がurdf-vizに送られます。

動作の様子

openrr_apps_robot_command

こっちはコマンドラインインタフェースです。

関節角度の取得

$ openrr_apps_robot_command -c ./config/robot_config.toml get_state arm
Joint positions : [-0.64, 0.0, 0.0, 0.0, -1.17, 0.0]

いろんなコマンドを逐次実行。詳細はcommand/commands.txtを見てみてください。

openrr_apps_robot_command -c ./config/robot_config.toml load_commands ./command/commands.txt

動作の様子

どんなコマンドがあるかは-hで調べてみてください。

$ openrr_apps_robot_command -h
openrr_apps_robot_command 0.0.1
An openrr command line tool.

USAGE:
    openrr_apps_robot_command [OPTIONS] <SUBCOMMAND>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -c, --config-path <config-path>

SUBCOMMANDS:
    cancel_navigation_goal         Cancel navigation gaol
    execute_command                Execute an external command
    get_navigation_current_pose    Get navigation current pose
    get_state                      Get joint positions and end pose if applicable
    help                           Prints this message or the help of the given subcommand(s)
    list                           List available clients
    load_commands                  Load commands from file and execute them
    move_ik                        Move with ik
    send_base_velocity             Send base velocity
    send_joints                    Send joint positions
    send_joints_pose               Send predefined joint positions
    send_navigation_goal           Send navigation goal pose
    speak                          Speak text message

他の例

Universal RobotのUR10を使った例や、PR2で動かす例などもopenrrのリポジトリにはありますのでもし興味持っていただいたら(ハードル高いと思いますが)試していただけるとめっちゃうれしいです。

ライブラリとして

ライブラリとして使うのが本当のOpenRRなのですが、まだサンプルと呼べるようなものはありません。openrr-apps自体が1つのサンプルではありますが、ちょっと複雑過ぎます。
Stay Tuned!

終わりに

以上でv0.0.1のOpenRRの紹介、解説は終わりです。興味を持って頂ければ幸いです。

32
27
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
32
27