-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"""Common functions and fixtures for flybody tests.""" | ||
|
||
import numpy as np | ||
|
||
|
||
def is_force_actuator(physics, actuator_id=None): | ||
"""Check if actuator with given id is a force actuator with ctrlrange == (-1, 1). | ||
If actuator_id is None, check all actuators. | ||
""" | ||
physics.reset() | ||
if actuator_id is None: | ||
inds = [*range(physics.model.nu)] | ||
else: | ||
assert isinstance(actuator_id, int) | ||
inds = [actuator_id] | ||
for i in inds: | ||
assert physics.model.actuator_gainprm[i][0] != 0. | ||
assert np.all(physics.model.actuator_gainprm[i][1:] == 0.) | ||
assert np.all(physics.model.actuator_biasprm[i][:] == 0.) | ||
assert physics.model.actuator_gaintype[i] == 0. | ||
assert physics.model.actuator_biastype[i] == 0. | ||
if physics.model.actuator_trntype[i] != 5: | ||
# Force actuator (on either joint or tendon). | ||
assert np.all(physics.model.actuator_ctrlrange[i] == (-1, 1)) | ||
else: | ||
# Adhesion actuator. | ||
assert np.all(physics.model.actuator_ctrlrange[i] == (0, 1)) | ||
|
||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters