Skip to content

CrissCCL/Temp_ControlMod_ROS_integration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔥 Temp Control Module — ROS 2 Humble Integration (UART Bridge)

ROS2 Python Platform License

Overview

This repository provides the ROS 2 Humble integration layer for the main temperature control platform:

👉 Main embedded project (hardware + firmware + control)
https://github.com/CrissCCL/Temp_ControlMod

It runs on a Raspberry Pi and bridges an embedded controller (Teensy/MCU) to ROS 2 via UART, enabling:

  • Real-time telemetry streaming
  • Remote setpoint commands
  • Online control performance metrics
  • Logging, visualization, and data analysis

✨ Features

  • Bidirectional UART ↔ ROS 2 communication
  • Real-time telemetry (~100 Hz, limited by UART bandwidth)
  • Remote setpoint commands
  • Online control metrics (IAE, ISE, ITAE, RMSE, overshoot, settling time)
  • rosbag logging support
  • Embedded + middleware architecture
  • Designed for control engineering education and experimentation

📂 Contents

ROS 2 (middleware layer)

  • /uart_ros_bridge/ → UART bridge + control metrics nodes
  • /launch/ → system launch files
  • /scripts/ → offline utilities (CSV merge, analysis)
  • /docs/ → diagrams and screenshots
  • /notebooks/ → data analysis (optional)

Embedded firmware

  • /control_temp_LC3/ → Teensy / Arduino firmware (compiled independently, not part of colcon build)

Package configuration

  • package.xml
  • setup.py

🏗️ Architecture

Architecture

🔧 Hardware Setup

Physical connections:

  • Teensy → temperature sensor + actuator (heater/fan)
  • UART (Serial1) → Raspberry Pi
  • Raspberry Pi → ROS 2 nodes (bridge + metrics + visualization)

🔌 Embedded Firmware (Teensy)

The Teensy executes the real-time PI temperature control loop and communicates with ROS 2 using a simple ASCII UART protocol.

Telemetry (MCU → ROS)

temp,u,ref\n

Command (ROS → MCU)

REF:<value>\n

Where:

  • temp → measured temperature
  • u → control effort
  • ref → active setpoint

UART settings

  • Serial1
  • 57600 baud
  • 8N1

Firmware is compiled with Arduino/Teensyduino and runs independently from ROS.

🎯 Use Cases

  • Control systems laboratories
  • Embedded–ROS integration
  • Controller tuning and identification
  • Digital twin experimentation
  • Teaching automatic control

📊 Results / Visualization

Step response (rqt_plot)

Runtime environment (Raspberry Pi + ROS nodes)

📡 ROS Topics

Published

Topic Type Description
/temp Float32 Temperature measurement
/u Float32 Control effort
/ref Float32 Active setpoint
/temp_u_ref String Raw telemetry line
/control_metrics String Online performance metrics

Subscribed

Topic Type Description
/ref_cmd Float32 New setpoint command

🔌 UART protocol

MCU → RPi (ROS)
Line format (ASCII):

temp,u,ref\n

RPi (ROS) → MCU
Command format (ASCII):

REF:<value>\n

Default port/baud (editable in the node file):

  • Port: /dev/serial0
  • Baud: 57600

⚙️ Requirements

  • Ubuntu 22.04 + ROS 2 Humble
  • Python 3
  • pyserial

Install pyserial:

pip3 install pyserial

Tip (serial permissions): add your user to dialout

sudo usermod -a -G dialout $USER
# logout/login

🧱 Build (colcon)

mkdir -p ~/ros2_ws/src
cd ~/ros2_ws/src
git clone <THIS_REPO_URL> uart_ros_bridge_repo
cd ..
colcon build
source install/setup.bash

▶️ Run

Option A — Launch (recommended)

source /opt/ros/humble/setup.bash
source ~/ros2_ws/install/setup.bash
ros2 launch uart_ros_bridge system.launch.py

Option B — Run nodes manually

UART bridge:

ros2 run uart_ros_bridge uart_temp_to_ros

Metrics:

ros2 run uart_ros_bridge control_metrics

Send a new setpoint:

ros2 topic pub /ref_cmd std_msgs/msg/Float32 "{data: 40.0}"

Quick check:

ros2 topic echo /temp
ros2 topic echo /control_metrics

Plot:

rqt_plot /temp /ref /u

🚀 Quick Test (5-minute demo)

1️⃣ Launch system

source /opt/ros/humble/setup.bash
source ~/ros2_ws/install/setup.bash
ros2 launch uart_ros_bridge system.launch.py

2️⃣ Check telemetry (raw UART frame)

ros2 topic echo /temp_u_ref

3️⃣ Check individual signals

ros2 topic echo /temp
ros2 topic echo /u
ros2 topic echo /ref

4️⃣ Change setpoint (one-shot)

ros2 topic pub --once /ref_cmd std_msgs/msg/Float32 "{data: 40.0}"

5️⃣ Visualize response

source /opt/ros/humble/setup.bash
source ~/ros2_ws/install/setup.bash
rqt

You should observe:

  • temperature tracking the reference
  • control effort reacting to the error
  • stable closed-loop behavior

📁 Utilities

Merge exported CSV (offline analysis)

If you export ROS bag topics to CSV files (e.g., temp.csv, u.csv, ref.csv), you can merge them:

python3 scripts/merge_temp_u_ref_csv.py

🔗 Related repositories

🤝 Support projects

Support me on Patreon https://www.patreon.com/c/CrissCCL

📜 License

MIT License

About

ROS 2 interface for real-time telemetry, supervisory control, and setpoint management of an embedded temperature control system.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors