-
Notifications
You must be signed in to change notification settings - Fork 7
Fix the gauge freedom for PGO #14
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
Open
zitongzhan
wants to merge
20
commits into
release
Choose a base branch
from
fix_gauge_pgo
base: release
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
6b541dc
Fix torch.cat to skip Jacobian traces for non-optimizable tensors
zitongzhan db25bf1
fix warning
zitongzhan e5bde70
fix warning
zitongzhan 1875dcc
guard warp bsr add to prevent unnecessarily long col
zitongzhan 0f0fb84
add the gauge free pgo
zitongzhan 923698c
pgo data
zitongzhan 556b2b0
add the SO3 pose adj
zitongzhan 33cbfd0
amend
zitongzhan 6aed4c1
fix the diagonal op (may not be useful)
zitongzhan 517c1b9
the non-log type loss function
zitongzhan 0a35cfa
minimize changes
zitongzhan 2ecbce1
[ci] add matplotlib dep
zitongzhan cb3439f
relax the ceres test to 1e-7
zitongzhan d01dd1e
add gif rendering
zitongzhan b208500
Merge branch 'release' into fix_gauge_pgo
zitongzhan d98e786
fix manual merge defects
zitongzhan 3288321
[pgo] convergence test
zitongzhan 90aec56
Merge branch 'release' into fix_gauge_pgo
zitongzhan 217936a
monkey patch pp
zitongzhan b9be50e
add the jacobian localization to test case as well
zitongzhan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -13,3 +13,4 @@ task.md | |
| *.png | ||
| .DS_Store | ||
| tmp/* | ||
| examples/module/pgo/data/* | ||
This file contains hidden or 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,3 @@ | ||
| from .utils.pypose_ambient_grad import maybe_install_pypose_ambient_grad_monkeypatch | ||
|
|
||
| maybe_install_pypose_ambient_grad_monkeypatch() |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,59 @@ | ||
| import torch | ||
|
|
||
|
|
||
| def skew_symmetric(v: torch.Tensor) -> torch.Tensor: | ||
| x, y, z = v.unbind(dim=-1) | ||
| zero = torch.zeros_like(x) | ||
| rows = ( | ||
| torch.stack((zero, -z, y), dim=-1), | ||
| torch.stack((z, zero, -x), dim=-1), | ||
| torch.stack((-y, x, zero), dim=-1), | ||
| ) | ||
| return torch.stack(rows, dim=-2) | ||
|
|
||
|
|
||
| def quat_mul_xyzw(q1: torch.Tensor, q2: torch.Tensor) -> torch.Tensor: | ||
| x1, y1, z1, w1 = q1.unbind(dim=-1) | ||
| x2, y2, z2, w2 = q2.unbind(dim=-1) | ||
| return torch.stack(( | ||
| w1 * x2 + x1 * w2 + y1 * z2 - z1 * y2, | ||
| w1 * y2 - x1 * z2 + y1 * w2 + z1 * x2, | ||
| w1 * z2 + x1 * y2 - y1 * x2 + z1 * w2, | ||
| w1 * w2 - x1 * x2 - y1 * y2 - z1 * z2, | ||
| ), dim=-1) | ||
|
|
||
|
|
||
| def quat_conj_xyzw(q: torch.Tensor) -> torch.Tensor: | ||
| return torch.cat((-q[..., :3], q[..., 3:4]), dim=-1) | ||
|
|
||
|
|
||
| def quat_inv_xyzw(q: torch.Tensor) -> torch.Tensor: | ||
| return quat_conj_xyzw(q) / q.square().sum(dim=-1, keepdim=True) | ||
|
|
||
|
|
||
| def quat_rotate_xyzw(q: torch.Tensor, v: torch.Tensor) -> torch.Tensor: | ||
| qv = torch.cat((v, torch.zeros_like(v[..., :1])), dim=-1) | ||
| return quat_mul_xyzw(quat_mul_xyzw(q, qv), quat_inv_xyzw(q))[..., :3] | ||
|
|
||
|
|
||
| def quaternion_plus_jacobian_xyzw(quat: torch.Tensor) -> torch.Tensor: | ||
| qx, qy, qz, qw = quat.unbind(dim=-1) | ||
| rows = ( | ||
| torch.stack((qw, qz, -qy), dim=-1), | ||
| torch.stack((-qz, qw, qx), dim=-1), | ||
| torch.stack((qy, -qx, qw), dim=-1), | ||
| torch.stack((-qx, -qy, -qz), dim=-1), | ||
| ) | ||
| return 0.5 * torch.stack(rows, dim=-2) | ||
|
|
||
|
|
||
| def se3_pose_plus_jacobian_xyzw(pose: torch.Tensor) -> torch.Tensor: | ||
| if pose.shape[-1] != 7: | ||
| raise ValueError(f"Expected 7D pose blocks, got {pose.shape[-1]}.") | ||
|
|
||
| J = torch.zeros(*pose.shape[:-1], 7, 6, dtype=pose.dtype, device=pose.device) | ||
| eye = torch.eye(3, dtype=pose.dtype, device=pose.device) | ||
| J[..., :3, :3] = eye | ||
| J[..., :3, 3:6] = -skew_symmetric(pose[..., :3]) | ||
| J[..., 3:7, 3:6] = quaternion_plus_jacobian_xyzw(pose[..., 3:7]) | ||
| return J |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 is no longer needed because mm supports all float types now