Skip to content

Commit 70bc60b

Browse files
committed
Update README and ur10_loop.py
1 parent 4806a21 commit 70bc60b

File tree

2 files changed

+13
-23
lines changed

2 files changed

+13
-23
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,23 @@ Here's a Python example:
3636
```python
3737
import example_robot_data as erd
3838
import pinocchio as pin
39-
import numpy as np
40-
from candlewick.multibody import Visualizer, VisualizerConfig
39+
from candlewick import Visualizer, VisualizerConfig, create_recorder_context
4140

4241
robot = erd.load("ur10")
4342
model: pin.Model = robot.model
44-
data: pin.Data = robot.data
45-
visual_model = robot.visual_model
43+
visual_model: pin.GeometryModel = robot.visual_model
4644

4745
config = VisualizerConfig()
4846
config.width = 1280
4947
config.height = 720
5048
viz = Visualizer(config, model, visual_model)
5149

5250
q0 = pin.neutral(model)
53-
viz.setCameraPose(pin.SE3.Identity())
54-
viz.display(q0)
51+
viz.addFrameViz(model.getFrameId("tool0"))
52+
53+
with create_recorder_context(viz, "ur10_video.mp4"):
54+
while not viz.shouldExit:
55+
viz.display(q0)
5556
```
5657

5758

examples/python/ur10_loop.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,23 @@
1010
visual_model = robot.visual_model
1111

1212
config = VisualizerConfig()
13-
config.width = 1280
14-
config.height = 720
13+
config.width = 1920
14+
config.height = 1080
1515
viz = Visualizer(config, model, visual_model)
1616

17-
print(
18-
"Visualizer has renderer:",
19-
viz.renderer,
20-
"driver name:",
21-
viz.renderer.device.driverName(),
22-
)
23-
2417
q0 = pin.neutral(model)
2518
q1 = pin.randomConfiguration(model)
2619

2720
t = 0.0
2821
dt = 0.02
29-
M = pin.SE3.Identity()
30-
ee_name = "ee_link"
31-
ee_id = model.getFrameId(ee_name)
32-
print(viz.model)
22+
viz.addFrameViz(frame_id=model.getFrameId("ee_link"))
3323

34-
for i in range(1000):
24+
i = 0
25+
while not viz.shouldExit and i < 1000:
3526
alpha = np.sin(t)
3627
q = pin.interpolate(model, q0, q1, alpha)
3728
pin.framesForwardKinematics(model, data, q)
38-
M = data.oMf[ee_id]
39-
if viz.shouldExit:
40-
break
4129
viz.display(q)
4230
time.sleep(dt)
4331
t += dt
32+
i += 1

0 commit comments

Comments
 (0)