ROS2 Jazzy driver for the AMS TCS34725 RGB color sensor with IR blocking filter over I2C.
- Publishes
std_msgs/ColorRGBAontcs34725/color(normalised R/G/B, clear as alpha) - Publishes
sensor_msgs/Illuminanceontcs34725/illuminance(lux via DN40 formula) fake_modefor testing without hardware (random Gaussian data)- 4-channel sensing: Clear, Red, Green, Blue (16-bit each)
- IR blocking filter for accurate visible-light color measurement
- Configurable integration time: 2.4 ms ~ 700 ms
- Configurable gain: 1x, 4x, 16x, 60x
- Runtime
publish_ratechange viaros2 param set - Calibration and reset services
- ROS 2 Jazzy
- Python 3
- Real hardware only:
smbus2(pip install smbus2)- TCS34725 breakout board (I2C)
cd ~/ros2_ws
colcon build --packages-select tcs34725_color --symlink-install
source install/setup.bashros2 launch tcs34725_color tcs34725_launch.pyros2 run tcs34725_color tcs34725_node.pyros2 launch tcs34725_color tcs34725_launch.py \
params_file:=path/to/your_params.yamlSet fake_mode: false, integration, and gain in your YAML file.
ros2 topic echo /tcs34725/color
ros2 topic echo /tcs34725/illuminance| Parameter | Type | Default | Description |
|---|---|---|---|
fake_mode |
bool | true |
Generate random data without hardware |
i2c_bus |
int | 1 |
I2C bus number (/dev/i2c-N) |
device_address |
int | 0x29 |
I2C address (fixed for TCS34725) |
integration |
string | 101ms |
Integration time: 2.4ms, 24ms, 50ms, 101ms, 154ms, 700ms |
gain |
string | 4x |
Gain: 1x, 4x, 16x, 60x |
publish_rate |
float | 5.0 |
Publishing rate in Hz |
frame_id |
string | color_link |
TF frame ID (illuminance topic) |
| Topic | Type | Description |
|---|---|---|
tcs34725/color |
std_msgs/ColorRGBA |
Normalised R/G/B (0-1), clear channel as alpha |
tcs34725/illuminance |
sensor_msgs/Illuminance |
Lux from DN40 application note formula |
| Service | Type | Description |
|---|---|---|
tcs34725/calibrate |
std_srvs/srv/Trigger |
Collect samples for 2 s, report averages |
tcs34725/reset |
std_srvs/srv/Trigger |
Clear bias, reinitialize sensor |
tcs34725_color/
├── CMakeLists.txt
├── package.xml
├── config/
│ └── tcs34725_params.yaml
├── launch/
│ └── tcs34725_launch.py
├── tcs34725_color/
│ ├── __init__.py
│ └── tcs34725_driver.py
├── nodes/
│ └── tcs34725_node.py
├── test/
│ └── test_tcs34725_node.py
├── .gitignore
├── LICENSE
├── CONTRIBUTING.md
└── README.md
Tested on Ubuntu 24.04 (WSL2) with fake_mode: true.
| Test Category | Test | Result |
|---|---|---|
| Topics | tcs34725/color publishes std_msgs/ColorRGBA |
PASS |
| Topics | RGB values in 0.0-1.0 range | PASS |
| Topics | tcs34725/illuminance publishes sensor_msgs/Illuminance |
PASS |
| Services | tcs34725/calibrate returns success=True |
PASS |
| Services | tcs34725/reset returns success=True |
PASS |
| Parameters | publish_rate runtime change |
PASS |
| Shutdown | Clean exit | PASS |
| Linting | pep257, flake8, copyright, xmllint | PASS |
MIT