Skip to content

Commit 5a1a892

Browse files
committed
Platform review of server
1 parent 1c09e63 commit 5a1a892

File tree

4 files changed

+28
-27
lines changed

4 files changed

+28
-27
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
## Terms and Conditions
66

77
When you make a contribution to this project, you are agreeing to offer your
8-
contribition under the same [LICENSE.TXT](LICENSE.TXT) as the project.
8+
contribution under the same [LICENSE.TXT](LICENSE.TXT) as the project.

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,6 @@ Please share your issues and improvements on GitHub.**
1515
This software is only tested on Ubuntu 22.04 "Jammy", but should probably
1616
work with any Python interpreter that supports our `requirements.txt`.
1717

18-
## Building and testing
19-
20-
From a git checkout of `drake-blender`:
21-
22-
```sh
23-
./bazel test //...
24-
```
25-
2618
## Running the render server
2719

2820
From a git checkout of `drake-blender`:
@@ -39,6 +31,14 @@ are available in your Python runtime environment.
3931

4032
See [examples](examples/README.md).
4133

34+
## Testing (for developers)
35+
36+
From a git checkout of `drake-blender`:
37+
38+
```sh
39+
./bazel test //...
40+
```
41+
4242
# Credits
4343

4444
The Drake-Blender project was created by the

server.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,9 @@ def render_image(self, *, params: RenderParams, output_path: Path):
138138
exec(code, {"bpy": bpy}, dict())
139139

140140
# Import a glTF file. Note that the Blender glTF importer imposes a
141-
# 90-degree rotation along X-axis when loading meshes. Thus, we
141+
# +90 degree rotation around the X-axis when loading meshes. Thus, we
142142
# counterbalance the rotation right after the glTF-loading.
143+
# TODO(#39) This is very suspicious. Get to the bottom of it.
143144
bpy.ops.import_scene.gltf(filepath=str(params.scene))
144145
bpy.ops.transform.rotate(
145146
value=math.pi/2, orient_axis='X', orient_type='GLOBAL'
@@ -151,9 +152,8 @@ def render_image(self, *, params: RenderParams, output_path: Path):
151152
scene.render.filepath = str(output_path)
152153
scene.render.resolution_x = params.width
153154
scene.render.resolution_y = params.height
154-
aspect_ratio = params.focal_y / params.focal_x
155155
scene.render.pixel_aspect_x = 1.0
156-
scene.render.pixel_aspect_y = aspect_ratio
156+
scene.render.pixel_aspect_y = params.focal_y / params.focal_x
157157

158158
# Set camera parameters.
159159
camera = bpy.data.objects.get("Camera Node")
@@ -169,6 +169,10 @@ def render_image(self, *, params: RenderParams, output_path: Path):
169169
# Set the clipping planes using {min, max}_depth when rendering depth
170170
# images; otherwise, `near` and `far` are set for color and label
171171
# images.
172+
# TODO(#38) This clipping logic fails to implement kTooClose.
173+
# When there is geometry within [near,far] clip but outside [min,max]
174+
# depth, we should return zero (too close) not maxint (too far). Fix
175+
# the code here and add regression tests for both too-close and -far.
172176
camera.data.clip_start = (
173177
params.min_depth if params.min_depth else params.near
174178
)
@@ -181,17 +185,9 @@ def render_image(self, *, params: RenderParams, output_path: Path):
181185
params.center_y - 0.5 * params.height
182186
) / params.width
183187

184-
# TODO(bassamul.haq/zachfang): Currently, `camera.data.angle` will not
185-
# be set if the values of fov_x and fov_y are different. The code path
186-
# needs to be tested.
187-
if params.fov_x == params.fov_y:
188-
camera.data.lens_unit = "FOV"
189-
camera.data.angle = params.fov_x
190-
else:
191-
_logger.warning(
192-
f"fov_x {params.fov_x} != fov_y {params.fov_y}. "
193-
"'camera.data.angle' is not set."
194-
)
188+
camera.data.lens_unit = "FOV"
189+
camera.data.angle_x = params.fov_x
190+
camera.data.angle_y = params.fov_y
195191

196192
# Set image_type specific functionality.
197193
if params.image_type == "color":
@@ -294,7 +290,7 @@ def create_depth_node_layer(self, min_depth=0.01, max_depth=10.0):
294290

295291
# Convert depth measurements via a MapValueNode. The depth values are
296292
# measured in meters, and thus they are converted to millimeters first.
297-
# Blender scales the pixel values by 65535 (2^16 -1) when producing an
293+
# Blender scales the pixel values by 65535 (2^16 -1) when producing a
298294
# UINT16 image, so we need to offset that to get the correct UINT16
299295
# depth.
300296
assert (

test/server_test.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ def test_label_render(self):
182182
)
183183

184184
# Test color and depth image rendering given a rgba and a textured mesh.
185-
# Note: Rendering a label image is not applicable for any textured objects.
185+
# (We do not check a label image because by definition an RPC for a label
186+
# image will never contain any textured objects.)
186187
def test_texture_color_render(self):
187188
self._render_and_check(
188189
gltf_path="test/one_rgba_one_texture_boxes.gltf",
@@ -203,7 +204,11 @@ def test_consistency(self):
203204
"""Tests the consistency of the render results from consecutive
204205
requests. Each image type is first rendered and compared with the
205206
ground truth images. A second image is then rendered and expected to be
206-
pixel-identical as the first one.
207+
pixel-identical as the first one. As with all things Drake, we expect
208+
reproducible simulations, so if there is any randomness in the render
209+
pipeline it's the responsibility of the server to configure it so that
210+
the exact same RPC call produces the exact same image output no matter
211+
how it's called or how many times it's called.
207212
"""
208213
TestCase = namedtuple(
209214
"TestCase", ["image_type", "reference_image", "threshold"]
@@ -227,7 +232,7 @@ def test_consistency(self):
227232
returned_image_paths.append(first_image)
228233

229234
for index, test_case in enumerate(test_cases):
230-
second_image = self._render_and_check(
235+
self._render_and_check(
231236
gltf_path=DEFAULT_GLTF_FILE,
232237
image_type=test_case.image_type,
233238
reference_image_path=returned_image_paths[index],

0 commit comments

Comments
 (0)