Skip to content

Commit 4d88534

Browse files
authored
Merge pull request #76 from Simple-Robotics/next
Fixes for VideoRecorder and context
2 parents e5b18c9 + 3598c8b commit 4d88534

File tree

6 files changed

+19
-22
lines changed

6 files changed

+19
-22
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- utils/VideoRecorder.cpp : fix `m_frameCounter` not being initialized
13+
- bindings/python : fix recorder context helper
14+
1015
## [0.3.0] - 2025-06-05
1116

1217
### Added
Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,14 @@
11
from .pycandlewick.multibody import Visualizer
2+
from contextlib import contextmanager
23

34

4-
class visualizer_video_context_wrapper:
5-
def __init__(self, viz: Visualizer, filename: str, fps: int):
6-
self.visualizer = viz
7-
self.filename = filename
8-
self.fps = fps
9-
10-
def __enter__(self):
11-
self.visualizer.startRecording(filename=self.filename, fps=self.fps)
12-
13-
def __exit__(self):
14-
self.visualizer.stopRecording()
15-
16-
5+
@contextmanager
176
def create_recorder_context(viz: Visualizer, filename: str, /, fps: int = 30):
18-
return visualizer_video_context_wrapper(viz, filename, fps)
7+
viz.startRecording(filename, fps)
8+
try:
9+
yield
10+
finally:
11+
viz.stopRecording()
1912

2013

2114
__all__ = ["create_recorder_context"]

examples/Ur5WithSystems.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,13 +478,13 @@ int main(int argc, char **argv) {
478478
pin::updateGeometryPlacements(model, pin_data, geom_model, geom_data);
479479
q = qn;
480480
debug_scene.update();
481+
robot_scene.updateTransforms();
481482

482483
// acquire command buffer and swapchain
483484
CommandBuffer command_buffer = renderer.acquireCommandBuffer();
484485

485486
if (renderer.waitAndAcquireSwapchain(command_buffer)) {
486487
const GpuMat4 viewProj = g_camera.camera.viewProj();
487-
robot_scene.updateTransforms();
488488
robot_scene.collectOpaqueCastables();
489489
auto &castables = robot_scene.castables();
490490
renderShadowPassFromAABB(command_buffer, shadowPassInfo,

examples/python/go2.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"This example requires the go2_description package, which was not found. Download it at: https://github.com/inria-paris-robotics-lab/go2_description"
1111
)
1212
raise
13-
import time
1413
import tqdm
1514

1615

@@ -45,6 +44,6 @@
4544
if viz.shouldExit:
4645
break
4746
viz.display(q0)
48-
time.sleep(dt)
47+
# time.sleep(dt)
4948

5049
print("Goodbye...")

src/candlewick/multibody/Visualizer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ Visualizer::~Visualizer() {
150150
}
151151

152152
void Visualizer::displayImpl() {
153-
processEvents();
153+
this->processEvents();
154154

155155
debugScene.update();
156156
robotScene.updateTransforms();
157-
render();
157+
this->render();
158158

159159
if (!m_currentScreenshotFilename.empty()) {
160160
takeScreenshot(m_currentScreenshotFilename);

src/candlewick/utils/VideoRecorder.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ namespace media {
4242
// IMPLEMENTING CLASS ----------------------------------------------
4343

4444
struct VideoRecorderImpl {
45-
int m_width; //< Width of incoming frames
46-
int m_height; //< Height of incoming frames
47-
Uint32 m_frameCounter; //< Number of recorded frames
45+
int m_width{0}; //< Width of incoming frames
46+
int m_height{0}; //< Height of incoming frames
47+
Uint32 m_frameCounter{0}; //< Number of recorded frames
4848

4949
AVFormatContext *formatContext = nullptr;
5050
const AVCodec *codec = nullptr;

0 commit comments

Comments
 (0)