google-deepmind / google-deepmind/mujoco
mujoco.mj_contactForce in mujoco-js / WASM doesn't seem to do anything
- Dominant language
- C++
- Stars
- 15.2k
- Forks
- 1.8k
- Avg merge
- 10d 16h
- Merged PRs (30d)
- 25
Description
### Intro
CC @yuvaltassa
I'm trying to create a realtime simulation with mujoco-js and want to implement audio for collisions, so I'd like to access the contact impulse. However, none of the expected methods to retrieve contact information seem to work correctly.
### My setup
- mujoco-js 0.0.7 / WASM (not sure what mujoco version that equates; ideally that'd be documented in the npm package README)
- Firefox 147.0.2 (x64)
- CachyOS
### What's happening? What did you expect?
Calling `mujoco.mj_contactForce` doesn't seem to do anything.
I'd expect it to return the impulse.
### Steps for reproduction
This does nothing
```ts
//
// [...]
function eachFrame() {
mujoco.mj_step(model, data);
for(let i = 0; i < data.ncon; i++) {
const impulse = new Float64Array([1,2,3,4,5,6]); //alternative: new Float64Array(6);
mujoco.mj_contactForce(model, data, i, impulse); // returns undefined
// impulse is *still* [1,2,3,4,5,6], so nothing was done
}
}
```
### Minimal model for reproduction
_No response_
### Code required for reproduction
_No response_
### Confirmations
- [x] I searched the [latest documentation](https://mujoco.readthedocs.io/en/latest/overview.html) thoroughly before posting.
- [x] I searched previous [Issues](https://github.com/google-deepmind/mujoco/issues) and [Discussions](https://github.com/google-deepmind/mujoco/discussions), I am certain this has not been raised before.
Contributor guide
Assessment
This issue has not been assessed yet.