Skip to content

Commit 00178f4

Browse files
authored
Merge pull request #81 from kevinzakka/new-release
Remove upper bound on numpy version.
2 parents 0ac8ce2 + 64ae2f8 commit 00178f4

File tree

6 files changed

+60
-23
lines changed

6 files changed

+60
-23
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
All notable changes to this project will be documented in this file.
44

5-
## Unreleased
5+
## [0.0.9] - 2025-04-21
66

77
### Changed
88

99
- Switch Lie algebra implementation to use mujoco functions.
1010
- Rewrite some Lie algebra methods to use derivations with least operations.
1111
- Relax tolerances on test_solve_ik.py test_single_task_convergence.
12+
- Relax numpy version requirement.
1213

1314
## [0.0.8] - 2025-04-21
1415

CONTRIBUTING.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,36 @@
11
# Contributing
22

3-
Some ways to contribute to mink:
3+
Thanks for your interest in contributing to **mink**! Here are a few great ways to get involved:
44

5-
- Try out the [examples](examples) and report any issue.
6-
- Pick something you want to do with one of the many [robot descriptions](https://github.com/robot-descriptions/robot_descriptions.py) and write a new example.
7-
- Find a use case that is not covered and write a unit test for it.
5+
- Try out the [examples](examples) and report any issues.
6+
- Pick something you'd like to do with one of the many [robot descriptions](https://github.com/robot-descriptions/robot_descriptions.py) and write a new example.
7+
- Find a use case that isn’t covered yet and write a unit test for it.
88
- Improve the documentation.
99
- Implement new tasks or constraints.
1010

11-
If any of those sound interesting, open an [issue](https://github.com/kevinzakka/mink/issues) and say you're on it!
11+
If any of those sound interesting, open an [issue](https://github.com/kevinzakka/mink/issues) and let us know you're on it!
12+
13+
## Pull Requests
14+
15+
When submitting a pull request, please make sure to:
16+
17+
- **Update the [changelog](CHANGELOG.md)** with a short description of your change.
18+
- **Run all tests** locally to ensure nothing is broken. You can do this with:
19+
20+
```bash
21+
pytest .
22+
```
23+
24+
If you’re adding new functionality, consider adding corresponding tests and updating the docs if applicable.
1225

1326
## Documentation
1427

15-
If you're adding new functionality to `mink` and want to update the documentation, you can build it and visualize it locally using the following:
28+
If youre adding new functionality to mink and want to update the documentation, you can build it and preview it locally like this:
1629

1730
```bash
1831
uv pip install -r docs/requirements.txt
1932
sphinx-build docs _build -W
2033
open _build/index.html
2134
```
35+
36+
Thanks again for helping make `mink` better!

mink/lie/se3.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,15 @@ def exp(cls, tangent: np.ndarray) -> SE3:
116116
assert tangent.shape == (cls.tangent_dim,)
117117
rotation = SO3.exp(tangent[3:])
118118
theta = np.float64(mujoco.mju_norm3(tangent[3:]))
119-
t2 = theta * theta
119+
t2 = theta * theta
120120
if t2 < get_epsilon(t2.dtype):
121121
v_mat = rotation.as_matrix()
122122
else:
123123
skew_omega = skew(tangent[3:])
124124
v_mat = (
125125
np.eye(3, dtype=np.float64)
126-
+ (1.0 - np.cos(theta)) / t2
127-
* skew_omega
128-
+ (theta - np.sin(theta)) / (t2 * theta)
129-
* (skew_omega @ skew_omega)
126+
+ (1.0 - np.cos(theta)) / t2 * skew_omega
127+
+ (theta - np.sin(theta)) / (t2 * theta) * (skew_omega @ skew_omega)
130128
)
131129
return cls.from_rotation_and_translation(
132130
rotation=rotation,
@@ -136,7 +134,9 @@ def exp(cls, tangent: np.ndarray) -> SE3:
136134
def inverse(self) -> SE3:
137135
inverse_wxyz_xyz = np.empty(SE3.parameters_dim, dtype=np.float64)
138136
mujoco.mju_negQuat(inverse_wxyz_xyz[:4], self.wxyz_xyz[:4])
139-
mujoco.mju_rotVecQuat(inverse_wxyz_xyz[4:], -1.0 * self.wxyz_xyz[4:], inverse_wxyz_xyz[:4])
137+
mujoco.mju_rotVecQuat(
138+
inverse_wxyz_xyz[4:], -1.0 * self.wxyz_xyz[4:], inverse_wxyz_xyz[:4]
139+
)
140140
return SE3(wxyz_xyz=inverse_wxyz_xyz)
141141

142142
def normalize(self) -> SE3:
@@ -170,9 +170,10 @@ def log(self) -> np.ndarray:
170170
else:
171171
half_theta = 0.5 * theta
172172
vinv_mat = (
173-
np.eye(3, dtype=np.float64)
173+
np.eye(3, dtype=np.float64)
174174
- 0.5 * skew_omega
175-
+ (1.0 - 0.5 * theta * np.cos(half_theta) / np.sin(half_theta)) / t2
175+
+ (1.0 - 0.5 * theta * np.cos(half_theta) / np.sin(half_theta))
176+
/ t2
176177
* skew_omega2
177178
)
178179
tangent = np.empty(SE3.tangent_dim, dtype=np.float64)

mink/lie/so3.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,12 @@ def ljac(cls, other: np.ndarray) -> np.ndarray:
190190
theta = np.float64(mujoco.mju_norm3(other))
191191
t2 = theta * theta
192192
if theta < get_epsilon(theta.dtype):
193-
alpha = (1.0 / 2.0) * (1.0 - t2 / 12.0 * (1.0 - t2 / 30.0 * (1.0 - t2 / 56.0)))
194-
beta = (1.0 / 6.0) * (1.0 - t2 / 20.0 * (1.0 - t2 / 42.0 * (1.0 - t2 / 72.0)))
193+
alpha = (1.0 / 2.0) * (
194+
1.0 - t2 / 12.0 * (1.0 - t2 / 30.0 * (1.0 - t2 / 56.0))
195+
)
196+
beta = (1.0 / 6.0) * (
197+
1.0 - t2 / 20.0 * (1.0 - t2 / 42.0 * (1.0 - t2 / 72.0))
198+
)
195199
else:
196200
t3 = t2 * theta
197201
alpha = (1 - np.cos(theta)) / t2
@@ -224,13 +228,17 @@ def ljacinv(cls, other: np.ndarray) -> np.ndarray:
224228
theta = np.float64(mujoco.mju_norm3(other))
225229
t2 = theta * theta
226230
if theta < get_epsilon(theta.dtype):
227-
beta = (1.0 / 12.0) * (1.0 + t2 / 60.0 * (1.0 + t2 / 42.0 * (1.0 + t2 / 40.0)))
231+
beta = (1.0 / 12.0) * (
232+
1.0 + t2 / 60.0 * (1.0 + t2 / 42.0 * (1.0 + t2 / 40.0))
233+
)
228234
else:
229-
beta = (1.0 / t2) * (1.0 - (theta * np.sin(theta) / (2.0 * (1.0 - np.cos(theta)))))
235+
beta = (1.0 / t2) * (
236+
1.0 - (theta * np.sin(theta) / (2.0 * (1.0 - np.cos(theta))))
237+
)
230238
# ljacinv = eye(3) - 0.5 * skew_other + beta * (skew_other @ skew_other)
231-
ljacinv = np.empty((3,3))
239+
ljacinv = np.empty((3, 3))
232240
# skew_other @ skew_other == outer(other) - inner(other) * eye(3)
233-
mujoco.mju_mulMatMat(ljacinv, other.reshape(3,1), other.reshape(1,3))
241+
mujoco.mju_mulMatMat(ljacinv, other.reshape(3, 1), other.reshape(1, 3))
234242
inner_product = mujoco.mju_dot3(other, other)
235243
ljacinv[0, 0] -= inner_product
236244
ljacinv[1, 1] -= inner_product

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi"
44

55
[project]
66
name = "mink"
7-
version = "0.0.8"
7+
version = "0.0.9"
88
readme = "README.md"
99
authors = [
1010
{name = "Kevin Zakka", email = "zakka@berkeley.edu"},
@@ -29,7 +29,7 @@ dependencies = [
2929
"mujoco >= 3.1.6",
3030
"qpsolvers[daqp] >= 4.3.1",
3131
"typing_extensions",
32-
"numpy < 2.0.0",
32+
"numpy",
3333
]
3434
keywords = ["inverse", "kinematics", "mujoco"]
3535

tests/test_lie_operations.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,18 @@ def test_so3_interpolate(self):
136136
start.interpolate(end, alpha=2.0)
137137
self.assertIn(expected_error_message, str(cm.exception))
138138

139+
def test_so3_apply(self):
140+
vec = np.random.rand(3)
141+
rot = SO3.sample_uniform()
142+
rotated_vec = rot.apply(vec)
143+
np.testing.assert_allclose(rotated_vec, rot.as_matrix() @ vec)
144+
145+
def test_so3_apply_throws_assertion_error_if_wrong_shape(self):
146+
rot = SO3.sample_uniform()
147+
vec = np.random.rand(2)
148+
with self.assertRaises(AssertionError):
149+
rot.apply(vec)
150+
139151
# SE3.
140152

141153
def test_se3_equality(self):

0 commit comments

Comments
 (0)