Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions mujoco_warp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
from mujoco_warp._src.forward import rungekutta4 as rungekutta4
from mujoco_warp._src.forward import step1 as step1
from mujoco_warp._src.forward import step2 as step2
from mujoco_warp._src.history import init_ctrl_history as init_ctrl_history
from mujoco_warp._src.history import init_sensor_history as init_sensor_history
from mujoco_warp._src.history import read_ctrl as read_ctrl
from mujoco_warp._src.history import read_sensor as read_sensor
from mujoco_warp._src.inverse import inverse as inverse
from mujoco_warp._src.io import create_render_context as create_render_context
from mujoco_warp._src.io import get_data_into as get_data_into
Expand Down
13 changes: 12 additions & 1 deletion mujoco_warp/_src/forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from mujoco_warp._src import collision_driver
from mujoco_warp._src import constraint
from mujoco_warp._src import derivative
from mujoco_warp._src import history
from mujoco_warp._src import island
from mujoco_warp._src import math
from mujoco_warp._src import passive
Expand Down Expand Up @@ -302,6 +303,9 @@ def _advance(m: Model, d: Data, qacc: wp.array, qvel: Optional[wp.array] = None)
outputs=[d.qpos],
)

# advance history buffers before time advance
history.insert_ctrl_history(m, d)

wp.launch(
_next_time,
dim=d.nworld,
Expand Down Expand Up @@ -1098,6 +1102,13 @@ def fwd_actuation(m: Model, d: Data):
d.actuator_force.zero_()
return

# read delayed ctrl (or direct copy if no delay)
if m.nhistory > 0:
ctrl = wp.empty((d.nworld, m.nu), dtype=float)
history.read_ctrl_delayed(m, d, ctrl)
else:
ctrl = d.ctrl

wp.launch(
_actuator_force,
dim=(d.nworld, m.nu),
Expand All @@ -1122,7 +1133,7 @@ def fwd_actuation(m: Model, d: Data):
m.actuator_acc0,
m.actuator_lengthrange,
d.act,
d.ctrl,
ctrl,
d.actuator_length,
d.actuator_velocity,
m.opt.disableflags & DisableBit.CLAMPCTRL,
Expand Down
Loading
Loading