Skip to content

Commit

Permalink
ROS 2 Jazzy対応 (#62)
Browse files Browse the repository at this point in the history
* The header file "cv_bridge.h" in the cv_bridge package has been renamed to "cv_bridge.hpp". This change has been applied to all corresponding "#include" statements.

* Replaced "Twist" with "TwistStamped" in "joystick_control.py"

* Replaced "Twist" with "TwistStamped" for "camera_line_follower.launch.py"

* Replaced "Twist" with "TwistStamped" for "object_tracking.launch.py"

* Replaced "Twist" with "TwistStamped" (Changed in all instances, revert if any unexpected issues occur, "revert").

* Modify CI to ensure compatibility with the act tool

* Add author

* Update README for Support Jazzy

* Add CI settings for Rolling

* Revert "Add CI settings for Rolling"

This reverts commit 5996db3.

* Replace ROS_REPO: [ros] with ROS_REPO: [main]

* Add rosinstall for CI

* Adapt clang-format with Google style

* Fix order of include in c file

* Revert "Add rosinstall for CI"

This reverts commit b9605cd.

* Reapply "Add rosinstall for CI"

This reverts commit a06b8a9.

* Revert "Fix order of include in c file"

This reverts commit 356a417.

* Revert "Adapt clang-format with Google style"

This reverts commit 0a42043.

* fix typo of distribution name

* Applied "ament_clang_format" and passed cpplint, with manual adjustments made to the "include" order

* Adapted ruff formetter

* fix "import" module order

* Adaptted "ament_uncrustify"

* Update README.en.md fo Jazzy

* Fix pictures and page links

* Fix images for README in japanese

* Update Copyright years

* Fix Indent and replace .h with .hpp

* FIxed autho name

* Add warnings for camera settings
  • Loading branch information
KuraZuzu authored Nov 25, 2024
1 parent b049273 commit b0ac055
Show file tree
Hide file tree
Showing 25 changed files with 510 additions and 473 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/.ci.rosinstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- git:
uri: https://github.com/rt-net/raspimouse2.git
local-name: raspimouse2
version: jazzy
- git:
uri: https://github.com/rt-net/rt_usb_9axisimu_driver.git
local-name: rt_usb_9axisimu_driver
version: jazzy
13 changes: 9 additions & 4 deletions .github/workflows/industrial_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,21 @@ on:
schedule:
- cron: "0 2 * * 0" # Weekly on Sundays at 02:00

env:
UPSTREAM_WORKSPACE: .github/workflows/.ci.rosinstall

jobs:
industrial_ci:
strategy:
fail-fast: false
matrix:
env:
- { ROS_DISTRO: humble, ROS_REPO: ros }
ROS_DISTRO: [jazzy]
ROS_REPO: [main]

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: "ros-industrial/industrial_ci@master"
env: ${{ matrix.env }}
env:
ROS_DISTRO: ${{matrix.ROS_DISTRO}}
ROS_REPO: ${{matrix.ROS_REPO}}
35 changes: 18 additions & 17 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,24 @@ To run on Gazebo, click [here](https://github.com/rt-net/raspimouse_sim/blob/ros

## Supported ROS 2 distributions

- [Foxy](https://github.com/rt-net/raspimouse_ros2_examples/tree/foxy-devel)
- Humble (This branch)
- [Humble](https://github.com/rt-net/raspimouse_ros2_examples/tree/humble)
- [Jazzy](https://github.com/rt-net/raspimouse_ros2_examples/tree/jazzy) (This branch)

## Requirements

- Raspberry Pi Mouse
- https://rt-net.jp/products/raspberrypimousev3/
- Linux OS
- Ubuntu server 22.04
- https://ubuntu.com/download/raspberry-pi
- Ubuntu server 24.04
- Device Driver
- [rt-net/RaspberryPiMouse](https://github.com/rt-net/RaspberryPiMouse)
- ROS
- [Humble Hawksbill](https://docs.ros.org/en/humble/Installation/Ubuntu-Install-Debians.html)
- [Jazzy Jalisco](https://docs.ros.org/en/jazzy/index.html)
- Raspberry Pi Mouse ROS 2 package
- https://github.com/rt-net/raspimouse2
- Remote Computer (Optional)
- ROS
- [Humble Hawksbill](https://docs.ros.org/en/humble/Installation/Ubuntu-Install-Debians.html)
- [Jazzy Jalisco](https://docs.ros.org/en/jazzy/index.html)
- Raspberry Pi Mouse ROS 2 package
- https://github.com/rt-net/raspimouse2

Expand All @@ -41,7 +40,7 @@ To run on Gazebo, click [here](https://github.com/rt-net/raspimouse_sim/blob/ros
```sh
$ cd ~/ros2_ws/src
# Clone package
$ git clone -b $ROS_DISTRO-devel https://github.com/rt-net/raspimouse_ros2_examples.git
$ git clone -b $ROS_DISTRO https://github.com/rt-net/raspimouse_ros2_examples.git

# Install dependencies
$ rosdep install -r -y --from-paths . --ignore-src
Expand Down Expand Up @@ -71,7 +70,7 @@ This repository is licensed under the Apache 2.0, see [LICENSE](./LICENSE) for d

This is an example to use joystick controller to control a Raspberry Pi Mouse.

#### Requirements
#### Requirements

- Joystick Controller
- [Logicool Wireless Gamepad F710](https://gaming.logicool.co.jp/ja-jp/products/gamepads/f710-wireless-gamepad.html#940-0001440)
Expand Down Expand Up @@ -122,15 +121,15 @@ button_cmd_enable : 4
[back to example list](#how-to-use-examples)
---
---
### object_tracking
<img src=https://rt-net.github.io/images/raspberry-pi-mouse/object_tracking.JPG width=500 />
This is an example to use RGB camera images and OpenCV library for object tracking.
#### Requirements
#### Requirements
- Web camera
- [Logicool HD WEBCAM C310N](https://www.logicool.co.jp/ja-jp/product/hd-webcam-c310n)
Expand Down Expand Up @@ -190,7 +189,7 @@ void Tracker::tracking(const cv::Mat & input_frame, cv::Mat & result_frame)
[back to example list](#how-to-use-examples)
---
---
### line_follower
Expand Down Expand Up @@ -256,7 +255,7 @@ void Follower::publish_cmdvel_for_line_following(void)
This is an example for line following by RGB camera.
#### Requirements
#### Requirements
- Web camera
- [Logicool HD WEBCAM C310N](https://www.logicool.co.jp/ja-jp/product/hd-webcam-c310n)
Expand Down Expand Up @@ -285,6 +284,8 @@ or [rqt_image_view](https://index.ros.org/p/rqt_image_view/).

**Viewing an image may cause the node to behave unstable and not publish cmd_vel or image topics.**

**If the line detection accuracy is poor, please adjust the camera's exposure and white balance.**

<img src=https://rt-net.github.io/images/raspberry-pi-mouse/camera_line_trace.png width=500 />

#### Parameters
Expand Down Expand Up @@ -316,7 +317,7 @@ ros2 param set /camera_follower max_brightness 80

[back to example list](#how-to-use-examples)

---
---

### SLAM

Expand All @@ -330,13 +331,13 @@ SLAM and Navigation examples for Raspberry Pi Mouse is [here](https://github.com

### direction_controller

<img src=https://www.rt-net.jp/wp-content/uploads/2018/02/img-usb9s_01.png width=500 />
<img src=https://www.rt-shop.jp/images/RT/RT-USB-9axisIMU.png width=200 /> <img src=https://www.rt-shop.jp/images/RT/%E8%A3%BD%E5%93%81%E5%86%99%E7%9C%9F.JPG height=200>

This is an example to use an IMU sensor for direction control.

#### Requirements

- [USB output 9 degrees IMU sensor module](https://www.rt-shop.jp/index.php?main_page=product_info&cPath=1348_1&products_id=3416&language=en)
- [USB output 9 degrees IMU sensor module](https://www.rt-shop.jp/index.php?main_page=product_info&products_id=3416&language=en)
- [LiDAR Mount](https://www.rt-shop.jp/index.php?main_page=product_info&cPath=1299_1395&products_id=3867)
- RT-USB-9axisIMU ROS Package.
- https://github.com/rt-net/rt_usb_9axisimu_driver
Expand Down Expand Up @@ -369,8 +370,8 @@ Then, press SW0 ~ SW2 to change the control mode as following,

### Troubleshooting

The IMU might not be connected correctly.
Reconnect the USB cable several times and re-execute the above command.
The IMU might not be connected correctly.
Reconnect the USB cable several times and re-execute the above command.

#### Configure

Expand Down
43 changes: 22 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,24 @@ Gazebo(シミュレータ)でも動作します。詳細は[こちら](https

## Supported ROS 2 distributions

- [Foxy](https://github.com/rt-net/raspimouse_ros2_examples/tree/foxy-devel)
- Humble (This branch)
- [Humble](https://github.com/rt-net/raspimouse_ros2_examples/tree/humble)
- [Jazzy](https://github.com/rt-net/raspimouse_ros2_examples/tree/jazzy) (This branch)

## Requirements

- Raspberry Pi Mouse
- https://rt-net.jp/products/raspberrypimousev3/
- Linux OS
- Ubuntu server 22.04
- https://ubuntu.com/download/raspberry-pi
- Ubuntu server 24.04
- Device Driver
- [rt-net/RaspberryPiMouse](https://github.com/rt-net/RaspberryPiMouse)
- ROS
- [Humble Hawksbill](https://docs.ros.org/en/humble/Installation/Ubuntu-Install-Debians.html)
- [Jazzy Jalisco](https://docs.ros.org/en/jazzy/index.html)
- Raspberry Pi Mouse ROS 2 package
- https://github.com/rt-net/raspimouse2
- Remote Computer (Optional)
- ROS
- [Humble Hawksbill](https://dcs.ros.org/en/humble/Installation/Ubuntu-Install-Debians.html)
- [Jazzy Jalisco](https://docs.ros.org/en/jazzy/index.html)
- Raspberry Pi Mouse ROS 2 package
- https://github.com/rt-net/raspimouse2

Expand All @@ -41,7 +40,7 @@ Gazebo(シミュレータ)でも動作します。詳細は[こちら](https
```sh
$ cd ~/ros2_ws/src
# Clone package
$ git clone -b $ROS_DISTRO-devel https://github.com/rt-net/raspimouse_ros2_examples.git
$ git clone -b $ROS_DISTRO https://github.com/rt-net/raspimouse_ros2_examples.git

# Install dependencies
$ rosdep install -r -y --from-paths . --ignore-src
Expand All @@ -54,7 +53,7 @@ $ source ~/ros2_ws/install/setup.bash

## License

このリポジトリはApache 2.0ライセンスの元、公開されています。
このリポジトリはApache 2.0ライセンスの元、公開されています。
ライセンスについては[LICENSE](./LICENSE)を参照ください。

## How To Use Examples
Expand All @@ -72,7 +71,7 @@ $ source ~/ros2_ws/install/setup.bash

ジョイスティックコントローラでRaspberryPiMouseを動かすコード例です。

#### Requirements
#### Requirements

- Joystick Controller
- [Logicool Wireless Gamepad F710](https://gaming.logicool.co.jp/ja-jp/products/gamepads/f710-wireless-gamepad.html#940-0001440)
Expand Down Expand Up @@ -123,7 +122,7 @@ button_cmd_enable : 4
[back to example list](#how-to-use-examples)
---
---
### object_tracking
Expand All @@ -132,7 +131,7 @@ button_cmd_enable : 4
色情報をもとにオレンジ色のボールの追跡を行うコード例です。
USB接続のWebカメラとOpenCVを使ってボール追跡をします。
#### Requirements
#### Requirements
- Webカメラ
- [Logicool HD WEBCAM C310N](https://www.logicool.co.jp/ja-jp/product/hd-webcam-c310n)
Expand Down Expand Up @@ -194,7 +193,7 @@ void Tracker::tracking(const cv::Mat & input_frame, cv::Mat & result_frame)
[back to example list](#how-to-use-examples)
---
---
### line_follower
Expand Down Expand Up @@ -252,15 +251,15 @@ void Follower::publish_cmdvel_for_line_following(void)
[back to example list](#how-to-use-examples)
---
---
### camera_line_follower
<img src=https://rt-net.github.io/images/raspberry-pi-mouse/mouse_camera_line_trace_2.png width=500 />
RGBカメラによるライントレースのコード例です。
#### Requirements
#### Requirements
- Webカメラ
- [Logicool HD WEBCAM C310N](https://www.logicool.co.jp/ja-jp/product/hd-webcam-c310n)
Expand Down Expand Up @@ -289,6 +288,8 @@ $ ros2 launch raspimouse_ros2_examples camera_line_follower.launch.py video_devi

**画像を表示するとノードの動作が不安定になり、cmd_velや画像トピックが発行されないことがあります。**

**ラインの検出精度が悪い場合はカメラの露光やホワイトバランスの調整を行ってください。**

<img src=https://rt-net.github.io/images/raspberry-pi-mouse/camera_line_trace.png width=500 />

#### Parameters
Expand All @@ -309,7 +310,7 @@ $ ros2 launch raspimouse_ros2_examples camera_line_follower.launch.py video_devi
- Type: `double`
- Default: 0.8
- 旋回速度の最大値
- `area_threthold`
- `area_threshold`
- Type: `double`
- Default: 0.20
- 走行を開始するためのライン面積のしきい値
Expand All @@ -320,7 +321,7 @@ ros2 param set /camera_follower max_brightness 80

[back to example list](#how-to-use-examples)

---
---

### SLAM

Expand All @@ -334,7 +335,7 @@ Raspberry Pi MouseでSLAMとNavigationを行うサンプルは[rt-net/raspimouse

### direction_controller

<img src=https://www.rt-net.jp/wp-content/uploads/2018/02/img-usb9s_01.png width=500 />
<img src=https://www.rt-shop.jp/images/RT/RT-USB-9axisIMU.png width=200 /> <img src=https://www.rt-shop.jp/images/RT/%E8%A3%BD%E5%93%81%E5%86%99%E7%9C%9F.JPG height=200>

IMUセンサを使用した角度制御のコード例です。

Expand Down Expand Up @@ -373,9 +374,9 @@ SW0 ~ SW2を押して動作モードを切り替えます。

### Troubleshooting

IMUの接続が正常に行われない場合があります。
その時は、IMUのUSBケーブルを抜き差ししてください。
抜き差し実施後は、コマンドを再度実行してください。
IMUの接続が正常に行われない場合があります。
その時は、IMUのUSBケーブルを抜き差ししてください。
抜き差し実施後は、コマンドを再度実行してください。

#### Configure

Expand Down Expand Up @@ -410,7 +411,7 @@ Set parameter successful
- Target angle for the SW1 control mode.
- default: 0.0, min:-π, max:+π
- type: double

#### Publish topics
- heading_angle
- Heading angle of the robot that calculated from the IMU module sensor values.
Expand Down
33 changes: 16 additions & 17 deletions include/raspimouse_ros2_examples/camera_line_follower_component.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 RT Corporation
// Copyright 2023-2024 RT Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -19,14 +19,14 @@
#include <string>

#include "raspimouse_msgs/msg/switches.hpp"
#include "raspimouse_ros2_examples/visibility_control.h"
#include "raspimouse_ros2_examples/visibility_control.hpp"
#include "rclcpp/rclcpp.hpp"
#include "rclcpp_lifecycle/lifecycle_node.hpp"
#include "rclcpp_lifecycle/lifecycle_publisher.hpp"
#include "std_msgs/msg/string.hpp"
#include "std_srvs/srv/set_bool.hpp"
#include "sensor_msgs/msg/image.hpp"
#include "geometry_msgs/msg/twist.hpp"
#include "geometry_msgs/msg/twist_stamped.hpp"
#include "opencv2/highgui/highgui.hpp"

namespace camera_line_follower
Expand All @@ -50,30 +50,29 @@ class CameraFollower : public rclcpp_lifecycle::LifecycleNode
cv::Point2d object_normalized_point_;
double object_normalized_area_;
std::shared_ptr<rclcpp_lifecycle::LifecyclePublisher<sensor_msgs::msg::Image>> result_image_pub_;
std::shared_ptr<rclcpp_lifecycle::LifecyclePublisher<geometry_msgs::msg::Twist>> cmd_vel_pub_;
std::shared_ptr<rclcpp_lifecycle::LifecyclePublisher<geometry_msgs::msg::TwistStamped>>
cmd_vel_pub_;
std::shared_ptr<rclcpp::Client<std_srvs::srv::SetBool>> motor_power_client_;
rclcpp::Subscription<sensor_msgs::msg::Image>::SharedPtr image_sub_;
rclcpp::Subscription<raspimouse_msgs::msg::Switches>::SharedPtr switches_sub_;
rclcpp::TimerBase::SharedPtr cmd_vel_timer_;

void set_motor_power(const bool motor_on);
std::string mat_type2encoding(const int mat_type) const;
void convert_frame_to_message(
const cv::Mat & frame,
sensor_msgs::msg::Image & msg) const;
void convert_frame_to_message(const cv::Mat & frame, sensor_msgs::msg::Image & msg) const;

bool detect_line(const cv::Mat & input_frame, cv::Mat & result_frame);

rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn
on_configure(const rclcpp_lifecycle::State &);
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn
on_activate(const rclcpp_lifecycle::State &);
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn
on_deactivate(const rclcpp_lifecycle::State &);
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn
on_cleanup(const rclcpp_lifecycle::State &);
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn
on_shutdown(const rclcpp_lifecycle::State &);
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn on_configure(
const rclcpp_lifecycle::State &);
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn on_activate(
const rclcpp_lifecycle::State &);
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn on_deactivate(
const rclcpp_lifecycle::State &);
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn on_cleanup(
const rclcpp_lifecycle::State &);
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn on_shutdown(
const rclcpp_lifecycle::State &);
};

} // namespace camera_line_follower
Expand Down
Loading

0 comments on commit b0ac055

Please sign in to comment.