> For the complete documentation index, see [llms.txt](https://directdrivetech.gitbook.io/development-manual/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://directdrivetech.gitbook.io/development-manual/software-api/lighting-effects.md).

# Lighting Effects

The API of the lighting effects can fully control 104 LED beads of the entire machine, allowing you to exchange colors, gradient effects, and so on.

## API Details

### Front Light Effects Control

**Function Overview：**&#x43;ontrol the Front Light Effects via Topic

**Topic：**&#x69;nteraction/light\_control/head\_light\_control

**Msg type：**&#x74;ita\_interaction\_msgs::msg::HeadLightControl

**Code Example：**

**Control：**`ros2 topic pub /`\[namespace]`/interaction/light_control/head_light_control tita_interaction_msgs/msg/HeadLightControl "{is_control: true, select_light_effect: 0, rgbl_value: [0xffff00ff, 0xff00ffff, 0x00ffffff,0xffff00ff, 0xff00ffff, 0x00ffffff,0xffff00ff, 0xff00ffff, 0x00ffffff,0xffff00ff, 0xff00ffff, 0x00ffffff,0xffff00ff, 0xff00ffff, 0x00ffffff,0xffff00ff, 0xff00ffff, 0x00ffffff,0xffff00ff, 0xff00ffff, 0x00ffffff,0xffff00ff, 0xff00ffff, 0x00ffffff,0xffff00ff, 0xff00ffff, 0x00ffffff,0xffff00ff, 0xff00ffff, 0x00ffffff,0xffff00ff, 0xff00ffff, 0x00ffffff,0xffff00ff, 0xff00ffff, 0x00ffffff,0xffff00ff, 0xff00ffff, 0x00ffffff,0xffff00ff, 0xff00ffff, 0x00ffffff,0xffff00ff, 0xff00ffff, 0x00ffffff,0xffff00ff, 0xff00ffff, 0x00ffffff]}" -1`

**Inquiry：**

`ros2 topic echo /`\[namespace]`/interaction/light_control/head_light_control`

**Value Range：**&#x42;ool is\_control， uin8\_t select\_light\_effect， uint32 rgbl\_value\[48]

{% hint style="info" %}
The `is_control` parameter should be set to `true` when control is needed and to `false` when control is relinquished.&#x20;

The `select_light_effect` currently only takes the value 0, which represents a constant brightness.

In the `uint32_t` type `rgbl[48]` array, each element represents the red, green, blue, and brightness values for an individual LED bead. For example, a color value of `0xfe00ff80U` for a certain LED bead indicates red: 254 (0xfeU), green: 0 (0x00U), blue: 255 (0xffU), and brightness: 128 (0x80U), which together present a specific color.
{% endhint %}

### Rear Light Effects Control

**Function Overview：**&#x43;ontrol the Rear Light Effects via Topic

**Topic：**&#x69;nteraction/light\_control/tail\_light\_control

**Msg Type：**&#x74;ita\_interaction\_msgs::msg::TailLightControl

**Code Example：**

**Control：**`ros2 topic pub /`\[namespace]`/interaction/light_control/tail_light_control tita_interaction_msgs/msg/TailLightControl "{is_control: true, select_light_effect: 0, rgbl_value: [0xffff00ff, 0xff00ffff, 0x00ffffff,0xffff00ff, 0xff00ffff, 0x00ffffff,0xffff00ff, 0xff00ffff, 0x00ffffff,0xffff00ff, 0xff00ffff, 0x00ffffff,0xffff00ff, 0xff00ffff, 0x00ffffff,0xffff00ff, 0xff00ffff, 0x00ffffff,0xffff00ff, 0xff00ffff, 0x00ffffff,0xffff00ff, 0xff00ffff, 0x00ffffff,0xffff00ff, 0xff00ffff, 0x00ffffff,0xffff00ff, 0xff00ffff, 0x00ffffff,0xffff00ff, 0xff00ffff, 0x00ffffff,0xffff00ff, 0xff00ffff, 0x00ffffff]}" -1`

**Inquiry：**

`ros2 topic echo /`\[namespace]`/interaction/light_control/tail_light_control`

**Value Range：**&#x42;ool is\_control,，uint8\_t select\_light\_effect，uin32\_t rgbl\_value\[36]

### Leg Light Effects Control

**Function Overview：**&#x43;ontrol the Leg Light Effects via Topic

**Topic：**&#x69;nteraction/light\_control/leg\_light\_control

**Msg Type：**&#x74;ita\_interaction\_msgs::msg::LegLightControl

**Code Example：**

**Control：**`ros2 topic pub /`\[namespace]`/interaction/light_control/leg_light_control tita_interaction_msgs/msg/LegLightControl "{select_leg_board: 1, is_control: true, select_light_effect: 0, rgb_value: [0xffff00ff, 0xff00ffff, 0x00ffffff,0xffff00ff, 0xff00ffff, 0x00ffffff,0xffff00ff, 0xff00ffff, 0x00ffffff,0xffff00ff]}" -1`

**Inquiry：**`ros2 topic echo /`\[namespace]`action/light_control/leg_light_control`

**Value Range：**&#x75;int8 select\_leg\_board，bool is\_control，uint8 select\_light\_effect， uint32\[10] rgb\_value

{% hint style="info" %}
The basic control is the same as mentioned earlier. Set `select_leg_board` to 1 for the robot's left leg and to 2 for the right leg.&#x20;

The select\_light\_effect currently as a default value of 0, which represents a constant brightness.

Please note that the `uint32_t` `rgb_value[10]` only represents the red, green, and blue values, without brightness, as it is just a placeholder to fill the `uint32_t`. For example, a color value of `0xfe00ff80U` for a certain LED bead indicates red: 254 (0xfeU), green: 0 (0x00U), blue: 255 (0xffU), and brightness: (default value is meaningless) for the overall presented color. For the LED beads on the legs, the higher the values of red, green, and blue you set, the brighter the corresponding LED bead will be, and vice versa, the lower the values, the dimmer the LED bead will be.
{% endhint %}

### Lighting Effects Switch

**Function Overview：**&#x59;ou can control the power of the entire machine's light boards.

**Topic：**&#x69;nteraction/light\_control/light\_power\_switch

**Msg Type：**&#x74;ita\_interaction\_msgs::msg::LightPowerSwitch

**Code Example：**

**Control：**`ros2 topic pub /`\[namespace]`/interaction/light_control/light_power_switch tita_interaction_msgs/msg/LightPowerSwitch "{is_head_light_power_on: true, is_tail_light_power_on: true, is_left_light_power_on: true, is_right_light_power_on: true}" -1`

**Inquiry：**`ros2 topic echo /titaxxxxx(对应的tita ID)/interaction/light_control/light_power_switch`

**Value Range：**

bool is\_head\_light\_power\_on

bool is\_tail\_light\_power\_on

bool is\_left\_light\_power\_on

bool is\_right\_light\_power\_on

{% hint style="info" %}
The default setting is `true` for all. Wherever you want to turn off the lights, set it to `false`.
{% endhint %}

### All machine lighting effect control

**Function Overview：**&#x43;ontrol the state pointer of the entire machine's light board state machine.

**Topic：**&#x69;nteraction/light\_control/light\_fsm\_control

**Msg Type：**&#x74;ita\_interaction\_msgs::msg::LightFsmControl

**Code Example：**

**Control：**`ros2 topic pub /`\[namespace]`/interaction/light_control/light_fsm_control tita_interaction_msgs/msg/LightFsmControl "{head_light_fsm: 1, tail_light_fsm: 1, left_leg_light_fsm: 1, right_leg_light_fsm: 1, head_fsm_lock: false, tail_fsm_lock: false, left_leg_fsm_lock: false, right_leg_fsm_lock: false}" -1`

**Inquiry：**`ros2 topic echo /`\[namespace]`/interaction/light_control/light_fsm_control tita_interaction_msgs/msg/LightFsmControl`

**Value Range：**

1. head\_light\_fsm，tail\_light\_fsm，left\_leg\_light\_fsm，right\_leg\_fsm, value:0\~255
2. head\_fsm\_lock,tail\_fsm\_lock,left\_fsm\_lock,right\_fsm\_lock, all bool

{% hint style="info" %}
General inquiries are fine; control is used for debugging.&#x20;

The `fsm_lock` is used to lock the current state of the state machine, causing the robot to repeat the lighting effect for debugging purposes.
{% endhint %}
