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
XXXX is a unique 4-character alphanumeric tag for each robot.
# 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: 000000001.2 Quick Drive Test
Connect the Joystick
Press and hold the joystick’s center Home button for at least 5 seconds.
Wait until pairing is complete.
If the joystick does not connect, fully charge it to 100% and try again.
Wake/Control the Robot
Use the controller’s left stick to control the robot’s movement.
Exit:
Ctrl + C
When you exit, the motors stop immediately. Be sure to hold the handle and support the robot before exiting.
1.3 View Execution Logs
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.
Typical control loop order: get_obs() → get_cmd() → build_state() → select_action() → do_action()
3. Package Structure
Core Components
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
flamingo_light_sdkRobotJoystickModeModeConfigRLcontrol_rate
flamingo_light_sdk.onnxpolicy
flamingo_light_sdk.onnxpolicyMLPPolicyLSTMPolicy
Exceptions
RobotInitErrorRobotSetGainsErrorRobotEStopErrorModeConfigError
flamingo_light_sdk
flamingo_light_sdkclass flamingo_light_sdk.Robot()
flamingo_light_sdk.Robot()Controls the hardware interface. It reads sensor observations and sends motor commands.
0
left_shoulder
1
right_shoulder
2
left_wheel
3
right_wheel
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)
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 motorstorque_ctrl (bool, optional): IfTrue, torque control mode
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()
flamingo_light_sdk.RL()Manages the reinforcement learning policy, builds the neural network input state from obs and cmd, and selects actions.
build_state() creates the input vector according to the mode settings (stack/scale/observation order), and select_action() runs policy inference.
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 ofrobot.get_obs()cmd (dict): Return value ofjoystick.get_cmd()last_action (list[float] | None): User-provided last_action clipped to [-1,1] (optional)
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)
flamingo_light_sdk.Mode(mode_cfg: dict)Defines per-mode policy settings. (Includes observation stack/scale and policy file path)
The build_state() result has the following form.
Example: stack_size=3, stacked_obs_order=["dof_pos","dof_vel"], non_stacked_obs_order=["command"]
mode_cfg keys
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
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: intstack_size: intstate_length: intaction_length: intpolicy_type: strpolicy_path: strstacked_obs_order: list[str]non_stacked_obs_order: list[str]action_scale: list[float]obs_scale: dictobs_lengths: dictcmd_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={})
flamingo_light_sdk.Joystick(max_cmd: list[float]=[], smoothness: float=50.0, mapping: dict={})Processes joystick input and returns cmd.
Connect to the robot: Press and hold the Home button for at least 5 seconds.
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
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
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_argumentexception 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.
⬆️ Up
1
2
3
4
➡️ Right
5
6
7
8
⬇️ Down
9
10
11
12
⬅️ Left
13
14
15
16
Emergency Stop (E-Stop)
Emergency Stop (E-Stop)
Press LT + RT buttons simultaneously
During an emergency stop (E-Stop), all motors stop immediately.
get_cmd() -> dict
Returns joystick commands and status.
Returns
cmd_vector (list[float]): Command vectormode_id (int | None): Current mode IDestop (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)
flamingo_light_sdk.control_rate(robot: Robot, hz: float = 50.0)A decorator that runs the control loop at the specified Hz.
flamingo_light_sdk.onnxpolicy
flamingo_light_sdk.onnxpolicyclass flamingo_light_sdk.onnxpolicy.MLPPolicy(weightPath: str)
flamingo_light_sdk.onnxpolicy.MLPPolicy(weightPath: str)An ONNX-based MLP policy inference engine.
Parameters
weightPath (str): Path to the ONNX model file
Methods
inference(state: list[float]) -> list[float]
Performs 1-step inference. state must be 1D.
The returned action is clipped internally to the [-1, 1] range.
class flamingo_light_sdk.onnxpolicy.LSTMPolicy(weightPath: str)
flamingo_light_sdk.onnxpolicy.LSTMPolicy(weightPath: str)An ONNX-based LSTM policy (with state retention) inference engine.
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.
Extra observations must be in the form of a 1D list or a 1D np.ndarray.
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.
Applies per-element scales. The vector length must match the dimension of the corresponding observation.
7. SDK Update
This requires an internet connection. After connecting via SSH, proceed in the following order.
Last updated

