ARISE-Initiative / robosuite

robosuite: A Modular Simulation Framework and Benchmark for Robot Learning
https://robosuite.ai
Other
1.29k stars 411 forks source link

igibson renderer's `set_camera()` requires flipped `poi` (or `target`) and weird igibson rendering results #325

Open kevin-thankyou-lin opened 2 years ago

kevin-thankyou-lin commented 2 years ago

Hi!

When I try to manually set an igibson renderer's extrinsics via renderer.set_camera(camera_pos, poi, up), I seem to need to negate the poi so that the rendered RGB gives the correct image. On the other hand, when I do the same thing in pybullet (directly in igibson), I don't need to negate the poi

Here are some (poi, -poi) pairs:

Pair 1

test0 592041931271839poi

test0 592041931271839-poi

Pair 2

test0 604845519745046poi

test0 634274057957335-poi

Pair 3

test0 0923738894608982poi test0 0923738894608982-poi

And for reference, the poi is the cube and the camera positions are sampled from the following hemisphere of green spheres: image

Also, would you know why the rendered cube doesn't have texture?

I'm using the BoxObject directly inside lift.py:

        # initialize objects of interest
        tex_attrib = {
            "type": "cube",
        }
        mat_attrib = {
            "texrepeat": "1 1",
            "specular": "0.4",
            "shininess": "0.1",
        }
        redwood = CustomMaterial(
            texture="WoodRed",
            tex_name="redwood",
            mat_name="redwood_mat",
            tex_attrib=tex_attrib,
            mat_attrib=mat_attrib,
        )
        self.cube = BoxObject(
            name="cube",
            size_min=[0.020, 0.020, 0.020],  # [0.015, 0.015, 0.015],
            size_max=[0.022, 0.022, 0.022],  # [0.018, 0.018, 0.018])
            rgba=[1, 0, 0, 1],
            material=redwood,
        )
kevin-thankyou-lin commented 2 years ago

The cause of the issue is that it seems like I need to first take env.step(action) before rendering.

Specifically,

post-env.reset() and pre-env.step() rendering gives: test0

(table and robot both collapsed to the center of the scene)

post-env.reset() and post-env.step() rendering gives: test0

A simple demo of this behavior could be reproduced in demo_renderer.py

       env.reset()
        for i in range(10000):
            # action = np.random.uniform(low, high)
            # obs, reward, done, _ = env.step(action)
            env.viewer.renderer.set_camera(np.ones(3), np.zeros(3), np.array([0, 0, 1]))
            frame = cv2.cvtColor(np.concatenate(env.viewer.renderer.render(modes=("rgb")), axis=1), cv2.COLOR_RGB2BGR)
                        cv2.imwrite("test{}.png".format(i), (frame*255).astype(np.uint8))

I think the 'correct' behavior should be env.reset() resetting the arm, table, etc. to the correct starting positions under open-ai standards (could be wrong though!)?