Skip to content

Commit 98afc3e

Browse files
authored
a small fix (#476)
* a small fix * make it or
1 parent e5d3d78 commit 98afc3e

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

mujoco_py/mjpid.pyx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ cdef mjtNum c_pid_bias(const mjModel* m, const mjData* d, int id) with gil:
8080
d.userdata[id * NUM_USER_DATA_PER_ACT + IDX_LAST_ERROR] = error
8181
d.userdata[id * NUM_USER_DATA_PER_ACT + IDX_DERIVATIVE_ERROR_LAST] = derivative_error
8282
d.userdata[id * NUM_USER_DATA_PER_ACT + IDX_INTEGRAL_ERROR] = integral_error
83-
return fmax(effort_limit_low, fmin(effort_limit_high, f))
83+
84+
if effort_limit_low != 0.0 or effort_limit_high != 0.0:
85+
f = fmax(effort_limit_low, fmin(effort_limit_high, f))
86+
return f
8487

8588

8689
def set_pid_control(m, d):

mujoco_py/tests/test_pid.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@
3636
"""
3737

3838
P_ONLY_ACTUATOR = """
39-
<general ctrlrange='-1 1' gaintype="user" biastype="user" forcerange="-100 100" gainprm="200" joint="hinge" name="a-hinge"/>
39+
<general ctrlrange='-1 1' gaintype="user" biastype="user" gainprm="200" joint="hinge" name="a-hinge"/>
4040
"""
4141

4242
POSITION_ACTUATOR = """
43-
<position ctrlrange='-1 1' forcerange="-100 100" kp=200 joint="hinge" name="a-hinge"/>
43+
<position ctrlrange='-1 1' kp=200 joint="hinge" name="a-hinge"/>
4444
"""
4545

4646

@@ -87,8 +87,8 @@ def test_mj_proptional_only():
8787
sim.data.qpos[0] = sim2.data.qpos[0] = init_pos
8888
sim.data.ctrl[0] = sim2.data.ctrl[0] = 0
8989

90-
for i in range(20):
90+
for i in range(2000):
9191
print(i, sim.data.qpos[0], sim2.data.qpos[0])
9292
sim.step()
9393
sim2.step()
94-
assert abs(sim.data.qpos[0] - sim2.data.qpos[0]) <= 1e-5, "%d step violates" % i
94+
assert abs(sim.data.qpos[0] - sim2.data.qpos[0]) <= 1e-7, "%d step violates" % i

mujoco_py/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
__all__ = ['__version__', 'get_version']
22

3-
version_info = (2, 0, 2, 7)
3+
version_info = (2, 0, 2, 8)
44
# format:
55
# ('mujoco_major', 'mujoco_minor', 'mujoco_py_major', 'mujoco_py_minor')
66

0 commit comments

Comments
 (0)