You're reading the documentation for an older, but still supported version (1.33.4).
For information on the latest version, please have a look at 1.33.5.

get_state_led_rule (Auto Mode)

This section explains how to use get_state_led_rule during Auto operations. This function returns the LED rule: 0 = default, 1 = custom by state, 2 = custom by command. It also returns 0 when the call is refused.

Available in Auto mode only, on controller v3.4 or later. In other modes, or on an older controller, the function returns 0. The mode check uses the value returned by get_robot_mode.

Typical usage

  • Check which LED rule is currently active before or after custom color control.

  • Use to synchronize external UI indicators with the robot’s LED behavior.

  • Log the LED rule for diagnostics.

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;

unsigned char rule = drfl.get_state_led_rule();
printf("[LED] Current LED rule: %d\n", rule);

if (rule == 0)
    printf("LED rule: Default\n");
else if (rule == 1)
    printf("LED rule: Custom by state\n");
else if (rule == 2)
    printf("LED rule: Custom by command\n");

This function provides insight into the LED rule currently applied by the controller, helping users maintain consistent visual feedback policies.

Tips