|
crane_x7_examples package from crane_x7 repocrane_x7 crane_x7_bringup crane_x7_control crane_x7_description crane_x7_examples crane_x7_gazebo crane_x7_moveit_config crane_x7_msgs |
Package Summary
| Tags | No category tags. |
| Version | 0.0.0 |
| License | NON-COMMERCIAL LICENSE AGREEMENT |
| Build type | CATKIN |
| Use | RECOMMENDED |
Repository Summary
| Checkout URI | https://github.com/rt-net/crane_x7_ros.git |
| VCS Type | git |
| VCS Version | master |
| Last Updated | 2019-05-09 |
| Dev Status | DEVELOPED |
| Released | UNRELEASED |
Package Description
Additional Links
Maintainers
- RT Corporation
Authors
- Daisuke Sato
- Hiroyuki Nomura
crane_x7_examples
CRANE-X7のためのパッケージ、 crane_x7 で用いるサンプルをまとめたパッケージです。
システムの起動方法
CRANE-X7の制御信号ケーブルを制御用パソコンへ接続します。
Terminalを開き、crane_x7_bringupのdemo.launchを起動します。
このlaunchファイルには次のオプションが用意されています。
- fake_execution (default: true)
実機を使用する/使用しない
シミュレータを使う場合
実機無しで動作を確認する場合、 制御信号ケーブルを接続しない状態で次のコマンドを実行します。
roslaunch crane_x7_bringup demo.launch fake_execution:=true
実機を使う場合
実機で動作を確認する場合、 制御信号ケーブルを接続した状態で次のコマンドを実行します。
roslaunch crane_x7_bringup demo.launch fake_execution:=false
ケーブルの接続ポート名はデフォルトで/dev/ttyUSB0です。
別のポート名(例: /dev/ttyUSB1)を使う場合は次のコマンドを実行します。
roslaunch crane_x7_bringup demo.launch fake_execution:=false port:=/dev/ttyUSB1
サンプルの実行方法
demo.launchを実行している状態で各サンプルを実行することができます。
gripper_action_example.pyの実行
ハンドを開閉させるコード例です。 このサンプルは実機動作のみに対応しています。
次のコマンドで45度まで開いて閉じる動作を実行します。
rosrun crane_x7_examples gripper_action_example.py
pose_groupstate_example.pyの実行
group_stateを使うコード例です。
SRDFファイルcrane_x7_moveit_config/config/crane_x7.srdf
に記載されているhomeとverticalの姿勢に移行します。
次のコマンドを実行します。
rosrun crane_x7_examples pose_groupstate_example.py
crane_x7_pick_and_place_demo.pyの実行
モノを掴む・持ち上げる・運ぶ・置くコード例です。
次のコマンドを実行します。
rosrun crane_x7_examples crane_x7_pick_and_place_demo.py

実機を使う場合
CRANE-X7から20cm離れた位置にピッキング対象を設置します。

サンプルで使用しているこのオレンジ色のソフトボールはRT ROBOT SHOPのこちらのページから入手することができます。
動作させるとこちらのような動きになります。
preset_pid_gain_example.pyの実行
crane_x7_controlのpreset_reconfigureを使うコード例です。
サーボモータのPIDゲインを一斉に変更できます。
プリセットはcrane_x7_control/scripts/preset_reconfigure.py にて編集できます。
次のコマンドを実行すると、preset_reconfigure.pyとpreset_pid_gain_example.pyのノードを起動します。
roslaunch crane_x7_examples preset_pid_gain_example.launch
動作させるとこちらのような動きになります。
teaching_example.pyの実行
ティーチングのコード例です。X7のPIDゲインを小さくすることでダイレクトティーチングができます。
次のコマンドでノードを起動します。
roslaunch crane_x7_examples teaching_example.launch
以下のキー割当を参考に、キーボードから操作してください。
Teaching Mode
起動時のモードです。トルクOFF*状態です。
| キー | 機能 |
|---|---|
| s / S | 現在の姿勢を保存 |
| d / D | これまでに保存した姿勢を削除 |
| m / M | Action Modeへ遷移 |
| q / Q | シャットダウン |
Action Mode
Teaching Modeから遷移します。トルクON*状態です。
| キー | 機能 |
|---|---|
| p / P | 保存した姿勢を1つずつ再生 |
| a / A | 保存した姿勢のすべてを連続再生 |
| l / L | ループ再生 ON / OFF |
| m / M | Teaching Modeへ遷移 |
| q / Q | シャットダウン |
- トルクのON / OFFはサーボモータのPIDゲインに小さい値をプリセットすることで実現しています。
動作させるとこちらのような動きになります。
joystick_example.pyの実行
ジョイスティックでX7を動かすコード例です。 手先の位置・姿勢の変更、グリッパーの開閉、PIDゲインのプリセット、ティーチングができます。
ジョイスティックをPCに接続し、/dev/input/js0が存在することを確認してください。
次のコマンドでノードを起動します。
実機を使う場合
roslaunch crane_x7_examples joystick_example.launch
シミュレータを使う場合
シミュレータを使う場合は、エラーを防ぐためsimオプションを追加してください。
roslaunch crane_x7_examples joystick_example.launch sim:=true
キー割り当ての変更
デフォルトのキー割り当てはこちらです。ジョイスティックは
Logicool Wireless Gamepad F710
を使っています。

crane_x7_example/launch/joystick_example.launch のキー番号を編集することで、キー割り当てを変更できます。
<node name="joystick_example" pkg="crane_x7_examples" type="joystick_example.py" required="true" output="screen">
<!-- 使用するジョイスティックコントローラに合わせてvalueを変更してください -->
<!-- ひとつのボタンに複数の機能を割り当てています -->
<param name="button_shutdown_1" value="8" type="int" />
<param name="button_shutdown_2" value="9" type="int" />
<param name="button_name_enable" value="7" type="int" />
<param name="button_name_home" value="8" type="int" />
<param name="button_preset_enable" value="7" type="int" />
<param name="button_preset_no1" value="9" type="int" />
デフォルトのキー番号はこちらです。

ジョイスティックのキー番号はトピック/joyで確認できます。
# ノードを起動する
roslaunch crane_x7_examples joystick_example.launch sim:=true
# 別のターミナルでコマンドを入力
rostopic echo /joy
# ジョイスティックのボタンを押す
header:
seq: 1
stamp:
secs: 1549359364
nsecs: 214800952
frame_id: ''
axes: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
buttons: [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
---
動作させるとこちらのような動きになります。
obstacle_avoidance_example.pyの実行
ROSのServiceを使って、障害物の追加と障害物回避をするコード例です。
次のコマンドでノードを起動します。
roslaunch crane_x7_examples obstacle_avoidance_example.launch
このサンプルでは目標姿勢と障害物の大きさ・姿勢を定義したサービスファイルを使用します。
目標姿勢と障害物の大きさ・姿勢は
crane_x7_examples/scripts/obstacle_client.pyを編集することで変更できます。
デフォルトでは、直方体の箱を障害物として設定しています。
# 障害物を設定
obstacle_name = "box"
obstacle_size = Vector3(0.28, 0.16, 0.14)
obstacle_pose_stamped = PoseStamped()
obstacle_pose_stamped.header.frame_id = "/base_link"
obstacle_pose_stamped.pose.position.x = 0.35
obstacle_pose_stamped.pose.position.z = obstacle_size.z/2.0
安全のため障害物として床を設置しています。
不要であればcrane_x7_examples/scripts/obstacle_avoidance_example.py
を編集してください。
# 安全のため床を障害物として生成する
floor_name = "floor"
floor_size = (2.0, 2.0, 0.01)
floor_pose = PoseStamped()
floor_pose.header.frame_id = "/base_link"
floor_pose.pose.position.z = -floor_size[2]/2.0
scene.add_box(floor_name, floor_pose, floor_size)
rospy.sleep(SLEEP_TIME)
moveitが障害物回避のパスを生成できない場合、X7は動作せず、次の目標位置に対するパスを計算します。
この場合、サーバからの返答はresult=Falseとなります。


servo_info_example.pyの実行
サーボモータ(joint)の情報を取得するコード例です。
次のコマンドでノードを起動します。
rosrun crane_x7_examples servo_info_example.py
このサンプルではグリッパーのモータcrane_x7_gripper_finger_a_jointのトピックを取得しています。
実行するとターミナル画面にモータの電流・位置・温度が表示されます。
# 表示例
current [mA]: 0.0 dxl_position: 2634 temp [deg C]: 42.0
current [mA]: 2.69 dxl_position: 2634 temp [deg C]: 42.0
current [mA]: 0.0 dxl_position: 2634 temp [deg C]: 42.0
current [mA]: 0.0 dxl_position: 2634 temp [deg C]: 42.0
current [mA]: 2.69 dxl_position: 2634 temp [deg C]: 42.0
...
また、電流が一定値を超えるとグリッパーを開く(閉じる)処理を入れてます。 これにより、手でグリッパーを開く(閉じる)ことができます。
トピックの詳細については、crane_x7_control/README.mdを確認してください。
Wiki Tutorials
Source Tutorials
Package Dependencies
| Deps | Name | |
|---|---|---|
| 1 | crane_x7_moveit_config | |
| 2 | std_msgs | |
| 2 | geometry_msgs | |
| 1 | message_generation | |
| 1 | catkin | |
| 2 | moveit_commander | |
| 1 | message_runtime | |
| 2 | joy |
System Dependencies
Dependant Packages
| Name | Repo | Deps |
|---|---|---|
| crane_x7 | github-rt-net-crane_x7_ros |
Launch files
- launch/obstacle_avoidance_example.launch
- launch/preset_pid_gain_example.launch
- launch/joystick_example.launch
-
- joydev [default: /dev/input/js0]
- sim [default: false]
- launch/teaching_example.launch