Skip to content

mingyo186/tcs34725_color

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TCS34725 RGB Color Sensor — ROS2 Jazzy Driver (I2C)

ROS2 Jazzy driver for the AMS TCS34725 RGB color sensor with IR blocking filter over I2C.

Features

  • Publishes std_msgs/ColorRGBA on tcs34725/color (normalised R/G/B, clear as alpha)
  • Publishes sensor_msgs/Illuminance on tcs34725/illuminance (lux via DN40 formula)
  • fake_mode for 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_rate change via ros2 param set
  • Calibration and reset services

Prerequisites

  • ROS 2 Jazzy
  • Python 3
  • Real hardware only:
    • smbus2 (pip install smbus2)
    • TCS34725 breakout board (I2C)

Installation

cd ~/ros2_ws
colcon build --packages-select tcs34725_color --symlink-install
source install/setup.bash

Usage

Launch (fake mode — default)

ros2 launch tcs34725_color tcs34725_launch.py

Run node directly

ros2 run tcs34725_color tcs34725_node.py

Real hardware (Raspberry Pi)

ros2 launch tcs34725_color tcs34725_launch.py \
  params_file:=path/to/your_params.yaml

Set fake_mode: false, integration, and gain in your YAML file.

Verify output

ros2 topic echo /tcs34725/color
ros2 topic echo /tcs34725/illuminance

Parameters

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)

Topics

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

Services

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

Package Structure

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

Test Results

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

License

MIT

About

ROS2 Jazzy driver for TCS34725 RGB color sensor (I2C, RGBC 4-channel, IR filter, DN40 lux, fake_mode)

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors