FlaminGO-Light Python SDK

FlmainGO-Light Python SDK

1. Getting Started

1.1 How to Connect via SSH

When you power on the robot, a Wi-Fi hotspot is automatically enabled. You can connect to the robot through the enabled Wi-Fi.

SSID

COCELO_ROBOT_XXXX

Password

00000000

circle-info

XXXX is a unique 4-character alphanumeric tag for each robot.

SSH Connection
# 1) Connect to Wi-Fi (connect to the COCELO_ROBOT_XXXX network)
# 2) SSH connection
ssh cocelo@XXXX    # XXXX = same tag as the Wi-Fi SSID
                   # Password: 00000000

1.2 Quick Drive Test

Connect the Joystick

  1. Press and hold the joystick’s center Home button for at least 5 seconds.

  2. Wait until pairing is complete.

circle-exclamation

Wake/Control the Robot

  • Use the controller’s left stick to control the robot’s movement.

  • Exit: Ctrl + C

triangle-exclamation

1.3 View Execution Logs

Command
Description

cocelo log list

View the list of saved log files

cocelo log show last

View the most recent log

cocelo log show <filename>

View a specific log file


2. SDK Preview

The example below shows the core SDK usage flow.

circle-info

Typical control loop order: get_obs()get_cmd()build_state()select_action()do_action()


3. Package Structure

Core Components

Component
Role

Robot

Robot interface

Joystick

Provides joystick input as cmd

Mode

Policy (.onnx)+ observation/scale/stack settings

RL

Builds network input state from obs + cmd + selects actions

control_rate

Runs the control loop at a specified rate


4. API Reference

Package Contents

flamingo_light_sdk

  • Robot

  • Joystick

  • Mode

  • ModeConfig

  • RL

  • control_rate

flamingo_light_sdk.onnxpolicy

  • MLPPolicy

  • LSTMPolicy

Exceptions

  • RobotInitError

  • RobotSetGainsError

  • RobotEStopError

  • ModeConfigError


flamingo_light_sdk

class flamingo_light_sdk.Robot()

circle-check

Attributes

gains_set: bool

Whether gains have been set.


Robot()

Creates a robot instance.

Raises

  • RobotInitError: Initialization failed


set_gains(kp: list[float], kd: list[float]) -> None

Sets PD gains for the 4 motors (joints).

Parameters

  • kp (list[float]): Proportional gains (length 4)

  • kd (list[float]): Derivative gains (length 4)

circle-info

The motor order corresponding to the gains in the kp/kd lists must match the following exactly.

Index 0: Left joint motor

Index 1: Right joint motor

Index 2: Left wheel motor

Index 3: Right wheel motor

Raises

  • RobotSetGainsError


get_obs() -> dict

Returns the current sensor data.


do_action(action: list[float], torque_ctrl: bool = False) -> None

Sends motor commands.

Parameters

  • action (list[float]): Target values (or torque values) for 4 motors

  • torque_ctrl (bool, optional): If True, torque control mode

circle-info

Please make sure to follow the argument order for the do_action method.

Index 0: Left joint motor position (rad) control

Index 1: Right joint motor position (rad) control

Index 2: Left wheel motor velocity (rad/s) control

Index 3: Right wheel motor velocity (rad/s) control

*When torque_ctrl=True, torque control is used for those motors


estop(msg: str = "", verbose: bool = True) -> None

Executes an emergency stop.

Raises

  • RobotEStopError


get_gains() -> dict

Returns the current gain settings.


class flamingo_light_sdk.RL()

circle-check

add_mode(mode: Mode) -> None

Adds a mode. (Supports multiple modes)


set_mode(mode_id: int | None = None) -> None

Sets the mode to activate.

Parameters

  • mode_id (int): Mode ID


build_state(obs: dict, cmd: dict, last_action: list[float] | None = None) -> list[float]

Converts observations into the neural network input (state) format.

Parameters

  • obs (dict): Return value of robot.get_obs()

  • cmd (dict): Return value of joystick.get_cmd()

  • last_action (list[float] | None): User-provided last_action clipped to [-1,1] (optional)

circle-info

If you do not pass last_action as an argument, RL stores and uses last_action internally (recommended).

Returns

  • list[float]: 1D state vector


select_action(state: list[float]) -> list[float]

Runs the policy to generate an action.


class flamingo_light_sdk.Mode(mode_cfg: dict)

circle-check

mode_cfg keys

Key
Type
Default
Description

id

int

(Required)

Mode ID (1~16)

policy_path

str

(Required)

Path to the ONNX policy file

stacked_obs_order

list[str]

[]

List of observation keys to stack

non_stacked_obs_order

list[str]

[]

List of observation keys not to stack

obs_scale

dict

{}

Per-observation scale (scalar or vector)

action_scale

float | list[float]

1.0

Action scale

stack_size

int

1

Number of stacked frames

policy_type

str

"mlp"

"mlp" / "lstm"

cmd_vector_length

int

0

Command vector dimension

extra_obs

dict[str,int]

{}

Custom observations (key: name, value: dimension)


Default Observations

Key
Description
Dimension

dof_pos

Motor angle (rad)

2

dof_vel

Motor velocity (rad/s)

4

ang_vel

Angular velocity (wx, wy, wz) (rad/s)

3

proj_grav

Projected gravity vector (gx, gy, gz)

3

last_action

Previous-step action output

4

command

Joystick command vector

cmd_vector_length


Attributes (read-only)

  • id: int

  • stack_size: int

  • state_length: int

  • action_length: int

  • policy_type: str

  • policy_path: str

  • stacked_obs_order: list[str]

  • non_stacked_obs_order: list[str]

  • action_scale: list[float]

  • obs_scale: dict

  • obs_lengths: dict

  • cmd_vector_length: int


inference(state: list[float]) -> list[float]

Directly performs ONNX policy inference.


class flamingo_light_sdk.Joystick(max_cmd: list[float]=[], smoothness: float=50.0, mapping: dict={})

circle-check

Parameters

  • max_cmd (list[float], optional)

    • Limits each axis output range to [-max_cmd[i], +max_cmd[i]].

    • If the list length is shorter than 6, the remaining values are filled with 1.0.

    • To disable a specific axis, set that index to 0.

  • smoothness (float, optional) Applies a filter to joystick input. The larger the value, the smoother the output, but the slower the input response.

  • mapping (dict[str,int], optional) You can map axes and buttons to specific indices of the command vector.

Default Mapping

Key Name
Command Index
Description
Value Range

LEFT_X

1

Left stick X-axis (left/right)

Continuous

LEFT_Y

0

Left stick Y-axis (up/down)

Continuous

RIGHT_X

2

Right stick X-axis (left/right)

Continuous

RIGHT_Y

3

Right stick Y-axis (up/down)

Continuous

LEFT_BTN

4

Left button (LB)

0 or 1

RIGHT_BTN

5

Right button (RB)

0 or 1

circle-info

LEFT_BTN / RIGHT_BTN return a discrete value: 0 when not pressed, 1 when pressed.

Mapping Rules

  • You must specify all 6 required keys (LEFT_X, LEFT_Y, RIGHT_X, RIGHT_Y, LEFT_BTN, RIGHT_BTN).

  • Each index must be unique within the 0~5 range.

  • If there are duplicate indices or missing keys, an invalid_argument exception is raised.


Mode Switching (mode_id)

Select mode_id(1~16) using a combination of the D-pad (⬆️➡️⬇️⬅️) and the face buttons (Y/B/A/X) combination. How to operate: While holding a D-pad direction, press one of Y/B/A/X at the same time.

D-pad Direction
Y
B
A
X

⬆️ Up

1

2

3

4

➡️ Right

5

6

7

8

⬇️ Down

9

10

11

12

⬅️ Left

13

14

15

16


Emergency Stop (E-Stop)

Function
Input Method

Emergency Stop (E-Stop)

Press LT + RT buttons simultaneously

triangle-exclamation

get_cmd() -> dict

Returns joystick commands and status.

Returns

  • cmd_vector (list[float]): Command vector

  • mode_id (int | None): Current mode ID

  • estop (bool): Whether E-Stop input is detected


is_connected() -> bool

Checks the joystick connection status.


function flamingo_light_sdk.control_rate(robot: Robot, hz: float = 50.0)

circle-info

A decorator that runs the control loop at the specified Hz.


flamingo_light_sdk.onnxpolicy

class flamingo_light_sdk.onnxpolicy.MLPPolicy(weightPath: str)

circle-check

Parameters

  • weightPath (str): Path to the ONNX model file

Methods

inference(state: list[float]) -> list[float]

Performs 1-step inference. state must be 1D.

circle-info

The returned action is clipped internally to the [-1, 1] range.


class flamingo_light_sdk.onnxpolicy.LSTMPolicy(weightPath: str)

circle-check

Parameters

  • weightPath (str): Path to the ONNX model file

Methods

inference(state: list[float]) -> list[float]

Performs 1-step inference (including internal h/c updates). state must be 1D.


5. Example Code


6. Applications

6.1 Switching Between Multiple Modes

Switching between multiple policies is supported. If build_state() detects mode_id in cmd, it can automatically switch modes.


6.2 Customizing Observations

You can process sensor data to create new observations and add them to the policy input. Define the dimensions of custom observations in advance with extra_obs, then add the data to the obs dictionary inside the loop.

circle-exclamation

6.3 Torque Control

Use torque control mode instead of position/velocity control.


6.4 Scale Settings

How to apply scales to observations and actions.

Applies the same scale to all elements.


7. SDK Update

This requires an internet connection. After connecting via SSH, proceed in the following order.


Last updated