botblocks
projectsgalleryworkspacedocsprofile
introdemospythondashboardcli

demos

here are some demos, which serve as examples, references, and things to show the user.

  1. basic so101 scene. you, as the agent, can inspect the robot (especially cameras) and move the arm to put the pink cube on top of the blue cube. note: this will be far easier if you keep the gripper pointed straight down and descend on the target. picking things up as an agent is difficult! as always, use your cameras often to verify where you are. as always, only report done once the block is actually, visibly, on the goal.
from botblocks import *
so101 = Robot().load('public/so101')
cube = Box(pos=[0.28, -0.12, 0], size=0.03, color='#f8a')
goal = Box(pos=[0.22, 0.18, 0], size=0.03, color='#8cf')

MujocoEnv([Plane(), so101, cube, goal]).start()
  1. showing keyboard counter controls + showing two-arm envs
from botblocks import *
import math

left = Robot(pos=[-0.4, 0, 0]).load('public/so101')
right = Robot(pos=[0.4, 0, 0], rot=[0, 0, math.pi]).load('public/so101')
keys = KeyboardCounter(pairs=['qa', 'ws', 'ed', 'rf', 'tg', 'yh'], init=[0, -0.7, 0.9, 0, 0, 0])

@left.loop
def drive(_, env):
    pose = keys.get_axes()
    for arm in (left, right):
        for joint, angle in zip(arm['arm'].nodes, pose):
            joint.target(angle)
        arm['jaw'].target(pose[-1])

ViewerEnv([Plane(), left, right, keys]).start()
  1. reinforcement learning/ppo. note subsys=[furuta] is shorthand for subsys=[furuta['encoder'], furuta['servo']] (ie. all observable subsystems).
from botblocks import GymEnv, Plane, Robot
import math

furuta = Robot().load('public/furuta')

@furuta.loop
def reward(bot, env):
    env.reward(-math.cos(bot['encoder'].read()))

GymEnv([Plane(), furuta], subsys=[furuta]) \
    .train(n=12, shards=2, steps=600_000, spacing=0.4, net=[160, 80])
  1. diffdrive of a duckiebot + regular keyboard control
from botblocks import Robot, Plane, MujocoEnv, Box, Keyboard

duckie = Robot().load('public/duckiebot')
box = Box(pos=[0.2, 0, 0], size=0.06)
keys = Keyboard()

@duckie.loop
def _(bot, env):
    forward = .6 if 'w' in keys else -.6 if 's' in keys else 0
    turn = .4 if 'd' in keys else -.4 if 'a' in keys else 0
    bot['drive'].power(forward, turn)

MujocoEnv([Plane(), box, duckie, keys]).start()