Skip to content

yumo13/G25_ros_ws

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

G25 ROS2 Workspace

校内案内ロボットG25用のROS 2ワークスペースです。CAN通信、BLE入力、ジョイスティック変換などを含みます。

機能

  • CANフレームの送受信(SocketCAN ↔ ROS 2)
  • BLE入力をTwistに変換して/cmd_velへ配信
  • ジョイスティック入力をTwistに変換
  • 速度・位置・加速度の軌道可視化
  • systemdサービスによるCAN/GPIO初期化

ディレクトリ構成

必要要件

  • ROS 2 Humble
  • Node 24.11.1 (BLEサーバー用)
  • CAN対応デバイス(Raspberry Pi内蔵CAN、CANable2など)

ビルド

colcon build --symlink-install

依存関係インストール

rosdep update
rosdep install --from-paths src --ignore-src -r -y 
cd ble_server
npm install
cd ..

また、ble_server実行のため、以下のコマンドを実行してください

sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)

CAN/GPIO設定

Raspberry Piの場合

  1. サービスをインストール:
./install_services.sh
  1. サービス起動(自動起動設定済み):
sudo systemctl start can-setup.service
  1. ログ確認
sudo systemctl status can-setup.service
sudo journalctl -u can-setup.service -f

他の環境の場合

CANable2などのデバイスを使用する場合、適宜CANインターフェースを設定してください。

sudo ip link set can0 type can bitrate 1000000
sudo ip link set can0 up

参考: CANable 2.0で高速can通信 with ROS 2

実行方法

環境セットアップ

source install/setup.bash

CANインターフェース

ros2 run can_interface can_interface_node

CANフレーム送信:

ros2 topic pub /can_tx can_msgs/msg/Frame "{id: 100, is_extended: false, is_remote: false, length: 2, data: [255, 255, 0, 0, 0, 0, 0, 0]}" -1

CANフレーム受信確認:

ros2 topic echo /can_rx

BLEコントローラ

  1. BLEサーバー起動:
node ble_server/ble_server.js
  1. ROS 2ノード起動:
ros2 run ble_controller ble_controller_node

ジョイスティック → Twist

ros2 run joy_controller joy_to_twist

軌道可視化

ros2 run jerk_trajectory_controller visualize_trajectory.py

トピック

  • /can_rx - 受信CANフレーム(Publisher)
  • /can_tx - 送信CANフレーム(Subscriber)
  • /cmd_vel - 速度指令(Publisher)
  • joy - ジョイスティック入力(Subscriber)

パラメータ

  • interface(can_interface): CANインターフェース名(デフォルト: "can0")
  • max_linear_speed(joy_controller): 直進最大速度
  • max_angular_speed(joy_controller): 旋回最大速度

注意

  • CAN/GPIO操作にはroot権限が必要です。
  • BLEサーバー実行にはNode.jsが必要です。

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors