Serving URDF Files Locally#
This tutorial shows you how to serve a URDF file locally. We will use the MIT Mini Cheetah robot as an example.
Before you start, letβs first download the URDF file from here.
mkdir -p mini_cheetah/meshes
cd "mini_cheetah" && wget -O "mini_cheetah.urdf" https://github.com/geyang/unitree-go1-setup-guide/raw/main/robots/mini_cheetah/mini_cheetah.urdf
cd "meshes"
wget -O "mini_abad.obj" https://github.com/geyang/unitree-go1-setup-guide/raw/main/robots/mini_cheetah/meshes/mini_abad.obj
wget -O "mini_body.obj" https://github.com/geyang/unitree-go1-setup-guide/raw/main/robots/mini_cheetah/meshes/mini_body.obj
wget -O "mini_lower_link.obj" https://github.com/geyang/unitree-go1-setup-guide/raw/main/robots/mini_cheetah/meshes/mini_lower_link.obj
wget -O "mini_upper_link.obj" https://github.com/geyang/unitree-go1-setup-guide/raw/main/robots/mini_cheetah/meshes/mini_upper_link.obj
You should have the following directory structure:
βββ meshes
β βββ mini_abad.obj
β βββ mini_body.obj
β βββ mini_lower_link.obj
β βββ mini_upper_link.obj
βββ mini_cheetah.urdf
2 directories, 5 files
import math
from asyncio import sleep
from pathlib import Path
from vuer import Vuer, VuerSession
from vuer.schemas import DefaultScene, Urdf, Movable
pi = 3.1415
app = Vuer(static_root=Path(__file__).parent / "mini_cheetah")
# this starts the vuer server immediately after this function is declared.
@app.spawn(start=True)
async def main(app: VuerSession):
# Note: you can only use `set` operator with Scene objects. This is a special operator.
app.set @ DefaultScene(
Movable(
Urdf(
src="http://localhost:8012/static/mini_cheetah.urdf",
jointValues={
"FL_hip_joint": -0.2,
"RL_hip_joint": -0.2,
"FR_hip_joint": 0.2,
"RR_hip_joint": 0.2,
"FL_thigh_joint": -0.25 * pi,
"RL_thigh_joint": -0.25 * pi,
"FR_thigh_joint": -1.3,
"RR_thigh_joint": -0.25 * pi,
"FL_calf_joint": 0.5 * pi,
"RL_calf_joint": 0.5 * pi,
"FR_calf_joint": 0.6 * pi,
"RR_calf_joint": 0.5 * pi,
},
key="robot",
),
position=[0, 0, 0.3],
scale=0.4,
),
grid=True,
)
await sleep(0.1)
i = 0
while True:
app.update @ Urdf(
src="http://localhost:8012/static/mini_cheetah.urdf",
jointValues={
"FL_hip_joint": -0.2,
"RL_hip_joint": -0.2,
"FR_hip_joint": 0.2,
"RR_hip_joint": 0.2,
"FL_thigh_joint": -0.25 * pi,
"RL_thigh_joint": -0.25 * pi,
"FR_thigh_joint": 0.5 * math.sin(i * 0.1) - 1.3,
"RR_thigh_joint": -0.25 * pi,
"FL_calf_joint": 0.5 * pi,
"RL_calf_joint": 0.5 * pi,
"FR_calf_joint": -0.5 * math.sin(i * 0.1) + 0.6 * pi,
"RR_calf_joint": 0.5 * pi,
},
key="robot",
)
await sleep(0.016)
i += 1
Now, if your script runs correctly, the robot should show up in the following view: