-
Notifications
You must be signed in to change notification settings - Fork 2
Synthetic data smoke test. #75
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
Changes from all commits
bbde0a4
4661907
d5cdd97
9baa1c7
a6b983f
7ed9f25
d4145c5
8248778
be2f1aa
935c922
2e6e01c
45774d9
e9c1a4f
f14910b
f6df7e3
7b16b5a
b75b354
6f7da79
Fixed root optimization, but still some debug code.
jf514 Oct 28, 2024
5433344
2405815
9a2a599
86d333e
84793e9
82c1887
d9fe782
418a1e9
19a30e0
dc26558
dc881c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
|
||
MJCF_PATH: 'models/synth_model.xml' | ||
|
||
# Frames per clip for transform. | ||
N_FRAMES_PER_CLIP: 1 | ||
|
||
# Tolerance for the optimizations of the full model, limb, and root. | ||
# TODO: Re-implement optimizer loops to use these tolerances | ||
FTOL: 5.0e-03 | ||
ROOT_FTOL: 1.0e-05 | ||
LIMB_FTOL: 1.0e-06 | ||
|
||
# Number of alternating pose and offset optimization rounds. | ||
N_ITERS: 1 | ||
|
||
KP_NAMES: | ||
- part_0 | ||
|
||
ROOT_OPTIMIZATION_KEYPOINT: part_0 | ||
|
||
# The model sites used to register the keypoints. | ||
KEYPOINT_MODEL_PAIRS: | ||
part_0: base | ||
|
||
# The initial offsets for each keypoint in meters. | ||
KEYPOINT_INITIAL_OFFSETS: | ||
part_0: 0 0 0.01 | ||
|
||
TRUNK_OPTIMIZATION_KEYPOINTS: | ||
- part_0 | ||
|
||
INDIVIDUAL_PART_OPTIMIZATION: | ||
model_base: [base] | ||
|
||
# Color to use for each keypoint when visualizing the results | ||
KEYPOINT_COLOR_PAIRS: | ||
part_0: 0 .5 1 1 | ||
|
||
# What is the size of the animal you'd like to register, relative to the model? | ||
SCALE_FACTOR: 1 | ||
|
||
# Multiplier to put the mocap data into the same scale as the data. Eg, if the | ||
# mocap data is known to be in millimeters and the model is in meters, this is | ||
# .001 | ||
MOCAP_SCALE_FACTOR: 1 | ||
|
||
# If you have reason to believe that the initial offsets are correct for particular keypoints, | ||
# you can regularize those sites using this with M_REG_COEF. | ||
SITES_TO_REGULARIZE: | ||
- part_0 | ||
|
||
RENDER_FPS: 200 | ||
|
||
N_SAMPLE_FRAMES: 1 | ||
|
||
# If you have reason to believe that the initial offsets are correct for particular keypoints, | ||
# you can regularize those sites using _SITES_TO_REGULARIZE. | ||
M_REG_COEF: 1 | ||
jf514 marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
fit_offsets_path: "synth_fit.p" | ||
ik_only_path: "synth_ik_only.p" | ||
data_path: "tests/data/test_synth_1_frames.nwb" | ||
|
||
n_fit_frames: 1 | ||
skip_fit_offsets: False | ||
skip_ik_only: False | ||
|
||
mujoco: | ||
solver: newton | ||
iterations: 1 | ||
ls_iterations: 4 |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How was the data saved from this notebook? And were there any offsets applied to the synthetic keypoint? I wanted to test whether it finds the ground truth offset when given different initial offsets in the This notebook doesn't run as is; the rendering is cell 3 is different for me from the one shared, and the last cell throw an error: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, it's just not ready for that. I changed to the title to reflect that it's just a smoke test... ie it runs with out crashing. This PR isn't to provide that level of functionality, sadly. I've created #81 to track the next steps. Please feel free to add any specific requests to that. As for the data generation, I created a single frame of fake data (not even collected from an actual Mujoco run) just to give an output. Also, if you think there are any comments that need to be added to the code to make this clear, also lmk. |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<mujoco> | ||
<option timestep=".001"> | ||
</option> | ||
|
||
<default> | ||
<joint type="hinge" axis="0 -1 0"/> | ||
<geom type="capsule" size=".02"/> | ||
</default> | ||
|
||
jf514 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<worldbody> | ||
<light pos="0 -.4 1"/> | ||
<camera name="fixed" pos="0 -1 0" xyaxes="1 0 0 0 0 1"/> | ||
<body name="base" pos="0 0 .2"> | ||
<joint type="free" name="root"/> | ||
<geom fromto="0 0 0 0 0 -.25" rgba="1 1 0 1"/> | ||
</body> | ||
</worldbody> | ||
</mujoco> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,15 +80,22 @@ | |
self._mj_model.body(i).name for i in range(self._mj_model.nbody) | ||
] | ||
|
||
joint_names = [self._mj_model.joint(i).name for i in range(self._mj_model.njnt)] | ||
if "ROOT_OPTIMIZATION_KEYPOINT" in self.cfg.model: | ||
self._root_kp_idx = self._kp_names.index( | ||
self.cfg.model.ROOT_OPTIMIZATION_KEYPOINT | ||
) | ||
else: | ||
self._root_kp_idx = -1 | ||
jf514 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# Set up bounds and part_names based on joint ranges, taking into account the dimensionality of parameters | ||
joint_names = [self._mj_model.joint(i).name for i in range(self._mj_model.njnt)] | ||
self._lb, self._ub, self._part_names = _align_joint_dims( | ||
self._mj_model.jnt_type, self._mj_model.jnt_range, joint_names | ||
) | ||
|
||
self._indiv_parts = self.part_opt_setup() | ||
|
||
# Generate boolean flags for keypoints included in trunk optimization. | ||
self._trunk_kps = jp.array( | ||
[n in self.cfg.model.TRUNK_OPTIMIZATION_KEYPOINTS for n in kp_names], | ||
) | ||
|
@@ -113,7 +120,7 @@ | |
[any(part in name for part in parts) for name in self._part_names] | ||
) | ||
|
||
if self.cfg.model.INDIVIDUAL_PART_OPTIMIZATION is None: | ||
if "INDIVIDUAL_PART_OPTIMIZATION" not in self.cfg.model: | ||
indiv_parts = [] | ||
else: | ||
indiv_parts = jp.array( | ||
|
@@ -224,11 +231,16 @@ | |
|
||
# Begin optimization steps | ||
# Skip root optimization if model is fixed (no free joint at root) | ||
if self._mj_model.jnt_type[0] == mujoco.mjtJoint.mjJNT_FREE: | ||
if self._root_kp_idx == -1: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. makes sense 👍 |
||
print( | ||
"ROOT_OPTIMIZATION_KEYPOINT not specified, skipping Root Optimization." | ||
) | ||
elif self._mj_model.jnt_type[0] == mujoco.mjtJoint.mjJNT_FREE: | ||
jf514 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
mjx_data = compute_stac.root_optimization( | ||
mjx_model, | ||
mjx_data, | ||
kp_data, | ||
self._root_kp_idx, | ||
self._lb, | ||
self._ub, | ||
self._body_site_idxs, | ||
|
@@ -339,15 +351,20 @@ | |
) | ||
|
||
# q_phase - root | ||
if self._mj_model.jnt_type[0] == mujoco.mjtJoint.mjJNT_FREE: | ||
if self._root_kp_idx == -1: | ||
print( | ||
"Missing or invalid ROOT_OPTIMIZATION_KEYPOINT, skipping root_optimization()" | ||
) | ||
elif self._mj_model.jnt_type[0] == mujoco.mjtJoint.mjJNT_FREE: | ||
jf514 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
vmap_root_opt = jax.vmap( | ||
compute_stac.root_optimization, | ||
in_axes=(0, 0, 0, None, None, None, None), | ||
in_axes=(0, 0, 0, None, None, None, None, None), | ||
jf514 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
mjx_data = vmap_root_opt( | ||
mjx_model, | ||
mjx_data, | ||
batched_kp_data, | ||
self._root_kp_idx, | ||
self._lb, | ||
self._ub, | ||
self._body_site_idxs, | ||
|
Uh oh!
There was an error while loading. Please reload this page.