Skip to content
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

Implement basic IK in python for a single leg #124

Merged
merged 87 commits into from
Mar 12, 2025

Conversation

anton-matosov
Copy link
Contributor

@anton-matosov anton-matosov commented Mar 11, 2025

Follow the guide from https://oscarliang.com/inverse-kinematics-and-trigonometry-basics/ to implement the IK for a single leg
Deviations:

  • use direct cosine rule formulas to make it easier to spot
  • add safe_acos to easily detect non solvable solutions
  • the Y coordinate in the leg IK for alpha and beta is a projection, not a real Y. Use L1 as the value for it
  • Z_offset is simply a -z
  • Use right hand side coordinates to match ROS (X forward, Y to the left, Z up)
  • Use gamma as angle to X, this way it matches directly to joint angle

Add TF broadcast for the mathematical model joints and target location
Implement a bunch of test sequences
Calculate positions from angles with appropriate corrections for Dr.QP legs that have offset joints
Send calculated positions to /pose_async
Break if non solvable and don't send pose

drqp-2025-03-11-13-00-17

@anton-matosov
Copy link
Contributor Author

Video converted with

  ffmpeg \
  -i "drqp-2025-03-11-13-00-17.mkv" \
  -r 15 \
  -vf "scale=1024:-1,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" \
  "drqp-2025-03-11-13-00-17.gif"

@anton-matosov anton-matosov enabled auto-merge March 11, 2025 20:08
Copy link

codecov bot commented Mar 11, 2025

Codecov Report

Attention: Patch coverage is 8.36653% with 230 lines in your changes missing coverage. Please review.

Project coverage is 51.69%. Comparing base (0fc5417) to head (a67fe3d).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...ckages/runtime/drqp_brain/drqp_brain/one_leg_ik.py 0.00% 227 Missing ⚠️
packages/runtime/drqp_brain/setup.py 0.00% 3 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (0fc5417) and HEAD (a67fe3d). Click for more details.

HEAD has 2 uploads less than BASE
Flag BASE (0fc5417) HEAD (a67fe3d)
unittests-amd64 2 1
unittests-arm64 2 1
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #124      +/-   ##
==========================================
- Coverage   57.30%   51.69%   -5.62%     
==========================================
  Files          72       77       +5     
  Lines        1937     2188     +251     
  Branches       64       86      +22     
==========================================
+ Hits         1110     1131      +21     
- Misses        803     1033     +230     
  Partials       24       24              
Flag Coverage Δ
unittests-amd64 51.69% <8.36%> (-5.62%) ⬇️
unittests-arm64 51.69% <8.36%> (-5.62%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@anton-matosov anton-matosov added this pull request to the merge queue Mar 12, 2025
@anton-matosov anton-matosov removed this pull request from the merge queue due to a manual request Mar 12, 2025
@anton-matosov anton-matosov enabled auto-merge March 12, 2025 01:23
@anton-matosov anton-matosov added this pull request to the merge queue Mar 12, 2025
Merged via the queue into main with commit aa63d2b Mar 12, 2025
22 of 24 checks passed
@anton-matosov anton-matosov deleted the 112-implement-basic-ik-in-python-for-a-single-leg branch March 12, 2025 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement basic IK in python for a single leg
1 participant