GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - NITKK-ROS-Team/rpios_ros2_lecture: RaspberryPi OS Bookworm & ROS 2 lecture

BranchesTags
Open more actions menu

Latest commit

 

History

9 Commits
9 Commits

Folders and files

NameName
Last commit message
Last commit date
servo_example
servo_example
 
 
servo_msgs
servo_msgs
 
 
stl
stl
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 

Repository files navigation

rpios_ros2_lecture

RaspberryPi OS Bookworm & ROS 2 lecture

create servo_example package

ros2 pkg create --build-type ament_python --dependencies rclpy servo_msgs --description "servo example" --package-format 3 --node-name servo_example_service --license Apache-2.0  servo_example

使用するキット

  • SG90:秋月電子
  • フォトインタラプタ(例:OP90° 赤外線反射ユニット:マルツ)
  • 固定用パーツ:STLファイル
servo_base

例

ビルド

source /opt/ros/jazzy/setup.bash

mkdir -p ~/ros2_ws/src
cd ~/ros2_ws/src
git clone https://github.com/NITKK-ROS-Team/rpios_ros2_lecture.git
cd ~/ros2_ws

colcon build --symlink-install

Publisher(送信のみ)

フォトインタラプタの状態を読み取り、その値をトピックとして送信する。

source ~/ros2_ws/install/setup.bash
ros2 run servo_example input_example_pub

受信する場合は、以下のコマンドを実行する。

source ~/ros2_ws/install/setup.bash
ros2 topic echo /input

Subscriber(受信のみ)

トピックから受信した値をサーボモータに出力する。

source ~/ros2_ws/install/setup.bash
ros2 run servo_example servo_example_sub

送信する場合は、以下のコマンドを実行する。

# 0度
ros2 topic pub /servo std_msgs/msg/Int16 data:\ 0
# 90度
ros2 topic pub /servo std_msgs/msg/Int16 data:\ 90

Service(送受信)

トピックから受信した値をサーボモータに出力する。送信されるまで待機し、即座に結果が返される。

source ~/ros2_ws/install/setup.bash
ros2 run servo_example servo_example_service

送信する場合は、以下のコマンドを実行する。

# 0度
ros2 service call /servo servo_msgs/srv/SG90 angle:\ 0
# 90度
ros2 service call /servo servo_msgs/srv/SG90 angle:\ 90

Action(送受信)

トピックから受信した値をサーボモータに出力する。送信されるまで待機し、結果が返されるまで待機する。

source ~/ros2_ws/install/setup.bash
ros2 run servo_example servo_example_action

送信する場合は、以下のコマンドを実行する。

# 0度:フォトインタラプタの値が1になるまで待機
ros2 action send_goal /servo servo_msgs/action/SetAngle "{angle: 0}" --feedback

# 90度:即座に返答される(仮実装)
ros2 action send_goal /servo servo_msgs/action/SetAngle "{angle: 90}" --feedback

About

RaspberryPi OS Bookworm & ROS 2 lecture

Resources

Readme
Apache-2.0 license
Activity
Custom properties

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.