このパッケージはCRANE-X7 ROS 2パッケージのサンプルコード集です。
CRANE-X7の起動方法はcrane_x7_examplesのREADMEを参照してください。
準備ができたらサンプルプログラムを実行します。 例えばグリッパを開閉するサンプルは次のコマンドで実行できます。
ros2 launch crane_x7_examples_py example.launch.py example:='gripper_control'
終了するときはCtrl+c
を入力します。
Gazeboでサンプルプログラムを実行する場合はuse_sim_time
オプションを付けます。
ros2 launch crane_x7_examples_py example.launch.py example:='gripper_control' use_sim_time:='true'
demo.launch
を実行している状態で各サンプルを実行できます。
実行できるサンプルの一覧は、example.launch.py
にオプション-s
を付けて実行することで表示できます。
$ ros2 launch crane_x7_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: 'pose_groupstate')
ハンドを開閉させるコード例です。
次のコマンドを実行します。
ros2 launch crane_x7_examples_py example.launch.py example:='gripper_control'
group_stateを使うコード例です。
SRDFファイルcrane_x7_moveit_config/config/crane_x7.srdf
に記載されているhome
とvertical
の姿勢に移行します。
次のコマンドを実行します。
ros2 launch crane_x7_examples_py example.launch.py example:='pose_groupstate'
アームのジョイント角度を1つずつ変更させるコード例です。
次のコマンドを実行します。
ros2 launch crane_x7_examples_py example.launch.py example:='joint_values'
モノを掴む・持ち上げる・運ぶ・置くコード例です。
次のコマンドを実行します。
ros2 launch crane_x7_examples_py example.launch.py example:='pick_and_place'
実機を使う場合
CRANE-X7から20cm離れた位置にピッキング対象を設置します。
サンプルで使用しているこのオレンジ色のソフトボールはRT ROBOT SHOPのこちらのページから入手することができます。
RealSense D435マウンタ搭載モデルのカメラを使用したサンプルコードです。
crane_x7_examplesのREADMEに記載されている「RealSense D435マウンタ搭載モデルを使用する場合」の手順に従ってdemo.launch
を実行している状態で各サンプルを実行できます。
実行できるサンプルの一覧は、camera_example.launch.py
にオプション-s
を付けて実行することで表示できます。
$ ros2 launch crane_x7_examples_py camera_example.launch.py -s
Arguments (pass arguments as '<name>:=<value>'):
'example':
Set an example executable name: [aruco_detection, color_detection]
(default: 'aruco_detection')
モノに取り付けたArUcoマーカをカメラで検出し、マーカ位置に合わせて掴むコード例です。 マーカはaruco_markers.pdfをA4紙に印刷し、一辺50mmの立方体に取り付けて使用します。
検出されたマーカの位置姿勢はtfのフレームとして配信されます。
tfのframe_id
はマーカIDごとに異なりID0のマーカのframe_id
はtarget_0
になります。掴む対象はtarget_0
に設定されています。マーカ検出にはOpenCVを使用しています。
次のコマンドを実行します
ros2 launch crane_x7_examples_py camera_example.launch.py example:='aruco_detection'
特定の色の物体を検出して掴むコード例です。
デフォルトでは青い物体の位置をtfのフレームとして配信します。
tfのframe_id
はtarget_0
です。
色の検出にはOpenCVを使用しています。
検出した物体の距離は深度画像から取得します。
次のコマンドを実行します
ros2 launch crane_x7_examples_py camera_example.launch.py example:='color_detection'