クイックスタート
導入
このガイドでは、Zivid Motion の使い方を紹介します。セルのデータをインストールし、そこから計画データを生成した後、以下のセクションで示すように経路を計画し、簡単な障害物を迂回するように再計画します。
Zivid Motion をまだインストールしていない場合は、 インストール にアクセスし、インストールが完了したらこの記事に戻ってください。
セルデータのインストール
セルデータは、Zivid Motion チームから入手したインストールファイルと同じ ZIP ファイル内に含まれています。
~/Downloads/motion-quickstart/
├─ data.zip
├─ zivid_pythonmotion*.whl
├─ zivid-motion*.deb
まず最初にやるべきことは、携帯電話のデータをインストールすることです。
python -c 'import zividmotion; app = zividmotion.Application(); zividmotion.install_package(application=app, package_path="path/to/data.zip")'
~/.local/share/Motion/ には、このクイックスタートガイドに必要なデータが含まれているはずです。このディレクトリの内容の詳細については、: の セルデータ データおよび設定ファイル セクションを参照してください。
計画データを生成する
プランニングを開始する前に、プランニングデータを生成する必要があります。これは、実行時プランナーの計算を高速化する前処理ステップです。~/.local/share/Motion/ 内のソースファイルに変更があった場合は、必ず再生成してください。再生成を忘れると、プランナーでエラーが発生します。
プランニングデータの生成 サンプル内のコードを実行して生成してください。生成時間はシステムの仕様によって異なりますが、 testing 環境であれば 1 分程度で完了するはずです。
経路計画
さあ、ルートを計画しましょう!以下の簡単な例を参考に、4 つの簡単なステップで進めていきます。
プランナーを初期化する
ある関節構成から別の関節構成への経路を計画する
経路を塞ぐ簡単な幾何学的障害物を設定する
経路を再度計画し、プランナーが障害物を迂回する新しい経路をどのように見つけるかを確認してください。
from typing import Optional
from zividmotion.zividmotion import (
Application,
Configuration,
ConfigurationGoals,
Mesh,
Obstacle,
PathRequest,
PlannerSettings,
Pose,
Profile,
Vector3f,
Visualizer,
)
# A visual representation of the cell will open when USE_VISUALIZER is set to True.
CELL_NAME = "demo_cell"
PROFILE = Profile.testing
USE_VISUALIZER = False
app = Application()
planner_settings = PlannerSettings(
cell_name=CELL_NAME,
profile=PROFILE,
)
print("1. Initializing planner...")
planner = app.create_planner(planner_settings)
visualizer: Optional[Visualizer] = Visualizer.view_planner(planner) if USE_VISUALIZER else None
print("Planner successfully initialized.")
start_joint_config = Configuration([0.0, 0.0, 0.6, 0.0, 0.9, 0.0])
input("2. Press Enter to plan path to goal...")
# A simple planning problem where the shortest path is to spin the first joint 180 degrees.
goal_configuration = Configuration([3.14, 0.0, 0.6, 0.0, 0.9, 0.0])
goal = ConfigurationGoals([goal_configuration])
path_request = PathRequest(goals=goal)
path_result_1 = planner.path(start_joint_config, path_request)
print(path_result_1)
input("3. Press Enter to set an obstacle...")
# This obstacle will block the direct path, forcing the planner to find a new path around it.
box_mesh = Mesh.create_box(Vector3f(0.12, 0.7, 0.7)).transform(
Pose(
[
[1.0, 0.0, 0.0, 0.0],
[0.0, 1.0, 0.0, 1.3],
[0.0, 0.0, 1.0, 0.8],
[0.0, 0.0, 0.0, 1.0],
]
)
)
obstacle = Obstacle.from_mesh(name="box_obstacle", mesh=box_mesh)
planner.set_obstacles([obstacle])
input("4. Press Enter to plan path to goal again...")
path_result_2 = planner.path(start_joint_config, path_request)
# The planner should now have found a new path around the obstacle. When comparing the two
# path results, you can see that path_result_2 contains multiple waypoints to pass around
# the obstacle.
print(path_result_1)
print(path_result_2)
if visualizer is not None:
print("Close the window to exit.")
visualizer.wait()
次のステップ
これは、Zivid Motion の簡単な紹介であり、ランタイム API を使用してパスを計画し、環境に動的な障害物を設定する方法の概要を理解していただくためのものです。次の推奨資料は以下のとおりです。