set_state_led_color (Auto Mode)
This section explains how to use set_state_led_color during Auto operations. This function sets the State LED color, allowing users to define custom color codes to indicate specific process or safety states. Each color channel is 0 (off) or 1 (on), which gives 8 colors; for example, red is (1, 0, 0) and yellow is (1, 1, 0).
Available in Auto mode only, on controller v3.4 or later. In other modes, or on an older controller, the function returns false. The mode check uses the value returned by get_robot_mode.
Typical usage
Provide visual feedback for process states (e.g., blue = ready, yellow = waiting, red = stop).
Display custom LED colors to represent operator messages or warnings.
Synchronize LED with popup or log severity.
Example
The example obtains control authority and sets Auto mode before the LED calls, because the LED functions are refused in other modes.
#include <atomic>
#include <chrono>
#include <cstdio>
#include <thread>
std::atomic<bool> g_bHasControlAuthority(false);
void OnMonitoringAccessControlCB(const MONITORING_ACCESS_CONTROL eAccess)
{
if (eAccess == MONITORING_ACCESS_CONTROL_GRANT)
g_bHasControlAuthority = true;
}
drfl.set_on_monitoring_access_control(OnMonitoringAccessControlCB);
if (!drfl.open_connection("192.168.137.100")) return 1;
drfl.manage_access_control(MANAGE_ACCESS_CONTROL_FORCE_REQUEST);
while (!g_bHasControlAuthority)
std::this_thread::sleep_for(std::chrono::milliseconds(100));
// The LED functions are refused unless Auto mode is set
if (!drfl.set_robot_mode(ROBOT_MODE_AUTONOMOUS)) return 1;
// Blue - Ready
if (!drfl.set_state_led_color(0, 0, 1)) return 1;
printf("[LED] Ready (Blue)\n");
std::this_thread::sleep_for(std::chrono::seconds(2));
// Yellow - Waiting for Input
if (!drfl.set_state_led_color(1, 1, 0)) return 1;
printf("[LED] Waiting for user input (Yellow)\n");
std::this_thread::sleep_for(std::chrono::seconds(2));
// Red - Error or Stop
if (!drfl.set_state_led_color(1, 0, 0)) return 1;
printf("[LED] Error Condition (Red)\n");
std::this_thread::sleep_for(std::chrono::seconds(2));
if (!drfl.state_led_reset())
printf("[ERROR] Failed to reset LED state.\n");
By switching each color channel on or off, this function lets you display context-aware colors to improve operator awareness.
Note
A return of true does not confirm that the LED changed.
Tips
Common color usage: Blue = Ready, Yellow = Waiting, Red = Error.
Use with set_on_tp_popup for visual popup feedback.
Reset with state_led_reset when the custom indication ends.