Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

頭部、胸部カメラサンプル追加 #153

Merged
merged 55 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
943a2fd
依存パッケージの追加
Kuwamai Nov 24, 2023
60e08ba
head_camera_tracking MoveIt版
Kuwamai Nov 24, 2023
ef48959
クラスの分割
Kuwamai Dec 4, 2023
9ba146e
トラッキング動作をmain関数に移動
Kuwamai Dec 5, 2023
a781ef2
依存パッケージ追加
Kuwamai Dec 5, 2023
c2d436f
不要な行の削除
Kuwamai Dec 6, 2023
3db140c
コメント追加
Kuwamai Dec 6, 2023
d07381e
制御周期変更
Kuwamai Dec 6, 2023
49f4c90
追従処理をクラス化
Kuwamai Dec 7, 2023
8459f5f
不要な変数を削除
Kuwamai Dec 8, 2023
806a4ca
component node化
Kuwamai Dec 11, 2023
9964ce5
install記述追加
Kuwamai Dec 11, 2023
1e9ecfb
rename
Kuwamai Dec 11, 2023
428eaec
不要な変数を削除
Kuwamai Dec 11, 2023
adf17c9
配列サイズのチェック
Kuwamai Dec 11, 2023
f496cab
yaw、pitch軸の処理をfor文に置き換え
Kuwamai Dec 12, 2023
31013e2
action serverの確認をコンストラクタ内で実行
Kuwamai Dec 12, 2023
73d8de7
プロセス内通信を有効化
Kuwamai Dec 12, 2023
6addaee
action動作が完了したか確認する処理を追加
Kuwamai Dec 12, 2023
285b297
コメント修正
Kuwamai Dec 12, 2023
9509062
コメント修正
Kuwamai Dec 12, 2023
73c5a3b
角度制限の定義箇所を変更
Kuwamai Dec 12, 2023
c879424
コメント修正
Kuwamai Dec 12, 2023
63965e2
スタイル修正
Kuwamai Dec 12, 2023
e9dd3f2
パラメータ調整
Kuwamai Dec 12, 2023
b4fac91
スタイル修正
Kuwamai Dec 12, 2023
5d97674
use_sim_timeオプション追加
Kuwamai Dec 13, 2023
b5776d4
コメント修正
Kuwamai Dec 13, 2023
8cabc07
README更新
Kuwamai Dec 13, 2023
424eaae
不要な記述を削除
Kuwamai Dec 13, 2023
77c9f54
依存パッケージ修正
Kuwamai Dec 13, 2023
8a8a770
ディレクトリ名変更
Kuwamai Dec 13, 2023
9f6afd9
誤字修正
Kuwamai Dec 13, 2023
88f1189
joint_trajectoryの配信をactionからtopicに変更
Kuwamai Dec 15, 2023
6d2d154
動作周期調整
Kuwamai Dec 15, 2023
472f82e
腰追従動作用コード追加
Kuwamai Dec 18, 2023
d3367f3
ファイル名変更
Kuwamai Dec 18, 2023
d4c999f
waist_jt_controller追加
Kuwamai Dec 18, 2023
8fe900c
Topic名変更
Kuwamai Dec 18, 2023
1e4aafd
chest_camera_tracking.launch.py追加
Kuwamai Dec 18, 2023
dc9df1e
namespace変更
Kuwamai Dec 18, 2023
b297cc7
スタイル修正
Kuwamai Dec 18, 2023
6db42c2
Update README
Kuwamai Dec 18, 2023
a1d5af7
胸部カメラパス変更
Kuwamai Dec 26, 2023
5f71ddf
不要な処理を削除
Kuwamai Dec 26, 2023
3264c14
不要なパッケージを削除
Kuwamai Dec 26, 2023
69d9ca0
不要なコメントの削除
Kuwamai Dec 26, 2023
dc83799
腰、首の関節数を変数化
Kuwamai Dec 26, 2023
e58f2a1
RCLCPP_INFOをDEBUGに変更
Kuwamai Dec 26, 2023
d2e3757
topic名を抽象的なものに変更
Kuwamai Jan 9, 2024
1a6d958
一番大きく映った領域のみを検出
Kuwamai Jan 11, 2024
819c418
remap修正
Kuwamai Jan 11, 2024
d780339
誤字修正
Kuwamai Jan 11, 2024
9b46ee1
パラメータ調整
Kuwamai Jan 11, 2024
19f7faa
変数名変更
Kuwamai Jan 12, 2024
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
53 changes: 53 additions & 0 deletions sciurus17_examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,57 @@ endif()
# find dependencies
find_package(ament_cmake REQUIRED)
find_package(angles REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(control_msgs REQUIRED)
find_package(image_geometry REQUIRED)
find_package(moveit_ros_planning_interface REQUIRED)
find_package(OpenCV REQUIRED COMPONENTS core)
find_package(rclcpp REQUIRED)
find_package(tf2_geometry_msgs REQUIRED)
find_package(rclcpp_action REQUIRED)
find_package(rclcpp_components REQUIRED)

include_directories(include)

set(components_list
color_detection
neck_jt_control
object_tracker
waist_jt_control
)
foreach(loop_var IN LISTS components_list)
add_library(${loop_var} SHARED
src/${loop_var}.cpp)
target_compile_definitions(${loop_var}
PRIVATE "COMPOSITION_BUILDING_DLL")
ament_target_dependencies(${loop_var}
angles
rclcpp_components
rclcpp_action
cv_bridge
geometry_msgs
image_geometry
OpenCV
rclcpp
control_msgs)
endforeach()

rclcpp_components_register_nodes(color_detection "sciurus17_examples::ColorDetection")
rclcpp_components_register_nodes(neck_jt_control "sciurus17_examples::NeckJtControl")
rclcpp_components_register_nodes(object_tracker "sciurus17_examples::ObjectTracker")
rclcpp_components_register_nodes(waist_jt_control "sciurus17_examples::WaistJtControl")

install(TARGETS
color_detection
neck_jt_control
object_tracker
waist_jt_control
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)

set(LIBRARY_NAME "pose_presets")
add_library(${LIBRARY_NAME}
Expand Down Expand Up @@ -73,9 +120,15 @@ foreach(loop_var IN LISTS executable_list)
add_executable(${loop_var} src/${loop_var}.cpp)
target_link_libraries(${loop_var} ${LIBRARY_NAME})
ament_target_dependencies(${loop_var}
rclcpp_action
cv_bridge
geometry_msgs
image_geometry
moveit_ros_planning_interface
OpenCV
rclcpp
tf2_geometry_msgs
control_msgs
)

install(TARGETS
Expand Down
38 changes: 38 additions & 0 deletions sciurus17_examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
- [waist\_control](#waist_control)
- [pick\_and\_place\_right\_arm\_waist](#pick_and_place_right_arm_waist)
- [pick\_and\_place\_left\_arm](#pick_and_place_left_arm)
- [head\_camera\_tracking](#head_camera_tracking)
- [chest\_camera\_tracking](#chest_camera_tracking)

## 準備(実機を使う場合)

Expand Down Expand Up @@ -89,6 +91,8 @@ ros2 launch sciurus17_examples example.launch.py example:='gripper_control' use_
- [waist\_control](#waist_control)
- [pick\_and\_place\_right\_arm\_waist](#pick_and_place_right_arm_waist)
- [pick\_and\_place\_left\_arm](#pick_and_place_left_arm)
- [head\_camera\_tracking](#head_camera_tracking)
- [chest\_camera\_tracking](#chest_camera_tracking)

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

Expand Down Expand Up @@ -165,3 +169,37 @@ ros2 launch sciurus17_examples example.launch.py example:='pick_and_place_left_a
[back to example list](#examples)

---

### head_camera_tracking

頭部カメラ映像を用いてオレンジ色の物体を追従するコード例です。

Gazeboで実行する場合は動作環境によってうまく追従しない場合があります。
カメラ解像度やサンプルコード内の追従速度ゲインを調整してください。

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

```sh
ros2 launch sciurus17_examples head_camera_tracking.launch.py
```

[back to example list](#examples)

---

### chest_camera_tracking

胸部カメラ映像を用いてオレンジ色の物体を追従するコード例です。

Gazeboで実行する場合は動作環境によってうまく追従しない場合があります。
カメラ解像度やサンプルコード内の追従速度ゲインを調整してください。

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

```sh
ros2 launch sciurus17_examples chest_camera_tracking.launch.py
```

[back to example list](#examples)

---
42 changes: 42 additions & 0 deletions sciurus17_examples/include/sciurus17_examples/color_detection.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2023 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.

#ifndef SCIURUS17_EXAMPLES__COLOR_DETECTION_HPP_
#define SCIURUS17_EXAMPLES__COLOR_DETECTION_HPP_

#include "rclcpp/rclcpp.hpp"
#include "geometry_msgs/msg/point_stamped.hpp"
#include "sensor_msgs/msg/image.hpp"
#include "opencv2/opencv.hpp"

namespace sciurus17_examples
{

class ColorDetection : public rclcpp::Node
{
public:
explicit ColorDetection(const rclcpp::NodeOptions & options);

private:
rclcpp::Subscription<sensor_msgs::msg::Image>::SharedPtr image_subscription_;
rclcpp::Publisher<sensor_msgs::msg::Image>::SharedPtr image_annotated_publisher_;
rclcpp::Publisher<geometry_msgs::msg::PointStamped>::SharedPtr object_point_publisher_;
rclcpp::TimerBase::SharedPtr timer_;

void image_callback(const sensor_msgs::msg::Image::SharedPtr msg);
};

} // namespace sciurus17_examples

#endif // SCIURUS17_EXAMPLES__COLOR_DETECTION_HPP_
39 changes: 39 additions & 0 deletions sciurus17_examples/include/sciurus17_examples/neck_jt_control.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright 2023 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.

#ifndef SCIURUS17_EXAMPLES__NECK_JT_CONTROL_HPP_
#define SCIURUS17_EXAMPLES__NECK_JT_CONTROL_HPP_

#include "rclcpp/rclcpp.hpp"
#include "trajectory_msgs/msg/joint_trajectory.hpp"
#include "std_msgs/msg/float64_multi_array.hpp"

namespace sciurus17_examples
{

class NeckJtControl : public rclcpp::Node
{
public:
explicit NeckJtControl(const rclcpp::NodeOptions & options);

private:
rclcpp::Subscription<std_msgs::msg::Float64MultiArray>::SharedPtr angles_subscription_;
rclcpp::Publisher<trajectory_msgs::msg::JointTrajectory>::SharedPtr jt_publisher_;

void angles_callback(const std_msgs::msg::Float64MultiArray::SharedPtr msg);
};

} // namespace sciurus17_examples

#endif // SCIURUS17_EXAMPLES__NECK_JT_CONTROL_HPP_
51 changes: 51 additions & 0 deletions sciurus17_examples/include/sciurus17_examples/object_tracker.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright 2023 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.

#ifndef SCIURUS17_EXAMPLES__OBJECT_TRACKER_HPP_
#define SCIURUS17_EXAMPLES__OBJECT_TRACKER_HPP_

#include <vector>

#include "rclcpp/rclcpp.hpp"
#include "control_msgs/msg/joint_trajectory_controller_state.hpp"
#include "geometry_msgs/msg/point_stamped.hpp"
#include "sensor_msgs/msg/image.hpp"
#include "std_msgs/msg/float64_multi_array.hpp"

namespace sciurus17_examples
{

class ObjectTracker : public rclcpp::Node
{
public:
explicit ObjectTracker(const rclcpp::NodeOptions & options);

private:
rclcpp::TimerBase::SharedPtr timer_;
rclcpp::Subscription<control_msgs::msg::JointTrajectoryControllerState>::SharedPtr
state_subscription_;
rclcpp::Subscription<geometry_msgs::msg::PointStamped>::SharedPtr object_point_subscription_;
rclcpp::Publisher<std_msgs::msg::Float64MultiArray>::SharedPtr angles_publisher_;
control_msgs::msg::JointTrajectoryControllerState::SharedPtr current_angles_msg_;
geometry_msgs::msg::PointStamped::SharedPtr object_point_msg_;
std::vector<double> target_angles_;

void state_callback(const control_msgs::msg::JointTrajectoryControllerState::SharedPtr msg);
void point_callback(const geometry_msgs::msg::PointStamped::SharedPtr msg);
void tracking();
};

} // namespace sciurus17_examples

#endif // SCIURUS17_EXAMPLES__OBJECT_TRACKER_HPP_
40 changes: 40 additions & 0 deletions sciurus17_examples/include/sciurus17_examples/waist_jt_control.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright 2023 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.

#ifndef SCIURUS17_EXAMPLES__WAIST_JT_CONTROL_HPP_
#define SCIURUS17_EXAMPLES__WAIST_JT_CONTROL_HPP_

#include "rclcpp/rclcpp.hpp"
#include "rclcpp_action/rclcpp_action.hpp"
#include "trajectory_msgs/msg/joint_trajectory.hpp"
#include "std_msgs/msg/float64_multi_array.hpp"

namespace sciurus17_examples
{

class WaistJtControl : public rclcpp::Node
{
public:
explicit WaistJtControl(const rclcpp::NodeOptions & options);

private:
rclcpp::Subscription<std_msgs::msg::Float64MultiArray>::SharedPtr angles_subscription_;
rclcpp::Publisher<trajectory_msgs::msg::JointTrajectory>::SharedPtr jt_publisher_;

void angles_callback(const std_msgs::msg::Float64MultiArray::SharedPtr msg);
};

} // namespace sciurus17_examples

#endif // SCIURUS17_EXAMPLES__WAIST_JT_CONTROL_HPP_
70 changes: 70 additions & 0 deletions sciurus17_examples/launch/chest_camera_tracking.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Copyright 2023 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.

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import ComposableNodeContainer
from launch_ros.actions import SetParameter
from launch_ros.descriptions import ComposableNode


def generate_launch_description():
declare_use_sim_time = DeclareLaunchArgument(
'use_sim_time', default_value='false',
description=('Set true when using the gazebo simulator.')
)

container = ComposableNodeContainer(
name='tracking_container',
namespace='head_camera_tracking',
package='rclcpp_components',
executable='component_container',
composable_node_descriptions=[
ComposableNode(
package='sciurus17_examples',
plugin='sciurus17_examples::ColorDetection',
name='color_detection',
namespace='chest_camera_tracking',
remappings=[
('/image_raw', '/chest_camera/image_raw')
],
extra_arguments=[{'use_intra_process_comms': True}]
),
ComposableNode(
package='sciurus17_examples',
plugin='sciurus17_examples::ObjectTracker',
name='object_tracker',
namespace='chest_camera_tracking',
remappings=[
('/controller_state', '/waist_yaw_controller/controller_state')
],
extra_arguments=[{'use_intra_process_comms': True}]
),
ComposableNode(
package='sciurus17_examples',
plugin='sciurus17_examples::WaistJtControl',
name='waist_jt_control',
namespace='chest_camera_tracking',
extra_arguments=[{'use_intra_process_comms': True}]
),
],
output='screen',
)

return LaunchDescription([
declare_use_sim_time,
SetParameter(name='use_sim_time', value=LaunchConfiguration('use_sim_time')),
container
])
Loading