Skip to content

Commit

Permalink
Simplify URDF example more
Browse files Browse the repository at this point in the history
  • Loading branch information
brentyi committed Sep 1, 2024
1 parent 3af801c commit c2f1636
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
15 changes: 11 additions & 4 deletions docs/source/examples/09_urdf_visualizer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ and viser. It can also take a path to a local URDF file as input.
def main(
urdf_path_or_name: Literal[
robot_type: Literal[
"panda",
"ur10",
"cassie",
Expand All @@ -82,13 +82,20 @@ and viser. It can also take a path to a local URDF file as input.
server = viser.ViserServer()
# Load URDF.
#
# This takes either a yourdfpy.URDF object or a path to a .urdf file.
viser_urdf = ViserUrdf(
server,
# We could also pass in a Path object to a URDF file here.
urdf_or_path=load_robot_description(urdf_path_or_name + "_description"),
urdf_or_path=load_robot_description(robot_type + "_description"),
)
(slider_handles, initial_config) = create_robot_control_sliders(server, viser_urdf)
# Create sliders in GUI that help us move the robot joints.
with server.gui.add_folder("Joint position control"):
(slider_handles, initial_config) = create_robot_control_sliders(
server, viser_urdf
)
# Set initial robot configuration.
viser_urdf.update_cfg(onp.array(initial_config))
# Create joint reset button.
Expand Down
15 changes: 11 additions & 4 deletions examples/09_urdf_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def create_robot_control_sliders(


def main(
urdf_path_or_name: Literal[
robot_type: Literal[
"panda",
"ur10",
"cassie",
Expand All @@ -71,13 +71,20 @@ def main(
server = viser.ViserServer()

# Load URDF.
#
# This takes either a yourdfpy.URDF object or a path to a .urdf file.
viser_urdf = ViserUrdf(
server,
# We could also pass in a Path object to a URDF file here.
urdf_or_path=load_robot_description(urdf_path_or_name + "_description"),
urdf_or_path=load_robot_description(robot_type + "_description"),
)

(slider_handles, initial_config) = create_robot_control_sliders(server, viser_urdf)
# Create sliders in GUI that help us move the robot joints.
with server.gui.add_folder("Joint position control"):
(slider_handles, initial_config) = create_robot_control_sliders(
server, viser_urdf
)

# Set initial robot configuration.
viser_urdf.update_cfg(onp.array(initial_config))

# Create joint reset button.
Expand Down

0 comments on commit c2f1636

Please sign in to comment.