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

Cannot assign to .ctrl via named indexers #238

Closed
saran-t opened this issue Apr 12, 2022 Discussed in #237 · 0 comments
Closed

Cannot assign to .ctrl via named indexers #238

saran-t opened this issue Apr 12, 2022 Discussed in #237 · 0 comments

Comments

@saran-t
Copy link
Member

saran-t commented Apr 12, 2022

Discussed in #237

Originally posted by DrawZeroPoint April 12, 2022
Dear MuJoCo developers,

I am using the 2.1.4 version python binding of MuJoCo to control actuators with codes. So far, I encountered an odd issue that may be due to my improper way to use the API, so any suggestions are gratefully appreciated.

The simplified code I am using is like this:

actuator = self._data.actuator(actuator_name)
actuator.ctrl = cmd

where I can confirm that _data is initialized and contains the actuator; cmd is a plain float number. Oddly, the second line gives the error:

IndexError: too many indices for array: array is 0-dimensional, but 1 were indexed

I wonder if it is due to .ctrl should not be used in this way? What I planned to do is to assign the control value cmd to the actuator.
Previously with mujoco-py, I did the same thing like this:

self.sim.data.ctrl[actuator_id] = cmd
```</div>
@saran-t saran-t changed the title Proper way to control the actuator via python? Cannot assign to .ctrl via named indexers Apr 12, 2022
kevinzakka pushed a commit to kevinzakka/mujoco that referenced this issue May 24, 2022
NumPy arrays with an empty shape cannot be assigned via the usual syntax.

Fixes: google-deepmind#238.
Related: google-deepmind#237.
PiperOrigin-RevId: 441265437
Change-Id: Ib0de22c83f9babe9a97682dc5a32660c198ad68c
kevinzakka pushed a commit to kevinzakka/mujoco that referenced this issue May 24, 2022
NumPy arrays with an empty shape cannot be assigned via the usual syntax.

Fixes: google-deepmind#238.
Related: google-deepmind#237.
PiperOrigin-RevId: 441265437
Change-Id: Ib0de22c83f9babe9a97682dc5a32660c198ad68c
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