Created
February 27, 2021 20:54
-
-
Save rfdickerson/44fd0a35292b9c798b26b5458d086f2c to your computer and use it in GitHub Desktop.
ik- newton
This file contains 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
@jit | |
def forward(state): | |
return forward_ik(state["angles"], state["lengths"]) | |
@jit | |
def checker(state): | |
end_location = forward(state) | |
distance = jnp.linalg.norm(end_location - state["target"]) | |
return distance > 0.00001 | |
@jit | |
def step(state): | |
d = forward(state) - state["target"] | |
J_inv = jnp.linalg.pinv(J(state["angles"], state["lengths"])) | |
state["angles"] -= jnp.dot(J_inv, d) | |
state["history"]["iterations"] += 1 | |
return state | |
def inverse_kinematics(state): | |
return while_loop(checker, step, state) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment