-
Notifications
You must be signed in to change notification settings - Fork 507
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
[BE] - fix inconsistent base_rot property #2085
Conversation
…sts. Activate and fix skipped humanoid unit tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Tested on the HITL stack. Left some general comments.
assert kin_humanoid.get_robot_sim_id() == 1 # 0 is the ground plane | ||
assert ( | ||
kin_humanoid.get_robot_sim_id() == 2 | ||
) # 0 is the stage and 1 is the ground plane |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use constants here for clarity (enum?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't a general thing. The stage_id is a constant from sim, but the others are just situational here.
produce_debug_video = False | ||
observations = [] | ||
cfg_settings = default_sim_settings.copy() | ||
cfg_settings["scene"] = "NONE" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to know :)
"color", | ||
"test_base_rot", | ||
open_vid=True, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea!
angle += mn.math.pi * 2 | ||
# NOTE: This final fmod ensures that large angles are mapped back into the -2pi, 2pi range. | ||
angle = mn.math.fmod(angle, 2 * mn.math.pi) | ||
return angle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, it would be more robust to force usage of forward vectors or rotation quaternions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that we are baking in lots of assumptions using a scalar angle about Y axis with implicitly defined origin.
Happy to re-design this part of the system, but pretty deeply embedded, so just trying to get it to behave consistently for now.
Motivation and Context
This PR addresses a long-standing bug in the
articulated_agent.base_rot
property API.The bug: 🐛
Rotations are stored internally as
Magnum.Quaternion
objects. Thebase_rot
property operates in scalar space, namely the angle of rotation about the Y axis. This means that every call to the setter creates a Quaternion from a rotation angle and Y axis, while the getter deconstructs a Quaternion into an angle using 2arccos.While the result is correct in some sense, it does not account for:
This results in the potential for several nasty bugs. The most obvious being that getting an angle after settings does not return the same scalar value (it could be a correct, but different angle) and could return an erroneous value (e.g. if the quaternion axis is inverted during normalization).
The solution:
This PR modifies the getter to:
Together, these changes result in a few nice guarantees from the function:
-pi ==pi
. This means, e.g.base_rot = pi/2
guaranteesbase_rot == pi/2
.base_rot = base_rot + 0.1
with the expected outcome of continual rotation.How Has This Been Tested
Added unit tests for robot wrapper and humanoid wrapper.
This includes changes from #2084. Note that CI was failing there and is now passing.
test_base_rot.mp4
Types of changes
Checklist