dm_control icon indicating copy to clipboard operation
dm_control copied to clipboard

Updating positions of sites during environment reset

Open mohakbhardwaj opened this issue 3 years ago • 3 comments

Hi, I have an environment where the robot needs to reach different goal positions that are randomized at every timestep. I am representing the goal as a site on the worldbody in the xml file for visualization purposes. However, while I update the site_xpos using with physics.reset_context(): physics.named.data.site_xpos["goal"] = np.random.uniform(low,high) the location of the site does not get updated in the dm_viewer. Is there a way to update site position in the viewer or am I using the functionality incorrectly? Thanks!

mohakbhardwaj avatar Apr 10 '22 04:04 mohakbhardwaj

You want to change model.site_pos rather than data.site_xpos. xpos quantities get overwritten by kinematics.

Makes sense?

yuvaltassa avatar Apr 10 '22 08:04 yuvaltassa

As an aside, if you have the site as an mjcf.Element, you can bind the mjcf.Physics object to it and query/change physical quantities much more easily. You can read about it here.

kevinzakka avatar Apr 10 '22 18:04 kevinzakka

As an aside, if you have the site as an mjcf.Element, you can bind the mjcf.Physics object to it and query/change physical quantities much more easily. You can read about it here.

Yes, this worked for me. Thanks!

mohakbhardwaj avatar Apr 10 '22 19:04 mohakbhardwaj