set_state_led_color

This function sets the LED color state of the robot arm.

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.

Definition
DRFLEx.h within class CDRFLEx, public section

bool set_state_led_color(int red, int green, int blue)
{
    return _set_state_led_color(_rbtCtrl, red, green, blue);
};

Parameter

Parameter Name

Type

Default

Description

red

int

Red LED state (0 or 1)

green

int

Green LED state (0 or 1)

blue

int

Blue LED state (0 or 1)

Color Combination Table

Enum #

R

G

B

Color

0

0

0

0

Off (no light)

1

1

0

0

RED

2

0

1

0

GREEN

3

1

1

0

YELLOW

4

0

0

1

BLUE

5

1

0

1

MAGENTA

6

0

1

1

CYAN

7

1

1

1

WHITE

Return

Value

Description

0

Fail — LED color could not be set.

1

Success — LED color successfully changed.

Note

A return of true does not confirm that the LED changed.

Example

// Assumes control authority is held; the LED functions work only in Auto mode
if (!Drfl.set_robot_mode(ROBOT_MODE_AUTONOMOUS)) {
    printf("set_robot_mode failed.\n");
    return 1;
}

// Indicate robot initialization state — set LED to blue
if (!Drfl.set_state_led_color(0, 0, 1))
    printf("set_state_led_color failed.\n");
std::this_thread::sleep_for(std::chrono::seconds(2));

// Indicate robot active/motion state — set LED to red
if (!Drfl.set_state_led_color(1, 0, 0))
    printf("set_state_led_color failed.\n");
std::this_thread::sleep_for(std::chrono::seconds(3));

// Indicate process completion — set LED to green
if (!Drfl.set_state_led_color(0, 1, 0))
    printf("set_state_led_color failed.\n");

// Reset to default LED configuration
if (!Drfl.state_led_reset())
    printf("state_led_reset failed.\n");

This example demonstrates how to use the state LED to indicate different robot operation phases. The LED first turns blue during initialization, then red while in motion, and finally green when the process completes. Such color cues are useful for providing visual feedback about the robot’s operational state in collaborative or human-interactive environments.