This tutorial focuses on the setup for connecting ESP8266 and ROS NOETIC
NodeMCU is a low-cost open-source IoT platform. It initially included firmware that runs on the ESP8266 Wi-Fi SoC from Espressif Systems and hardware which was based on the ESP-12 module.Ref
The Robot Operating System (ROS) is a flexible framework for writing robot software. It is a collection of tools, libraries, and conventions that aim to simplify the task of creating complex and robust robot behavior across a wide variety of robotic platforms. Why? Because creating a truly robust, general-purpose robot software is hard.Ref
ROS Serial is a point-to-point version of ROS communications over serial, primarily for integrating low-cost microcontrollers (Arduino) into ROS.Ref
I have used the Arduino IDE to embed the rosserial to Arduino based nodemcu. I have worked on ubuntu 22.04.05 LTS and ran a Docker container with ubuntu 20.04 LTS.
git clone https://github.com/EMendezJ/ESP8266-ROSNOETIC.gitcd /ESP8266-ROSNOETIC
docker build -f Dockerfile -t ros_noetic .
REMEMBER TO SET THE PORT TO YOUR CORRESPONDING USB PORT, KNOWN ISSUES FOR MULTIPLE USB DEVICES CONNECTED AT THE SE TIME
docker run -it \
--name esp_noetic \
--network host \
--device=/dev/ttyUSB0:/dev/ttyUSB0 \
--privileged \
-v ~/ros_ws:/root/ros_ws \
ros_noeticRemember to docker run the container when exiting first time, it will stop the container.
Inside Arduino IDE install the rosserial library

By default rosserial will assume that user wants to connect via TCP to the NODE-MCU, this can be easily corrected within code and inside the library files. Inside ros.h file we will need to specify only serial port usage (see example). Navigate to your libraries folder generated by arduino and inside Rosserial_Arduino_Library find the ros.h file.
Original File
File Correction
Inside Arduino IDE navigate to Sketch -> Examples -> Rosserial Arduino Library -> HelloWorld
Add #include <ArduinoHardware.h> to the file and upload it to the board.
Evaluation of correct functioning requires 3 terminal tabs attached to the Docker container esp_noetic
Terminal 1
docker start esp_noetic
docker exec -it esp_noetic bash
roscore
Terminal 2
docker exec -it esp_noetic bash
cd /opt/ros/noetic/lib/rosserial_arduino
rosrun rosserial_python serial_node.py
Terminal 3
docker exec -it esp_noetic bash
rostopic echo /chatter
EXPECTED OUTPUTS
T1
T2
T3
https://github.com/mcagriaksoy/ros_nodemcu_rosserial_sensor ros-drivers/rosserial#398 (comment) https://wiki.ros.org/rosserial