For the complete documentation index, see llms.txt. This page is also available as Markdown.

FlaminGO- Python SDK

FlmainGO 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.

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.

Motor set zero

  • Press a in the terminal to get the motor state. Make sure all the state is set to "2" after pressing a then go to the next step.

  • Press z in the terminal to send all motor to zero position.

  • Robot will go the the standing position after pressing z.

  • Press q in the terminal to quit the motor set-zero mode.

Wake/Control the Robot

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

  • Exit: Ctrl + C


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.

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_sdk

  • Robot

  • Joystick

  • Mode

  • ModeConfig

  • RL

  • control_rate

flamingo_sdk.onnxpolicy

  • MLPPolicy

  • LSTMPolicy

Exceptions

  • RobotInitError

  • RobotSetGainsError

  • RobotEStopError

  • ModeConfigError


flamingo_sdk

class flamingo_sdk.Robot()

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 8 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 hip motor

Index 1: Right hip motor

Index 2: Left shoulder motor

Index 3: Right shoulder motor

Index 4: Left leg motor

Index 5: Right leg motor

Index 6: Left wheel motor

Index 7: 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

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 joint motor position (rad) control

Index 3: Right joint motor position (rad) control

Index 4: Left joint motor position (rad) control

Index 5: Right joint motor position (rad) control

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

Index 7: 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_sdk.RL()


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)

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_sdk.Mode(mode_cfg: dict)

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]

0.25

Action scale

stack_size

int

3

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_sdk.Joystick(max_cmd: list[pair(double, double)]=[], smoothness: float=50.0, mapping: dict={})

Parameters

  • max_cmd (list[pair(double, double)], optional)

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

    • If the argument list length is shorter than cmd_vector_length, the remaining values are filled with (-1.0, 1.0).

    • To disable a specific axis, set the corresponding index to (-0.0, 0.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(str) : Maps buttons to the command vector in order. For discrete buttons, the delta value can also be specified.

Mapping Rules

  • Users must map the same number of buttons as the cmd_vector_length defined in the mode.

  • Each button must be uniquely mapped, and for discrete buttons such as BTN_A, BTN_B, BTN_Y, and BTN_X, both increase and decrease deltas must be defined.


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


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_sdk.control_rate(robot: Robot, hz: float = 50.0)

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


flamingo_sdk.onnxpolicy

class flamingo_sdk.onnxpolicy.MLPPolicy(weightPath: str)

Parameters

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

Methods

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

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


class flamingo_sdk.onnxpolicy.LSTMPolicy(weightPath: str)

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.


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