README

crane_plus_examples

このパッケージはCRANE+ V2 ROS 2パッケージのサンプルコード集です。

Table of Contents

Setup

CRANE+ V2の起動方法はcrane_plus_examplesのREADMEを参照してください。

Using CRANE+ V2

crane_plus

1. CRANE+ V2本体をPCに接続する

CRANE+ V2本体をPCに接続します。 接続方法は製品マニュアルを参照してください。

[!NOTE] CRANE+ V2本体が接触しないように、十分なスペースを確保してください。

2. USB通信ポートの接続を確認する

USB通信ポートの設定についてはcrane_plus_controlREADME を参照してください。

[!NOTE] 正しく設定できていない場合、CRANE+ V2が動作しない、振動する、などの不安定な動きになるので注意してください。

3. move_groupとcontrollerを起動する
  • 標準のCRANE+ V2を使用する場合

    次のコマンドでmove_group (crane_plus_moveit_config)とcontroller (crane_plus_control)を起動します。

    ros2 launch crane_plus_examples demo.launch.py port_name:=/dev/ttyUSB0
    
  • Webカメラ搭載モデルを使用する場合

    Webカメラ搭載モデルの場合は、次のコマンドを実行してください。 video_deviceは使用するWebカメラを指定してください。

    ros2 launch crane_plus_examples demo.launch.py port_name:=/dev/ttyUSB0 use_camera:=true video_device:=/dev/video0
    

Using Gazebo

crane_plus_ignition

1. move_groupとGazeboを起動する
  • 標準のCRANE+ V2を使用する場合

    次のコマンドでmove_group (crane_plus_moveit_config)とGazeboを起動します。

    ros2 launch crane_plus_gazebo crane_plus_with_table.launch.py
    
  • Webカメラ搭載モデルを使用する場合

    Webカメラ搭載モデルの場合は、次のコマンドを実行してください。

    ros2 launch crane_plus_gazebo crane_plus_with_table.launch.py use_camera:=true
    

[!NOTE] CRANE+ V2の前にArUcoマーカ付きのBoxを置いたシミュレータ環境を使用する場合は次のコマンドを実行します。

aruco_detectionサンプルを実行する際に使用することを想定しています。

ros2 launch crane_plus_gazebo crane_plus_with_aruco_cube.launch.py use_camera:=true

[!NOTE] CRANE+ V2の前に赤いBoxを置いたシミュレータ環境を使用する場合は次のコマンドを実行します。

color_detectionサンプルを実行する際に使用すること想定しています。

ros2 launch crane_plus_gazebo crane_plus_with_red_cube.launch.py use_camera:=true

Using Mock Components

1. move_groupとcontrollerを起動する

次のコマンドでmove_group (crane_plus_moveit_config)とcontroller (crane_plus_control)を起動します。

ros2 launch crane_plus_examples demo.launch.py use_mock_components:=true

[!NOTE] Mock Componentsではカメラを使ったサンプルを実行することはできません。

How to Run Examples

準備ができたらサンプルプログラムを実行します。 例えばグリッパを開閉するサンプルは次のコマンドで実行できます。

ros2 launch crane_plus_examples example.launch.py example:='gripper_control'

終了するときはCtrl+cを入力します。

[!NOTE] Gazeboでサンプルプログラムを実行する場合はuse_sim_timeオプションを付けます。

ros2 launch crane_plus_examples example.launch.py example:='gripper_control' use_sim_time:=true

Examples

demo.launch.pyを実行している状態で各サンプルを実行できます。

[!NOTE] 実行できるサンプルの一覧は、example.launch.pyにオプション-sを付けて実行することで表示できます。

ros2 launch crane_plus_examples 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 example.launch.py example:='gripper_control'

Back to example list


pose_groupstate

group_stateを使うコード例です。

SRDFファイルcrane_plus_moveit_config/config/crane_plus.srdf に記載されているhomeverticalの姿勢に移行します。

次のコマンドを実行します。

ros2 launch crane_plus_examples example.launch.py example:='pose_groupstate'

Back to example list


joint_values

アームのジョイント角度を1つずつ変更するコード例です。

次のコマンドを実行します。

ros2 launch crane_plus_examples example.launch.py example:='joint_values'

Back to example list


pick_and_place

モノを掴む・持ち上げる・運ぶ・置くコード例です。

次のコマンドを実行します。

ros2 launch crane_plus_examples example.launch.py example:='pick_and_place'

Back to example list

Camera Examples

Webカメラ搭載モデルのカメラを使用したサンプルコードです。

「Webカメラ搭載モデルを使用する場合」の手順に従い、demo.launch.pyを実行している状態で各サンプルを実行します。

実行できるサンプルの一覧は、camera_example.launch.pyにオプション-sを付けて実行することで確認できます。

ros2 launch crane_plus_examples 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 フレームとして配信され、ID0のマーカは frame_id=target_0 になります。

  • 掴む対象はtarget_0に設定されています。

  • マーカ検出にはOpenCVを使用しています。

aruco_detection

次のコマンドを実行します。

ros2 launch crane_plus_examples camera_example.launch.py example:='aruco_detection'

Back to camera example list


color_detection

特定の色の物体を検出して掴むコード例です。

  • デフォルトでは青い物体の位置をtfのフレームとして配信します。

  • tfのframe_idtarget_0です。

  • 色の検出にはOpenCVを使用しています。

color_detection

次のコマンドを実行します。

ros2 launch crane_plus_examples camera_example.launch.py example:='color_detection'

Back to camera example list