Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
587ec53
jazzy対応(MoveitConfigsBuilder)
mizonon Jul 19, 2024
1374d50
不要なコメント削除
mizonon Aug 9, 2024
6b10a74
不要ファイルのignore
mizonon Aug 13, 2024
89bdf8b
crane_plus_moveit_config/launchの中の不要ファイル削除
mizonon Aug 13, 2024
96186f6
default_***_scaling_factorを0.1->1.0に変更
mizonon Aug 15, 2024
e3898ed
setup assistantによる書換わりを元の書き方に修正
mizonon Aug 15, 2024
553e522
exampleのdemo.lauch修正
mizonon Aug 15, 2024
384f2b4
run_move_group.rviz削除
mizonon Aug 15, 2024
7147e27
sensors_3d.yaml削除
mizonon Aug 15, 2024
de86b8d
solverを元に戻す
mizonon Aug 15, 2024
0314d62
.gitignore変更
mizonon Aug 15, 2024
185c6bd
setup_assistant関連のファイル追加
mizonon Aug 15, 2024
2e01610
ciのjazzy対応
mizonon Aug 15, 2024
4ba5ed8
run_move_froup.lauch.pyの整理
mizonon Aug 15, 2024
92f9340
不要な権限変更
mizonon Aug 15, 2024
b6e6962
不要な権限変更
mizonon Aug 15, 2024
bde95e1
不要なscript削除
mizonon Aug 16, 2024
9013d35
kinematicの設定修正
mizonon Aug 16, 2024
82a96db
ソルバーをKDLに戻す
mizonon Aug 20, 2024
3199a4d
実装完了
mizonon Sep 9, 2024
d31d5e6
jazzy環境対応
mizonon Sep 18, 2024
a057fce
camera_example.launch.pyの実装追加
mizonon Sep 19, 2024
e7ce02d
add crane_plus_example_py
mizonon Sep 19, 2024
f2b83d7
Merge branch 'support_jazzy' into moveit_py
mizonon Sep 19, 2024
91add60
warehouse_ros_mongoをcrane_plus_moveit_configのpackage.xmlに含めない
mizonon Sep 19, 2024
52e8c9c
Merge branch 'support_jazzy' into moveit_py
mizonon Sep 19, 2024
b8f40d7
1回の通信エラーで終了処理をするのをやめる
mizonon Sep 20, 2024
e33e9da
entrypoint.shのパッケージ名の指定修正
mizonon Sep 20, 2024
3398057
launchファイル修正
mizonon Sep 20, 2024
9a099d3
package.xmlに必要なpythonパッケージ追加
mizonon Sep 20, 2024
44bf384
不要なscriptsディレクトリ削除
mizonon Sep 20, 2024
9277ab5
numpy-quaternion-pipをpackage.xmlに含める
mizonon Sep 20, 2024
70deeb6
package.xmlにpython3-pipの依存関係追加
mizonon Sep 25, 2024
094fa3c
pose_groupstate.pyとgripper_control.pyについて動作確認できた
mizonon Sep 26, 2024
d0c1f67
gripper_control.pyとpose_groupstate.pyにコメント追加
mizonon Sep 27, 2024
ccfb544
joint_values.pyについて動作確認できた
mizonon Sep 30, 2024
1c3b113
レビュー結果反映
mizonon Oct 4, 2024
bb49b1e
radianの計算はpythonのmathを使うことに統一
mizonon Oct 4, 2024
e46d557
utils.pyなどの細かい修正
mizonon Oct 16, 2024
2ea61a0
moveit2をソースからビルドして動いたときのプログラム
mizonon Oct 18, 2024
b227184
README.md(jazzy対応&バイナリインストール方法追加)
mizonon Oct 21, 2024
88f4313
.dockerのREADME.mdのjazzy対応
mizonon Oct 21, 2024
e9a548f
CI対応(copyright追加)
mizonon Oct 21, 2024
bf56ec0
CI対応
mizonon Oct 22, 2024
a74f3b7
CI対応(setup_assistant.launch.py)
mizonon Oct 22, 2024
a671d5e
CI対応(package.xmlの不要な部分削除)
mizonon Oct 22, 2024
86513fb
コメントをjazzyに合わせる
mizonon Oct 22, 2024
2de4b14
ign fuelでgazeboのモデルをダウンロードする記述削除
mizonon Oct 22, 2024
8a157cc
ciのDockerイメージをjazzyに対応
mizonon Oct 22, 2024
f1bfe95
他の製品と設定を共通化
mizonon Oct 22, 2024
e6866a2
crane_plus_description/package.xmlのauthorに溝口を追加
mizonon Oct 23, 2024
f2e153a
ompl_planning.yamlに抜けていた記述追加
mizonon Oct 23, 2024
b895f0b
joint_values.pyにmax_acceleraration_scaling_factorとmax_velocity_scalin…
mizonon Oct 25, 2024
8eaf1e8
color_detection.pyのsubscriptionのcallback関数名修正
mizonon Oct 25, 2024
5c6104d
crane_plus_examples_py用のREADME追加
mizonon Oct 30, 2024
4e0a275
CIのnumpy-quaternionのインストールエラー対応
mizonon Oct 31, 2024
057338c
CI対応
mizonon Oct 31, 2024
8ab3822
CI対応
mizonon Oct 31, 2024
c122fb8
CI対応
mizonon Nov 1, 2024
1e1c7e2
CI対応
mizonon Nov 1, 2024
1a5fd93
CI対応
mizonon Nov 1, 2024
32a0cb8
CI対応
mizonon Nov 1, 2024
b3f6ec1
動作確認のため、support_jazzyをマージ
mizonon Nov 8, 2024
1ff1b3b
カメラサンプル用のlaunchファイル修正
mizonon Nov 11, 2024
c823afa
カメラサンプル動作確認用の修正
mizonon Nov 11, 2024
dc07458
カメラサンプル用のlaunchファイル微修正
mizonon Nov 12, 2024
f4161fd
crane_plush_examples_pyのサンプル起動用のlaunchファイル微修正
mizonon Nov 12, 2024
1850f69
crane_plus_examples_pyのpick_and_place_tf.py微修正
mizonon Nov 12, 2024
225a604
crane_plus_examples_py/utils.pyの余計なコメント削除
mizonon Nov 12, 2024
1f59bd9
crane_plus_examples_pyの各コード微修正
mizonon Nov 12, 2024
78dbc3c
CI対応の微修正
mizonon Nov 12, 2024
9b161aa
CI対応の微修正
mizonon Nov 12, 2024
2361a41
CI対応の微修正
mizonon Nov 12, 2024
5d05398
CI対応の微修正
mizonon Nov 12, 2024
f797d08
CI対応
mizonon Nov 20, 2024
8daa08f
CI対応
mizonon Nov 20, 2024
2611004
Merge branch 'master' into moveit_py
Kuwamai Dec 27, 2024
2b4cdd8
コメント修正
Kuwamai Dec 27, 2024
e342fbb
通信エラー時の処理修正
Kuwamai Dec 27, 2024
20aaa8e
不要な差分を削除
Kuwamai Dec 27, 2024
6614b2a
Revert "コメント修正"
Kuwamai Dec 27, 2024
37778b1
コメント修正
Kuwamai Dec 27, 2024
6c52b25
インデント修正
Kuwamai Dec 27, 2024
5a4277f
パッケージ情報更新
Kuwamai Jan 7, 2025
43c5e39
コーディングスタイルを統一
Kuwamai Jan 17, 2025
f2fc690
コーディングスタイルを統一
Kuwamai Jan 17, 2025
accc732
動作の成否を返り値として出力
Kuwamai Jan 17, 2025
d512a86
capabilitiesの記述を削除
Kuwamai Jan 17, 2025
2f4d5fd
不要な処理を削除
Kuwamai Jan 22, 2025
44dc4a4
コーディングスタイルの統一
Kuwamai Jan 22, 2025
02070cf
回転行列の変換にscipyを使用
Kuwamai Jan 22, 2025
ab329fa
コーディングスタイル修正
Kuwamai Jan 22, 2025
314302e
コーディングスタイル修正
Kuwamai Jan 22, 2025
b90e3a6
Merge branch 'master' into moveit_py
Kuwamai Jan 28, 2025
c8c9d9f
Merge remote-tracking branch 'origin/master' into moveit_py
YusukeKato Feb 6, 2026
4fb8ab6
位置姿勢の許容範囲を設定してプランニングを実行する
YusukeKato Feb 6, 2026
f68e5cf
自動フォーマット
YusukeKato Feb 6, 2026
672e336
Revert "自動フォーマット"
YusukeKato Feb 6, 2026
7e3baea
ruffで自動フォーマット
YusukeKato Feb 6, 2026
91c962c
import文の順序を修正
YusukeKato Feb 6, 2026
1f59285
import順を修正
YusukeKato Feb 6, 2026
b930d61
色検出サンプルが動くように修正
YusukeKato Feb 6, 2026
70e87cf
ArUcoマーカ検出サンプルが動作するように修正
YusukeKato Feb 6, 2026
e6d8a09
READMEをcrane_x7_rosに合わせる
YusukeKato Feb 6, 2026
99574fa
不要なimportを削除
YusukeKato Feb 6, 2026
81054bf
armグループからarm_tcpグループへ変更
YusukeKato Feb 6, 2026
ab5bdec
tcpリンクを使用
YusukeKato Feb 9, 2026
e1053de
実行コマンドの先頭の$マークを削除
YusukeKato Feb 9, 2026
8e425a0
パッケージ情報を追加
YusukeKato Feb 9, 2026
952beef
ここにライセンスファイルは不要なので削除
YusukeKato May 21, 2026
4dc702b
Merge remote-tracking branch 'origin/master' into moveit_py
YusukeKato May 21, 2026
88c300e
フォーマットに合わせて修正
YusukeKato May 21, 2026
47366b3
不要なドルマークを削除
YusukeKato May 21, 2026
ed04e08
自動整形
YusukeKato May 22, 2026
4363181
crane-x7に実装を合わせる
YusukeKato May 22, 2026
4ad270b
crane-x7に実装を合わせる
YusukeKato May 22, 2026
b88bddc
リンクと文章を修正
YusukeKato May 25, 2026
1b0003a
authorを追記
YusukeKato May 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ ros2 launch crane_plus_examples example.launch.py example:='gripper_control'
- CRANE+ V2のモデルデータ(xacro)を定義するパッケージです
- crane_plus_examples
- [README](./crane_plus_examples/README.md)
- CRANE+ V2のサンプルコード集です
- CRANE+ V2のC++サンプルコード集です
- crane_plus_examples_py
- [README](./crane_plus_examples_py/README.md)
- CRANE+ V2のPythonサンプルコード集です
- crane_plus_gazebo
- [README](./crane_plus_gazebo/README.md)
- CRANE+ V2のGazeboシミュレーションパッケージです
Expand All @@ -105,7 +108,12 @@ ros2 launch crane_plus_examples example.launch.py example:='gripper_control'

## How to Use Examples

サンプルプログラムは、`crane_plus_examples`パッケージの[README](./crane_plus_description/README.md)参照してください。
サンプルプログラムは、C++とPythonの両方を用意しています。詳しくは、以下のリンクをご覧ください。

- C++
- [crane_plus_examples](./crane_plus_examples/README.md)
- Python
- [crane_plus_examples_py](./crane_plus_examples_py/README.md)

## License

Expand Down
8 changes: 6 additions & 2 deletions crane_plus_control/src/crane_plus_hardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ return_type CranePlusHardware::read(
RCLCPP_ERROR(
rclcpp::get_logger("CranePlusHardware"),
driver_->get_last_error_log().c_str());
return return_type::ERROR;
// readに失敗しても通信は継続させる。
// 不確かなデータをセットしないようにOKを返す。
return return_type::OK;
} else {
for (uint i = 0; i < hw_position_states_.size(); ++i) {
hw_position_states_[i] = joint_positions[i];
Expand Down Expand Up @@ -271,7 +273,9 @@ return_type CranePlusHardware::write(
RCLCPP_ERROR(
rclcpp::get_logger("CranePlusHardware"),
driver_->get_last_error_log().c_str());
return return_type::ERROR;
// writeに失敗しても通信は継続させる。
// 不確かなデータをセットしないようにOKを返す。
return return_type::OK;
}

prev_comm_timestamp_ = steady_clock_.now();
Expand Down
197 changes: 197 additions & 0 deletions crane_plus_examples_py/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
# crane_plus_examples_py

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

## Table of Contents

- [crane\_plus\_examples\_py](#crane_plus_examples_py)
- [Table of Contents](#table-of-contents)
- [Setup](#setup)
- [How to Run Examples](#how-to-run-examples)
- [Examples](#examples)
- [gripper\_control](#gripper_control)
- [pose\_groupstate](#pose_groupstate)
- [joint\_values](#joint_values)
- [pick\_and\_place](#pick_and_place)
- [Camera Examples](#camera-examples)
- [aruco\_detection](#aruco_detection)
- [color\_detection](#color_detection)

## Setup

CRANE+ V2の起動方法は[crane_plus_examplesのREADME](../crane_plus_examples/README.md)を参照してください。

## How to Run Examples

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

```sh
ros2 launch crane_plus_examples_py example.launch.py example:='gripper_control'
```

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

> [!NOTE]
> Gazeboでサンプルプログラムを実行する場合は`use_sim_time`オプションを付けます。
>
> ```sh
> ros2 launch crane_plus_examples_py example.launch.py example:='gripper_control' use_sim_time:=true
> ```

## Examples

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

- [gripper_control](#gripper_control)
- [pose_groupstate](#pose_groupstate)
- [joint_values](#joint_values)
- [pick_and_place](#pick_and_place)

> [!NOTE]
> 実行できるサンプルの一覧は、`examples.launch.py`にオプション`-s`を付けて実行することで表示できます。
>
> ```sh
> $ 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

グリッパを開閉させるコード例です。

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

```sh
ros2 launch crane_plus_examples_py example.launch.py example:='gripper_control'
```

<img src=https://rt-net.github.io/images/crane-plus/gripper_control.gif width=500px />

[back to example list](#examples)

---

### pose_groupstate

group_stateを使うコード例です。

SRDFファイル[crane_plus_moveit_config/config/crane_plus.srdf](../crane_plus_moveit_config/config/crane_plus.srdf)
に記載されている`home`と`vertical`の姿勢に移行します。

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

```sh
ros2 launch crane_plus_examples_py example.launch.py example:='pose_groupstate'
```

<img src=https://rt-net.github.io/images/crane-plus/pose_groupstate.gif width=500px />

[back to example list](#examples)

---

### joint_values

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

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

```sh
ros2 launch crane_plus_examples_py example.launch.py example:='joint_values'
```

<img src=https://rt-net.github.io/images/crane-plus/joint_values.gif width=500px />

[back to example list](#examples)

---

### pick_and_place

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

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

```sh
ros2 launch crane_plus_examples_py example.launch.py example:='pick_and_place'
```

<img src=https://rt-net.github.io/images/crane-plus/pick_and_place.gif width=500px />

[back to example list](#examples)

---

## Camera Examples

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

[crane_plus_examplesのREADME](../crane_plus_examples/README.md)に記載されている「Webカメラ搭載モデルを使用する場合」の手順に従って`demo.launch`を実行している状態で各サンプルを実行できます。

- [aruco\_detection](#aruco_detection)
- [color\_detection](#color_detection)

> [!NOTE]
> 実行できるサンプルの一覧は、`camera_example.launch.py`にオプション`-s`を付けて実行することで確認できます。
>
> ```sh
> 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](./aruco_markers.pdf)をA4紙に印刷して、一辺50mmの立方体に取り付けて使用します。

検出されたマーカの位置姿勢はtfのフレームとして配信されます。
tfの`frame_id`はマーカIDごとに異なりID0のマーカの`frame_id`は`target_0`になります。
掴む対象は`target_0`に設定されています。
マーカ検出には[OpenCV](https://docs.opencv.org/4.x/d5/dae/tutorial_aruco_detection.html)を使用しています。

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

```bash
ros2 launch crane_plus_examples_py camera_example.launch.py example:='aruco_detection'
```

#### Videos
[![crane_plus_aruco_detection_demo](https://rt-net.github.io/images/crane-plus/aruco_detection.gif)](https://youtu.be/m9dus6LCocc)

[back to example list](#examples)

---

### color_detection

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

デフォルトでは赤い物体の位置をtfのフレームとして配信します。
tfの`frame_id`は`target_0`です。
色検出には[OpenCV](https://docs.opencv.org/4.x/db/d8e/tutorial_threshold.html)を使用しています。

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

```sh
ros2 launch crane_plus_examples_py camera_example.launch.py example:='color_detection'
```

#### Videos
[![crane_plus_color_detection_demo](https://rt-net.github.io/images/crane-plus/color_detection.gif)](https://youtu.be/Kn0eWA7sALY)

[back to example list](#examples)

---
26 changes: 26 additions & 0 deletions crane_plus_examples_py/config/crane_plus_moveit_py_examples.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
planning_scene_monitor_options:
name: "planning_scene_monitor"
robot_description: "robot_description"
joint_state_topic: "/joint_states"
attached_collision_object_topic: "/moveit_cpp/planning_scene_monitor"
publish_planning_scene_topic: "/moveit_cpp/publish_planning_scene"
monitored_planning_scene_topic: "/moveit_cpp/monitored_planning_scene"
wait_for_initial_state_timeout: 10.0

planning_pipelines:
pipeline_names: ["ompl"]

plan_request_params:
planning_attempts: 1
planning_pipeline: ompl
max_velocity_scaling_factor: 1.0
max_acceleration_scaling_factor: 1.0

ompl_rrtc: # Namespace for individual plan request
plan_request_params: # PlanRequestParameters similar to the ones that are used by the single pipeline planning of moveit_cpp
planning_attempts: 1 # Number of attempts the planning pipeline tries to solve a given motion planning problem
planning_pipeline: ompl # Name of the pipeline that is being used
planner_id: "RRTConnectkConfigDefault:" # Name of the specific planner to be used by the pipeline
max_velocity_scaling_factor: 1.0 # Velocity scaling parameter for the trajectory generation algorithm that is called (if configured) after the path planning
max_acceleration_scaling_factor: 1.0 # Acceleration scaling parameter for the trajectory generation algorithm that is called (if configured) after the path planning
planning_time: 5.0 # Time budget for the motion plan request. If the planning problem cannot be solved within this time, an empty solution with error code is returned
Empty file.
106 changes: 106 additions & 0 deletions crane_plus_examples_py/crane_plus_examples_py/aruco_detection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Copyright 2025 RT Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import cv2
from cv2 import aruco
from cv_bridge import CvBridge
from geometry_msgs.msg import TransformStamped
import numpy as np
import rclpy
from rclpy.node import Node
from scipy.spatial.transform import Rotation
from sensor_msgs.msg import CameraInfo, Image
from tf2_ros import TransformBroadcaster


class ImageSubscriber(Node):
def __init__(self):
super().__init__('aruco_detection')
self.image_subscription = self.create_subscription(
Image, 'image_raw', self.image_callback, 10
)
self.camera_info_subscription = self.create_subscription(
CameraInfo, 'camera_info', self.camera_info_callback, 10
)
self.tf_broadcaster = TransformBroadcaster(self)

self.camera_info = None

self.bridge = CvBridge()

def image_callback(self, msg):
# 画像データをROSのメッセージからOpenCVの配列に変換
cv_img = self.bridge.imgmsg_to_cv2(msg, desired_encoding=msg.encoding)
cv_img = cv2.cvtColor(cv_img, cv2.COLOR_RGB2BGR)

if not self.camera_info:
return

# ArUcoマーカのデータセットを読み込む
# DICT_6x6_50は6x6ビットのマーカが50個収録されたもの
MARKER_DICT = aruco.getPredefinedDictionary(aruco.DICT_6X6_50)
# マーカID
ids = []
# 画像座標系上のマーカ頂点位置
corners = []
# マーカの検出
corners, ids, _ = aruco.detectMarkers(cv_img, MARKER_DICT)
if ids is None:
return
# マーカの検出数
n_markers = len(ids)
# カメラパラメータ
CAMERA_MATRIX = np.array(self.camera_info.k).reshape(3, 3)
DIST_COEFFS = np.array(self.camera_info.d).reshape(1, 5)
# マーカ一辺の長さ 0.04 [m]
MARKER_LENGTH = 0.04
# 画像座標系上のマーカ位置を三次元のカメラ座標系に変換
rvecs, tvecs, _ = cv2.aruco.estimatePoseSingleMarkers(
corners, MARKER_LENGTH, CAMERA_MATRIX, DIST_COEFFS
)

# マーカの位置姿勢をtfで配信
for i in range(n_markers):
# tfの配信
t = TransformStamped()
t.header = msg.header
t.child_frame_id = 'target_' + str(ids[i][0])
t.transform.translation.x = tvecs[i][0][0]
t.transform.translation.y = tvecs[i][0][1]
t.transform.translation.z = tvecs[i][0][2]
# 回転ベクトルをクォータニオンに変換
marker_orientation_rot = Rotation.from_rotvec(rvecs[i][0])
marker_orientation_quat = marker_orientation_rot.as_quat()
t.transform.rotation.x = marker_orientation_quat[0]
t.transform.rotation.y = marker_orientation_quat[1]
t.transform.rotation.z = marker_orientation_quat[2]
t.transform.rotation.w = marker_orientation_quat[3]
self.tf_broadcaster.sendTransform(t)

def camera_info_callback(self, msg):
self.camera_info = msg


def main(args=None):
rclpy.init(args=args)

image_subscriber = ImageSubscriber()
rclpy.spin(image_subscriber)

image_subscriber.destroy_node()
rclpy.shutdown()


if __name__ == '__main__':
main()
Loading
Loading