README
crane_plus_examples_py
このパッケージはCRANE+ V2 ROS 2パッケージのPythonによるサンプルコード集です。
Table of Contents
Setup
CRANE+ V2の起動方法はcrane_plus_examplesのREADMEを参照してください。
How to Run Examples
準備ができたらPythonによるサンプルプログラムを実行します。 例えばグリッパを開閉するサンプルは次のコマンドで実行できます。
ros2 launch crane_plus_examples_py example.launch.py example:='gripper_control'
終了するときはCtrl+cを入力します。
[!NOTE] Gazeboでサンプルプログラムを実行する場合は
use_sim_timeオプションを付けます。ros2 launch crane_plus_examples_py example.launch.py example:='gripper_control' use_sim_time:=true
Examples
demo.launch.pyを実行している状態で各サンプルを実行できます。
[!NOTE] 実行できるサンプルの一覧は、
examples.launch.pyにオプション-sを付けて実行することで表示できます。$ ros2 launch crane_plus_examples_py example.launch.py -s Arguments (pass arguments as '<name>:=<value>'): 'example': Set an example executable name: [gripper_control, pose_groupstate, joint_values, pick_and_place] (default: 'gripper_control')
gripper_control
グリッパを開閉させるコード例です。
次のコマンドを実行します。
ros2 launch crane_plus_examples_py example.launch.py example:='gripper_control'
pose_groupstate
group_stateを使うコード例です。
SRDFファイルcrane_plus_moveit_config/config/crane_plus.srdf
に記載されているhomeとverticalの姿勢に移行します。
次のコマンドを実行します。
ros2 launch crane_plus_examples_py example.launch.py example:='pose_groupstate'
joint_values
アームのジョイント角度を1つずつ変更するコード例です。
次のコマンドを実行します。
ros2 launch crane_plus_examples_py example.launch.py example:='joint_values'
pick_and_place
モノを掴む・持ち上げる・運ぶ・置くコード例です。
次のコマンドを実行します。
ros2 launch crane_plus_examples_py example.launch.py example:='pick_and_place'
Camera Examples
Webカメラ搭載モデルのカメラを使用したサンプルコードです。
crane_plus_examplesのREADMEに記載されている「Webカメラ搭載モデルを使用する場合」の手順に従ってdemo.launchを実行している状態で各サンプルを実行できます。
[!NOTE] 実行できるサンプルの一覧は、
camera_example.launch.pyにオプション-sを付けて実行することで確認できます。ros2 launch crane_plus_examples_py camera_example.launch.py -s Arguments (pass arguments as '<name>:=<value>'): 'example': Set an example executable name: [color_detection] (default: 'color_detection')
aruco_detection
モノに取り付けたArUcoマーカをカメラで検出し、マーカ位置に合わせて掴むコード例です。 マーカはaruco_markers.pdfをA4紙に印刷して、一辺50mmの立方体に取り付けて使用します。
検出されたマーカの位置姿勢はtfのフレームとして配信されます。
tfのframe_idはマーカIDごとに異なりID0のマーカのframe_idはtarget_0になります。
掴む対象はtarget_0に設定されています。
マーカ検出にはOpenCVを使用しています。
次のコマンドを実行します。
ros2 launch crane_plus_examples_py camera_example.launch.py example:='aruco_detection'
Videos
color_detection
特定の色の物体を検出して掴むコード例です。
デフォルトでは赤い物体の位置をtfのフレームとして配信します。
tfのframe_idはtarget_0です。
色検出にはOpenCVを使用しています。
次のコマンドを実行します。
ros2 launch crane_plus_examples_py camera_example.launch.py example:='color_detection'

