Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing camera pose #43

Open
ozgraslan opened this issue Aug 11, 2022 · 0 comments
Open

Changing camera pose #43

ozgraslan opened this issue Aug 11, 2022 · 0 comments

Comments

@ozgraslan
Copy link

Hello,

I am trying to change the pose of the camera during simulation.
There are already implemented functions in furniture class: _set_camera_position for mujoco renderer and _set_camera_pose for unity renderer. When I tried to use _set_camera_pose, it did not change the camera pose. But _set_camera_position works using the mujoco renderer.
I used following code. Am I missing something for the unity case?

import gym
import furniture
import numpy as np
from furniture import agent_names, background_names, furniture_names
import matplotlib.pyplot as plt


env_name = "IKEA{}-v0".format(agent_names[0])
furniture_name= furniture_names[0]
background_name = background_names[2]
unity = False 
camera_id = 0
new_pose = np.array([1,1,1, 1,0,0,0])
env = gym.make(env_name, furniture_name=furniture_name, background=background_name, 
                unity=unity, camera_ids = [camera_id])

env.reset()
old_rgb = env.render("rgb_array")[0]
if unity:
    env.env._set_camera_pose(camera_id, new_pose)
else:
    env.env._set_camera_position(camera_id, new_pose[:3])
    env.env.sim.model.cam_quat[camera_id] = new_pose[3:]
    env.env.sim.forward()
    env.env.sim.step()

new_rgb = env.render("rgb_array")[0]

fig = plt.figure()
fig.add_subplot(2, 1, 1)
plt.imshow(old_rgb)
fig.add_subplot(2, 1, 2)
plt.imshow(new_rgb)
plt.show()

Outputs:
Mujoco:
mjc
Unity:
unity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant