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

ROS 2 Jazzyへの対応 #53

Merged
merged 15 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
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
8 changes: 5 additions & 3 deletions .github/workflows/industrial_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ jobs:
industrial_ci:
strategy:
matrix:
env:
- { ROS_DISTRO: humble, ROS_REPO: ros }
ROS_DISTRO: [jazzy]
ROS_REPO: [ros]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
KuraZuzu marked this conversation as resolved.
Show resolved Hide resolved
- uses: "ros-industrial/industrial_ci@master"
env: ${{ matrix.env }}
env:
ROS_DISTRO: ${{ matrix.ROS_DISTRO }}
ROS_REPO: ${{ matrix.ROS_REPO }}
45 changes: 19 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,26 @@
# Raspimouse Node

ROS 2 node for the Raspberry Pi Mouse.

![raspimouse](https://rt-net.jp/wp-content/uploads/2020/04/Raspberry-Pi-Mouse.png)

## Build Status

### master branch

[![industrial_ci](https://github.com/rt-net/raspimouse2/workflows/industrial_ci/badge.svg?branch=master)](https://github.com/rt-net/raspimouse2/actions?query=workflow%3Aindustrial_ci+branch%3Amaster)
[![industrial_ci](https://github.com/rt-net/raspimouse2/actions/workflows/industrial_ci.yml/badge.svg?branch=master)](https://github.com/rt-net/raspimouse2/actions/workflows/industrial_ci.yml)

### Source Build Status on ROS2 Buildfarm
ROS 2 node for the Raspberry Pi Mouse.

| ROS 2 + Ubuntu | raspimouse | raspimouse_msgs |
|:---:|:---:|:---:|
| Foxy + Focal ([`foxy-devel`](https://github.com/rt-net/raspimouse2/tree/foxy-devel)) | [![Build Status](https://build.ros2.org/view/Fsrc_uF/job/Fsrc_uF__raspimouse__ubuntu_focal__source/badge/icon)](https://build.ros2.org/view/Fsrc_uF/job/Fsrc_uF__raspimouse__ubuntu_focal__source/) | [![Build Status](https://build.ros2.org/view/Fsrc_uF/job/Fsrc_uF__raspimouse_msgs__ubuntu_focal__source/badge/icon)](https://build.ros2.org/view/Fsrc_uF/job/Fsrc_uF__raspimouse_msgs__ubuntu_focal__source/) |
| Humble + Jammy ([`humble-devel`](https://github.com/rt-net/raspimouse2/tree/humble-devel)) | **TODO** | **TODO** |
![raspimouse](https://rt-net.github.io/images/raspberry-pi-mouse/Raspberry-Pi-Mouse.png)

## Requirements

- Raspberry Pi Mouse
- https://rt-net.jp/products/raspberrypimousev3/
- [RT Robot Shop](https://www.rt-shop.jp/index.php?main_page=product_info&cPath=1299_1395&products_id=3774)
- [Summary](https://rt-net.jp/products/raspberrypimousev3/)
- [RT Robot Shop](https://www.rt-shop.jp/index.php?main_page=product_info&products_id=4141)
- Linux OS
- Ubuntu server 20.04
- https://ubuntu.com/download/raspberry-pi
- Ubuntu server
- 22.04
- 24.04
- [Raspberry Pi OS](https://ubuntu.com/download/raspberry-pi)
- Device Driver
- [rt-net/RaspberryPiMouse](https://github.com/rt-net/RaspberryPiMouse)
- ROS
- [Foxy Fitzroy](https://index.ros.org/doc/ros2/Installation/Foxy/Linux-Install-Debians/)
- [Humble Hawksbill](https://docs.ros.org/en/humble/Installation/Ubuntu-Install-Debians.html)
- [Jazzy Jalisco](https://docs.ros.org/en/jazzy/Installation/Ubuntu-Install-Debs.html)

## Installation

Expand All @@ -44,7 +35,7 @@ $ sudo apt install ros-$ROS_DISTRO-raspimouse
```sh
$ cd ~/ros2_ws/src
# Clone package
$ git clone -b $ROS_DISTRO-devel https://github.com/rt-net/raspimouse2
$ git clone -b $ROS_DISTRO https://github.com/rt-net/raspimouse2

# Install dependencies
$ rosdep install -r -y -i --from-paths .
Expand All @@ -57,19 +48,21 @@ $ source ~/ros2_ws/install/setup.bash

## QuickStart

Build and install the [device driver](https://github.com/rt-net/RaspberryPiMouse) in advance.

```sh
# Terminal 1
$ source ~/ros2_ws/install/setup.bash
$ ros2 launch raspimouse raspimouse.launch.py

# Terminal 2
$ source ~/ros2_ws/install/setup.bash
$ source ~/ros2_ws/install/setup.
KuraZuzu marked this conversation as resolved.
Show resolved Hide resolved
# Set buzzer frequency
$ ros2 topic pub -1 /buzzer std_msgs/msg/Int16 '{data: 1000}'
$ ros2 topic pub -1 /buzzer std_msgs/msg/Int16 '{data: 0}'
# or rotate motors
$ ros2 service call /motor_power std_srvs/SetBool '{data: true}'
$ ros2 topic pub -1 /cmd_vel geometry_msgs/Twist '{linear: {x: 0.1, y: 0, z: 0}, angular: {x: 0, y: 0, z: 0.05}}'
$ ros2 topic pub -1 /cmd_vel geometry_msgs/msg/TwistStamped '{twist: {linear: {x: 0.05, y: 0, z: 0}, angular: {x: 0, y: 0, z: 0.05}}}'
# Shutdown
$ ros2 lifecycle set raspimouse shutdown
```
Expand Down Expand Up @@ -105,7 +98,7 @@ a velocity command.

```shell
$ ros2 service call /motor_power std_srvs/SetBool '{data: true}'
$ ros2 topic pub -1 /cmd_vel geometry_msgs/Twist '{linear: {x: 0.1, y: 0, z: 0}, angular: {x: 0, y: 0, z: 0.05}}'
$ ros2 topic pub -1 /cmd_vel geometry_msgs/msg/TwistStamped '{twist: {linear: {x: 0.1, y: 0, z: 0}, angular: {x: 0, y: 0, z: 0.05}}}'
```

Odometry information can be checked by echoing the `odom` topic.
Expand All @@ -129,7 +122,7 @@ Similarly other sensor information can also be viewed by echoing the relevant to

- `cmd_vel`

Type: `geometry_msgs/Twist`
Type: `geometry_msgs/msg/TwistStamped`

Controls the motors. Specify the forward and turning speeds of the robot.

Expand Down Expand Up @@ -220,7 +213,7 @@ Similarly other sensor information can also be viewed by echoing the relevant to

Sets the diameter of the robot's wheel.
The unit is in meters.

- `wheel_tread`

Type: `double`
Expand Down Expand Up @@ -298,7 +291,7 @@ Similarly other sensor information can also be viewed by echoing the relevant to

Adds prefix to the frames of the topic `odom`.
If set as *`mouse`*, the frame_id and the child_frame_id will be *`mouse/odom`* and *`mouse/baes_footprint`*.

## License

This repository is licensed under the Apache 2.0, see [LICENSE](./LICENSE) for details.
Expand Down
5 changes: 3 additions & 2 deletions raspimouse/include/raspimouse/raspimouse_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ extern "C" {
#include <std_msgs/msg/int16.hpp>
#include <std_srvs/srv/set_bool.hpp>
#include <nav_msgs/msg/odometry.hpp>
#include <geometry_msgs/msg/twist_stamped.hpp>

#include <raspimouse_msgs/msg/leds.hpp>
#include <raspimouse_msgs/msg/switches.hpp>
Expand Down Expand Up @@ -97,7 +98,7 @@ class Raspimouse : public rclcpp_lifecycle::LifecycleNode
int last_pulse_count_left_;
int last_pulse_count_right_;

rclcpp::Subscription<geometry_msgs::msg::Twist>::SharedPtr velocity_sub_;
rclcpp::Subscription<geometry_msgs::msg::TwistStamped>::SharedPtr velocity_sub_;
rclcpp::Service<std_srvs::srv::SetBool>::SharedPtr power_service_;
rclcpp::TimerBase::SharedPtr watchdog_timer_;

Expand Down Expand Up @@ -136,7 +137,7 @@ class Raspimouse : public rclcpp_lifecycle::LifecycleNode
void publish_switches();
void publish_light_sensors();

void velocity_command(const geometry_msgs::msg::Twist::SharedPtr msg);
void velocity_command(const geometry_msgs::msg::TwistStamped::SharedPtr msg);
void leds_command(const raspimouse_msgs::msg::Leds::SharedPtr msg);
void buzzer_command(const std_msgs::msg::Int16::SharedPtr msg);

Expand Down
4 changes: 2 additions & 2 deletions raspimouse/launch/raspimouse.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
from launch.events import matches_action
from launch.events import Shutdown
from launch_ros.actions import LifecycleNode
from launch_ros.events import lifecycle
from launch_ros.event_handlers import OnStateTransition
from launch_ros.events import lifecycle
from lifecycle_msgs.msg import Transition


Expand All @@ -33,7 +33,7 @@ def generate_launch_description():
package='raspimouse', executable='raspimouse', output='screen',
parameters=[os.path.join(get_package_share_directory(
'raspimouse'), 'config', 'params.yaml')]
)
)

emit_configuring_event = EmitEvent(
event=lifecycle.ChangeState(
Expand Down
1 change: 1 addition & 0 deletions raspimouse/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<author email="daisuke.sato@rt-net.jp">Daisuke Sato</author>
<author email="kozasa@rt-net.jp">Shuhei Kozasa</author>
<author email="git@killbots.net">Geoffrey Biggs</author>
<author email="kurasawa@rt-net.jp">Kazushi Kurasawa</author>

<buildtool_depend>ament_cmake</buildtool_depend>

Expand Down
9 changes: 5 additions & 4 deletions raspimouse/src/raspimouse_component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "rclcpp/rclcpp.hpp"
#include "rosidl_runtime_cpp/message_initialization.hpp"
#include "lifecycle_msgs/msg/transition.hpp"
#include "geometry_msgs/msg/twist_stamped.hpp"

#define _USE_MATH_DEFINES

Expand Down Expand Up @@ -128,7 +129,7 @@ CallbackReturn Raspimouse::on_configure(const rclcpp_lifecycle::State &)
odom_timer_->cancel();

// Subscriber for velocity commands
velocity_sub_ = create_subscription<geometry_msgs::msg::Twist>(
velocity_sub_ = create_subscription<geometry_msgs::msg::TwistStamped>(
"cmd_vel", 10, std::bind(&Raspimouse::velocity_command, this, _1));

// Motor power control service
Expand Down Expand Up @@ -431,10 +432,10 @@ void Raspimouse::publish_light_sensors()
light_sensors_pub_->publish(sensor_values);
}

void Raspimouse::velocity_command(const geometry_msgs::msg::Twist::SharedPtr msg)
void Raspimouse::velocity_command(const geometry_msgs::msg::TwistStamped::SharedPtr msg)
{
linear_velocity_ = msg->linear.x;
angular_velocity_ = msg->angular.z;
linear_velocity_ = msg->twist.linear.x;
angular_velocity_ = msg->twist.angular.z;

const auto WHEEL_DIAMETER = get_parameter(WHEEL_DIAMETER_PARAM).get_value<double>();
const auto WHEEL_TREAD = get_parameter(WHEEL_TREAD_PARAM).get_value<double>();
Expand Down
Loading