Skip to content

Instantly share code, notes, and snippets.

@cohnt
Created January 25, 2025 01:05
Show Gist options
  • Save cohnt/8fb1cbfbbcd7ed30a6ee3bdad048d9c0 to your computer and use it in GitHub Desktop.
Save cohnt/8fb1cbfbbcd7ed30a6ee3bdad048d9c0 to your computer and use it in GitHub Desktop.
import numpy as np
import time
from pydrake.all import (
StartMeshcat,
RigidTransform,
RotationMatrix
)
meshcat = StartMeshcat()
rot = np.array([
[-1, 0, 0],
[0, 0, -1],
[0, -1, 0]
])
# print(np.linalg.det(rot))
trans = np.array([0, 0, 1])
tf = RigidTransform(RotationMatrix(rot), trans)
limits = [[0, 20], [0, 20]]
meshcat.Set2dRenderMode(X_WC=tf,
xmin=limits[0][0] - 1,
xmax=limits[0][1] + 1,
ymin=limits[1][0] - 1,
ymax=limits[1][1] + 1)
starts = [[0, 0, 0], [0, 0, 0]]
ends = [[5, 15, 0], [15, 5, 0]]
starts = np.asarray(starts).T
ends = np.asarray(ends).T
meshcat.SetLineSegments(
path="thin_line",
start=starts[:,:1],
end=ends[:,:1],
line_width=1.0 # Works if 0.1 on firefox
)
meshcat.SetLineSegments(
path="thick_line",
start=starts[:,1:],
end=ends[:,1:],
line_width=10.0
)
while True:
time.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment