Skip to content

hchelo/ROS2_Service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ROS 2 Service Practice

Turn on an LED on an ESP32 from a laptop1 server and a laptop2 client

Configuration Diagram: Configuration Diagram

0. In the ESP32

sudo chmod 777 /dev/ttyUSB0 Upload the following program to the ESP32. Don't forget to connect the ESP32 to the same Wi-Fi network as your PCs.

  • src/Code_ESP32/esp_led.py

Afterward, you can disconnect the ESP32 and test it with a separate 5V power supply.

1. Create new package

Open a new terminal and source, in this case: esp32_ws/src/

create:

  • ros2 pkg create --build-type ament_python py_srvcliESP --dependencies rclpy example_interfaces

2 Write the service node

  • src/py_srvcliESP/py_srvcliESP/serviesp.py

3 Write the client node

  • src/py_srvcliESP/py_srvcliESP/cliesp.py

4 Build and run

  • colcon build
  • source install/setup.bash

SERVER: ros2 run py_srvcliESP minimal_service

CLIENT ros2 run py_srvcliESP minimal_client 1

If the argument is 1, it turns on the LED on the ESP32; if the argument is 0, the LED turns off.

About

Service in ROS2

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published