Skip to content

color_detectionサンプルの追加#183

Merged
Kuwamai merged 26 commits into
ros2from
feature/color_detection
Jul 1, 2026
Merged

color_detectionサンプルの追加#183
Kuwamai merged 26 commits into
ros2from
feature/color_detection

Conversation

@KuraZuzu

@KuraZuzu KuraZuzu commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

What does this implement/fix?

color_detectionサンプルを追加します。

crane_x7_roscolor_detectionサンプルをベースに実装しています。

移植に加えて、Sciurus17向けに以下の変更・修正を行っています。

  • sciurus17_examples/src/color_detection_2d.cpp

    • 既存の2Dトラッキング用 color_detection コンポーネントを color_detection_2d にリネームしました。
    • C++クラス名は ColorDetection2D に変更しています。
    • head_camera_tracking.launch.py / chest_camera_tracking.launch.py の component 名・plugin 名も更新しています。
    • 処理内容は変更していません。
  • sciurus17_examples/src/color_detection.cpp

    • C++版 color_detection として、 Sciurus17 のカメラ構成に合わせて調整しました。
    • 入力トピックを /head_camera/color/image_raw/head_camera/aligned_depth_to_color/image_raw/head_camera/color/camera_info に変更しています。
    • 検出結果は target_0 の TF として配信します。
    • Gazeboと実機でのRealsenseのエンコードデータが違うため、深度画像の encoding として 16UC132FC1 の両方に対応しています。
    • HSV変換時に共有されたROS画像バッファを書き換えないよう、画像をコピーして処理するようにしました。
    • TFの姿勢 quaternion に恒等回転 w=1.0 を明示しました。
    • cv::moments() の名前空間を明示しました。
    • 深度画像アクセス時の座標変換を明示的な static_cast<int> にしました。
  • sciurus17_examples/src/pick_and_place_tf.cpp

    • pick_and_place_tf.cpp を実機/Gazeboでの動作に合わせて調整しました。
    • 把持対象のZ方向下限が0.03程度となって青色キューブが把持対象外となってしまうため、0.04 から 0.02 に緩和しています。
  • sciurus17_examples_py/sciurus17_examples_py/color_detection.py

    • Python版の color_detection サンプルとして追加しました。
    • C++版と同様にRGB画像・深度画像・CameraInfoを同期して使用します。
    • 16UC1 / 32FC1 の深度画像 encoding に対応しています。
    • 検出結果を target_0 の TF として配信します。
    • TFの姿勢 quaternion に恒等回転 w=1.0 を明示しています。
  • sciurus17_examples_py/sciurus17_examples_py/pick_and_place_tf.py

    • Python版の pick_and_place_tf.py を追加しました。
    • Sciurus17の左右腕・腰・左右グリッパ・首のMoveIt groupに合わせています。
    • 物体位置のY座標に応じて左右の腕を切り替えるようにしています。
  • その他

    • C++版/Python版それぞれの launch、依存関係、README を更新しました。
    • camera_example.launch.py から color_detection を起動できるようにしました。
    • image_transportmessage_filtersimage_geometrytf2_roscv_bridge など必要な依存関係を追加しています。
    • README に color_detection の実行方法と、配信される TF frame の説明を追記しました。

Does this close any currently open issues?

しません。

How has this been tested?

実機とGazeboの両方で動作を確認しました。

  1. Sciurus17を起動する
# 実機
$ ros2 launch sciurus17_examples demo.launch.py
# Gazebo
$ ros2 launch sciurus17_gazebo sciurus17_with_blue_cube.launch.py
  1. color_detectioサンプルを実行する
# C++版サンプル
$ ros2 launch sciurus17_examples camera_example.launch.py example:='color_detection'
# Python版サンプル
$ ros2 launch sciurus17_examples_py camera_example.launch.py example:='color_detection'

Any other comments?

なし

Checklists

@KuraZuzu KuraZuzu self-assigned this Jun 22, 2026
@KuraZuzu KuraZuzu added the Type: Feature New Feature label Jun 22, 2026
@KuraZuzu KuraZuzu requested a review from Copilot June 22, 2026 08:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Sciurus17向けに、特定色(デフォルト青)の物体を深度画像込みで検出し、TF(target_0)として配信してピッキングにつなぐ color_detection サンプル(C++/Python)を追加するPRです。既存の2D版 color_detection コンポーネントは color_detection_2d にリネームし、追従系launchから参照する構成に整理しています。

Changes:

  • C++: 深度+CameraInfoを同期して3D位置を算出しTF配信する color_detection 実行ファイルを追加
  • C++: 既存2D検出コンポーネントを color_detection_2d に改名し、関連launchを更新
  • Python: color_detection と、それに対応する pick_and_place_tf とカメラ例launchを追加

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
sciurus17_examples/src/color_detection.cpp 深度/CameraInfo同期で3D位置を算出しTF配信する新しい実行ファイルノードを実装
sciurus17_examples/src/color_detection_2d.cpp 既存2D検出を ColorDetection2d としてコンポーネント化
sciurus17_examples/include/sciurus17_examples/color_detection_2d.hpp ColorDetection2d の新規ヘッダ/ガード名更新
sciurus17_examples/CMakeLists.txt color_detection_2d をコンポーネント登録、color_detection を実行ファイルとして追加、依存追加
sciurus17_examples/package.xml image_transport/message_filters/tf2_ros 依存追加
sciurus17_examples/README.md color_detection サンプル説明を追加
sciurus17_examples/launch/head_camera_tracking.launch.py 参照コンポーネントを color_detection_2d に更新
sciurus17_examples/launch/chest_camera_tracking.launch.py 参照コンポーネントを color_detection_2d に更新
sciurus17_examples/launch/example.launch.py 例示リスト文言を更新
sciurus17_examples/launch/camera_example.launch.py color_detection を例示リストに追加
sciurus17_examples_py/setup.py pick_and_place_tfcolor_detection エントリポイント追加
sciurus17_examples_py/sciurus17_examples_py/pick_and_place_tf.py TFターゲットを見てピック&プレースするノードを新規追加
sciurus17_examples_py/sciurus17_examples_py/color_detection.py Python版の深度同期・3D算出・TF配信ノードを新規追加
sciurus17_examples_py/launch/camera_example.launch.py Python版のカメラ例launchを新規追加
sciurus17_examples_py/package.xml Pythonサンプル実行に必要な依存を追加
sciurus17_examples_py/README.md Python版 color_detection サンプル説明を追加

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sciurus17_examples/src/color_detection.cpp
Comment thread sciurus17_examples/src/color_detection.cpp
Comment thread sciurus17_examples/src/color_detection.cpp
Comment thread sciurus17_examples/src/color_detection.cpp Outdated
Comment thread sciurus17_examples/src/color_detection_2d.cpp
Comment thread sciurus17_examples_py/sciurus17_examples_py/color_detection.py Outdated
Comment thread sciurus17_examples_py/sciurus17_examples_py/color_detection.py
Comment thread sciurus17_examples/README.md Outdated
Comment thread sciurus17_examples_py/README.md Outdated
Comment thread sciurus17_examples/launch/camera_example.launch.py
KuraZuzu and others added 14 commits June 22, 2026 17:47
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@KuraZuzu KuraZuzu requested a review from Kuwamai June 23, 2026 06:21
@KuraZuzu

Copy link
Copy Markdown
Contributor Author

@Kuwamai レビューをお願いします。

@KuraZuzu KuraZuzu marked this pull request as ready for review June 23, 2026 06:29

@Kuwamai Kuwamai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KuraZuzu
取り急ぎドキュメントについてコメントしました。
実装について後ほど確認します 🙇

Comment thread sciurus17_examples/README.md Outdated

@Kuwamai Kuwamai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KuraZuzu コードについてもコメントしました 🙇

Comment thread sciurus17_examples_py/sciurus17_examples_py/color_detection.py
Comment thread sciurus17_examples/src/color_detection.cpp
@KuraZuzu KuraZuzu requested a review from Kuwamai June 29, 2026 05:46
@KuraZuzu

Copy link
Copy Markdown
Contributor Author

@Kuwamai
ドキュメントの説明を修正しました。
また、カメラの深度画像のifによる分岐について1点コメントに返信をしているのでご確認をお願いします。

@Kuwamai Kuwamai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

コメントだけ追記できたらあとは大丈夫そうです 🙇

@KuraZuzu

KuraZuzu commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

コメントを追加しました。ご確認をお願いします。

@KuraZuzu KuraZuzu requested a review from Kuwamai July 1, 2026 01:17

@Kuwamai Kuwamai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTMです

@Kuwamai Kuwamai merged commit aed6727 into ros2 Jul 1, 2026
2 checks passed
@Kuwamai Kuwamai deleted the feature/color_detection branch July 1, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Feature New Feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants