> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tryreflex.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# MotorCommands

> Named joint control. No hardcoded tensor indices.

`MotorCommands` builds actions from joint names. Joint names are resolved
from any `RobotConfig`'s joint list, so there are no hardcoded indices in
policy code.

## Construct

```python theme={null}
cmd = rfx.MotorCommands(
    {"gripper": 0.8, "elbow": -0.3},
    config=rfx.SO101_CONFIG,
)
```

## Convert

```python theme={null}
action = cmd.to_tensor()               # shape: (1, action_dim)
positions = cmd.to_list()              # flat list, length = action_dim

# Batched
action = cmd.to_tensor(batch_size=4)   # shape: (4, action_dim)
```

## Factory

```python theme={null}
cmd = rfx.MotorCommands.from_positions(
    {"elbow": 1.0},
    config=rfx.SO101_CONFIG,
    kp=30.0,
)
```

## Why it exists

Hardcoded tensor indices are a bug source every time a robot config changes.
`MotorCommands` pins joint names as the contract, so:

* Swapping a SO-101 for a different 6-DOF arm only requires a new config, not
  a policy rewrite.
* Adding a joint does not shift the meaning of existing indices.
* Policy code reads like intent, not like array plumbing.
