From scratch firmware rewrite in python. Intent is to keep it as small and as simple as possible. Minimize complexity --> Minimize bugs.
Loop runs at 50Hz. Roundtrip time is around 4.5ms. We then wait 15.5ms to get to 50hz. The actuators independently run a PD controller at 1kHz.
Loop:
- Read sensor values from actuators, imu, etc
- Forward pass through policy network
- Send policy actions to motors
git clone https://www.github.com/kscalelabs/pyfirmware
cd pyfirmware
make setup # installs conda env
conda activate firmware
pip install .Test the actuators with a simple sinewave at low pd gains:
kbot-sineRun Kscale policies:
kbot-runRun your policies:
POLICY_DIR=<your-policy-dir> kbot-runKbot accepts keyboard (wasd) or UDP commands.
| Key(s) | Command | Change |
|---|---|---|
w / s |
x-vel | ±0.1 |
a / d |
y-vel | ±0.1 |
q / e |
yaw ω | ±0.1 |
= / - |
base height | ±0.05 |
r / f |
base roll | ±0.1 |
t / g |
base pitch | ±0.1 |
0 |
reset cmds | 0 |
z |
wave | - |
x |
salute | - |
c |
raise arms | - |
v |
boxing guard | - |
b |
left punch | - |
n |
right punch | - |
i |
base cone | - |
Kbot accepts two types of UDP commands:
- Policy commands: for arm teleop while walking/standing
- Direct joint commands: for individual joint control like grippers or upper-body-only robots
| Command | Default |
|---|---|
| xvel | 0 |
| yvel | 0 |
| yawrate | 0 |
| baseheight | 0 |
| baseroll | 0 |
| basepitch | 0 |
| rshoulderpitch | 0 |
| rshoulderroll | 0 |
| rshoulderyaw | 0 |
| relbowpitch | 0 |
| rwristroll | 0 |
| lshoulderpitch | 0 |
| lshoulderroll | 0 |
| lshoulderyaw | 0 |
| lelbowpitch | 0 |
| lwristroll | 0 |
| Full Name |
|---|
| dof_left_shoulder_pitch_03 |
| dof_left_shoulder_roll_03 |
| dof_left_shoulder_yaw_02 |
| dof_left_elbow_02 |
| dof_left_wrist_00 |
| dof_left_wrist_gripper_05 |
| dof_right_shoulder_pitch_03 |
| dof_right_shoulder_roll_03 |
| dof_right_shoulder_yaw_02 |
| dof_right_elbow_02 |
| dof_right_wrist_00 |
| dof_right_wrist_gripper_05 |
| dof_left_hip_pitch_04 |
| dof_left_hip_roll_03 |
| dof_left_hip_yaw_03 |
| dof_left_knee_04 |
| dof_left_ankle_02 |
| dof_right_hip_pitch_04 |
| dof_right_hip_roll_03 |
| dof_right_hip_yaw_03 |
| dof_right_knee_04 |
| dof_right_ankle_02 |
Send JSON-formatted UDP commands to port 10000 on localhost (127.0.0.1) or robot IP.
{
"type": "normal",
"commands": {
// Policy commands
"xvel": 0.5,
"yvel": 0.0,
"yawrate": 0.0,
"baseheight": 0.8,
"baseroll": 0.0,
"basepitch": 0.0,
// Direct joint commands
"dof_left_wrist_gripper_05": 0.57
}
}{
"type": "reset"
}Untested, unlabeled, incompatible policies that WILL break your bot:
kbot-deploy [--gstreamer] [--command-source keyboard|udp]- critical faults raise an error, stopping the firmware, rather than gracefully handling