-
Notifications
You must be signed in to change notification settings - Fork 47
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
fix spacemouse action transformation direction #38
Conversation
@@ -94,3 +94,12 @@ def transform_action(self, action: np.ndarray): | |||
action = np.array(action) # in case action is a jax read-only array | |||
action[:6] = self.adjoint_matrix @ action[:6] | |||
return action | |||
|
|||
def transform_action_inv(self, action: np.ndarray): | |||
""" |
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.
can you add description that this assumes last dimension is gripper open/close?
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.
There's actually description in the docstring for the entire wrapper class. It just requires the first 6 dimensions to be translation+rotation, and does not assume anything about gripper dimension.
class RelativeFrame(gym.Wrapper):
"""
This wrapper transforms the observation and action to be expressed in the end-effector frame.
Optionally, it can transform the tcp_pose into a relative frame defined as the reset pose.
This wrapper is expected to be used on top of the base Franka environment, which has the following
observation space:
{
"state": spaces.Dict(
{
"tcp_pose": spaces.Box(-np.inf, np.inf, shape=(7,)), # xyz + quat
......
}
),
......
}, and at least 6 DoF action space with (x, y, z, rx, ry, rz, ...)
"""
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.
Ok, then what's the assumption for the 7th>?
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.
Doesn't assume anything for the 7th. It can also be non-existant. All the code only indices the first 6 dimensions action[:6]
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.
then can we add a simple description of the expected 7th dimension? e.g., discrete/continuous gripper status
please also fix the precommit error |
actions = np.zeros((6,)) | ||
next_obs, rew, done, truncated, info = env.step(action=actions) | ||
if "intervene_action" in info: | ||
actions = info["intervene_action"] |
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.
how does this code run correctly without issues previously?
if "intervene_action" is None, the previous code always assumes
actions = info["intervene_action"]
and this doesn't throw out errors?
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.
My bad, there was a change in the IntervenetionWrapper that I missed. Now it puts intervene_action
in info only if intervene_action is nonzero
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 was more talking the code in the left
next_obs, rew, done, truncated, info = env.step(action=np.zeros((7,)))
actions = info["intervene_action"]
does this code run without issues previously? the actions can be unassigned in certain cases
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.
it used to be always assigned. If no intervention was provided, then the policy action is just put in info['intervene_action'], but this meant the intervene_action were in two different frames depending on whether it's from the policy or the spacemouse
|
||
def step(self, action): | ||
new_action = self.action(action) | ||
|
||
new_action, replaced = self.action(action) |
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.
replaced
is always False?
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.
It's set to true in line 205, which is when the current time is within 0.5 seconds of the previous nonzero spacemouse action (0.5 sec delay until the control is handed back to the policy)
did you get this code tested on real robot ? |
Hi all, this includes the fix for the spacemouse intervention action transformation bug that was found this week. The spacemouse actions are given in the base frame, so it should be transformed into the end-effector frame to be learned by the policy. Previously, the transformation from end-effector frame to base frame was applied to this action.