ros-drivers / rosserial

A ROS client library for small, embedded devices, such as Arduino. See: http://wiki.ros.org/rosserial
508 stars 527 forks source link

Add ArduinoBluetoothHardware and example #569

Open sktometometo opened 2 years ago

sktometometo commented 2 years ago

Add ArduinoBluetoothHardware.h and example for ESP32 Bluetooth Serial.

This PR enables rosserial connection over bluetooth of ESP32. I don't know who originaly develop this usage, but already some uses this.

I thinks this will be useful for otherESP32 rosserial users.

I confirmed that example program works with boards below

Usage

FIrst, burn the example sketch to your ESP32 board. After that, connect your PC's bluetooth interface to esp32 board

bluetoothctl
scan on # check MAC address of your device
scan off
pair <MAC address of your device>
trust <MAC address of your device>
connect <MAC address of your device>
info <MAC address of your device> # check if your device is successfully connected

And bind bluetooth serial connection to /dev/rfcomm1

sudo rfcomm bind 1 <MAC address of your device>
sudo stty -F /dev/rfcomm1 57600 cs8

Now you can use rosserial over bluetooth

roscore
rosrun rosserial_python serial_node.py _port:=/dev/rfcomm1 _baud:=57600
smiiisato commented 1 year ago

I'm using devkit-v1 from esp32 and it didn't connect at all. But https://blog.51cto.com/u_12369060/5192168とhttps://askubuntu.com/questions/137794/why-is-my-bluetooth-connection-always-failing I did sudo apt install blueman and used blueman-manager to set up serial communication and it worked fine. Thank you very much.

k-okada commented 12 months ago

tips: to use this with latest noetic branch, we may need https://github.com/ros-drivers/rosserial/pull/448.