22import jax .numpy as jnp
33import trimesh
44import b3d
5+ import rerun as rr
56
7+ PORT = 8812
8+ rr .init ("real" )
9+ rr .connect (addr = f"127.0.0.1:{ PORT } " )
610
711def test_renderer_full (renderer ):
812 mesh_path = os .path .join (
@@ -15,7 +19,7 @@ def test_renderer_full(renderer):
1519 object_library .add_trimesh (mesh )
1620
1721 pose = b3d .Pose .from_position_and_target (
18- jnp .array ([0.2 , 0.2 , 0.0 ]), jnp .array ([0.0 , 0.0 , 0.0 ])
22+ jnp .array ([0.2 , 0.2 , 0.2 ]), jnp .array ([0.0 , 0.0 , 0.0 ])
1923 ).inv ()
2024
2125 rgb , depth = renderer .render_attribute (
@@ -39,17 +43,21 @@ def test_renderer_normal_full(renderer):
3943 object_library .add_trimesh (mesh )
4044
4145 pose = b3d .Pose .from_position_and_target (
42- jnp .array ([0.2 , 0.2 , 0.0 ]), jnp .array ([0.0 , 0.0 , 0.0 ])
46+ jnp .array ([0.2 , 0.2 , 0.2 ]), jnp .array ([0.0 , 0.0 , 0.0 ])
4347 ).inv ()
4448
45- _ , _ , normal = renderer .render_attribute_normal (
49+ rgb , depth , normal = renderer .render_attribute_normal (
4650 pose [None , ...],
4751 object_library .vertices ,
4852 object_library .faces ,
4953 jnp .array ([[0 , len (object_library .faces )]]),
5054 object_library .attributes ,
5155 )
5256
53- normal = jnp .abs (normal )
54- b3d .get_rgb_pil_image (normal ).save (b3d .get_root_path () / "assets/test_results/test_ycb_normal.png" )
55- assert normal .sum () > 0
57+ b3d .get_rgb_pil_image ((normal + 1 )/ 2 ).save (b3d .get_root_path () / "assets/test_results/test_ycb_normal.png" )
58+
59+ point_im = b3d .utils .unproject_depth (depth , renderer )
60+ rr .log ("pc" , rr .Points3D (point_im .reshape (- 1 ,3 ), colors = rgb .reshape (- 1 ,3 )))
61+ rr .log ("arrows" , rr .Arrows3D (origins = point_im [::5 ,::5 ,:].reshape (- 1 ,3 ), vectors = normal [::5 ,::5 ,:].reshape (- 1 ,3 )/ 100 ))
62+
63+ assert jnp .abs (normal ).sum () > 0
0 commit comments