Repository navigation
scarakins, three21kins: keep joints within a half turn of the previous value #4867
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
Merged
Merged
Changes from all commits
Commits
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
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 @@ | ||
| ../shared-checkresult |
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 @@ | ||
| ../shared-skip |
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 @@ | ||
| ../shared-test.sh |
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,11 @@ | ||
| # The walks pumakins-unwrap took for #4585 and #4708. The wrist pitch, | ||
| # joint 5, is left out: at +-180 the wrist is folded back on itself, a | ||
| # singularity where joints 4 and 6 are not determined. | ||
| # joints 4 and 6 together from 150 and 140 | ||
| pumakins start=20,-20,100,150,35,140 mask=40 | ||
| # the waist, joint 1, from 150 | ||
| pumakins start=150,-20,100,30,35,40 mask=1 | ||
| # the shoulder, joint 2, from 150 | ||
| pumakins start=20,150,100,30,35,40 mask=2 | ||
| # the elbow, joint 3, from 150 | ||
| pumakins start=20,-20,150,30,35,40 mask=4 |
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 @@ | ||
| ../shared-checkresult |
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 @@ | ||
| ../shared-skip |
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 @@ | ||
| ../shared-test.sh |
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 @@ | ||
| # joint 0 across 180 with the elbow bent each way | ||
| scarakins start=150,30,0,0,0,0 mask=1 | ||
| scarakins start=150,-30,0,0,0,0 mask=1 |
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,7 @@ | ||
| #!/bin/sh | ||
| # every walk in walks ran and held | ||
| n=$(grep -cv '^[[:space:]]*\(#\|$\)' "$(dirname "$1")/walks") | ||
| [ "$n" -ge 1 ] \ | ||
| && [ "$(grep -c '^=== ' "$1")" = "$n" ] \ | ||
| && [ "$(grep -c 'joints continuous' "$1")" = "$n" ] \ | ||
| && ! grep -q "FAIL" "$1" |
File renamed without changes.
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,20 @@ | ||
| #!/bin/bash | ||
| # Walk kinematics joints across +-180 the way motion calls them. Each | ||
| # line of walks is a module and the walkcheck arguments for one walk. | ||
| # One directory per module, so runtests -j runs them side by side. | ||
| set -e | ||
|
|
||
| [ -r walks ] || { echo "Error: file 'walks' does not exist"; exit 1; } | ||
|
|
||
| halcompile --install ../walkcheck.c >/dev/null | ||
|
|
||
| # every walk runs, so one failure does not hide the next | ||
| status=0 | ||
| while read -r kins args; do | ||
| case "$kins" in ''|'#'*) continue ;; esac | ||
| printf 'loadrt %s\nloadrt walkcheck %s\n' "$kins" "$args" > walk.hal | ||
| echo "=== $kins $args" | ||
| halrun -f walk.hal < /dev/null || status=1 | ||
| done < walks | ||
| rm -f walk.hal | ||
| exit $status | ||
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 @@ | ||
| ../shared-checkresult |
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 @@ | ||
| ../shared-skip |
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 @@ | ||
| ../shared-test.sh |
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,5 @@ | ||
| # pumakins' walks: three21kins carries its solver | ||
| three21kins start=20,-20,100,150,35,140 mask=40 | ||
| three21kins start=150,-20,100,30,35,40 mask=1 | ||
| three21kins start=20,150,100,30,35,40 mask=2 | ||
| three21kins start=20,-20,150,30,35,40 mask=4 |
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,124 @@ | ||
| /* Check that a kinematics module keeps its joints continuous (#4585). | ||
| * | ||
| * Loaded after the module under test, so kinematicsForward() and | ||
| * kinematicsInverse() resolve to it. A failed check fails the load, and | ||
| * a failed load fails the test. | ||
| * | ||
| * An inverse that takes its joints from atan2(), or from a difference of | ||
| * two, lands in (-180, 180] or (-360, 360], so a joint crossing a half | ||
| * turn comes back a whole turn away in one call. Walk the joints in mask | ||
| * 60 degrees up from start, across +-180, and back down, as motion does: | ||
| * take the pose of each step from the forward and hand the inverse the | ||
| * joints of the step before. The inverse has to return the joints that | ||
| * made the pose, not ones a turn away. | ||
| * | ||
| * Author: LinuxCNC | ||
| * License: GPL Version 2 | ||
| * System: Linux | ||
| * | ||
| * Copyright (c) 2026 All rights reserved. | ||
| */ | ||
|
|
||
| #include <rtapi.h> | ||
| #include <rtapi_app.h> | ||
| #include <rtapi_errno.h> | ||
| #include <rtapi_math.h> | ||
| #include <rtapi_string.h> | ||
| #include <hal.h> | ||
| #include <emcpos.h> | ||
| #include <kinematics.h> | ||
|
|
||
| MODULE_LICENSE("GPL"); | ||
| MODULE_DESCRIPTION("kinematics joint unwrap checker"); | ||
|
|
||
| static int start[6]; | ||
| RTAPI_MP_ARRAY_INT(start, 6, "joints to start the walk from"); | ||
|
|
||
| static int mask = 1; | ||
| RTAPI_MP_INT(mask, "joints to walk, bit 0 for joint 0"); | ||
|
|
||
| /* degrees the inverse may drift from the joints that made the pose; the | ||
| round trip is exact, this only covers floating point noise */ | ||
| #define TOL 1e-6 | ||
| #define STEP 2.5 | ||
|
|
||
| static int comp_id = -1; | ||
| static int failures; | ||
| static int poses; | ||
|
|
||
| static void step(double *prev, const double *j) | ||
| { | ||
| EmcPose world; | ||
| double out[6]; | ||
| KINEMATICS_FORWARD_FLAGS ff = 0; | ||
| KINEMATICS_INVERSE_FLAGS inf = 0; | ||
| double worst = 0.0; | ||
| int i; | ||
|
|
||
| poses++; | ||
| if (kinematicsForward(j, &world, &ff, &inf)) { | ||
| rtapi_print_msg(RTAPI_MSG_ERR, "walkcheck: FAIL forward at %g %g %g %g %g %g\n", | ||
| j[0], j[1], j[2], j[3], j[4], j[5]); | ||
| failures++; | ||
| return; | ||
| } | ||
| memcpy(out, prev, sizeof(out)); | ||
| if (kinematicsInverse(&world, out, &inf, &ff)) { | ||
| rtapi_print_msg(RTAPI_MSG_ERR, "walkcheck: FAIL inverse at %g %g %g %g %g %g\n", | ||
| j[0], j[1], j[2], j[3], j[4], j[5]); | ||
| failures++; | ||
| return; | ||
| } | ||
| for (i = 0; i < 6; i++) { | ||
| if (fabs(out[i] - j[i]) > worst) { worst = fabs(out[i] - j[i]); } | ||
| } | ||
| if (worst > TOL) { | ||
| rtapi_print_msg(RTAPI_MSG_ERR, | ||
| "walkcheck: FAIL at %g %g %g %g %g %g: got %g %g %g %g %g %g," | ||
| " worst joint error %g\n", | ||
| j[0], j[1], j[2], j[3], j[4], j[5], | ||
| out[0], out[1], out[2], out[3], out[4], out[5], worst); | ||
| failures++; | ||
| } | ||
| memcpy(prev, out, sizeof(out)); | ||
| } | ||
|
|
||
| static void walk_to(double *j, double *prev, int n) | ||
| { | ||
| int i; | ||
|
|
||
| for (i = 0; i < 6; i++) { | ||
| if (mask & (1 << i)) { j[i] = start[i] + n * STEP; } | ||
| } | ||
| step(prev, j); | ||
| } | ||
|
|
||
| int rtapi_app_main(void) | ||
| { | ||
| double j[6], prev[6]; | ||
| int i, n; | ||
|
|
||
| if (mask <= 0 || mask >= (1 << 6)) { | ||
| rtapi_print_msg(RTAPI_MSG_ERR, "walkcheck: mask %d must pick from joints 0 to 5\n", mask); | ||
| return -EINVAL; | ||
| } | ||
|
|
||
| comp_id = hal_init("walkcheck"); | ||
| if (comp_id < 0) { return comp_id; } | ||
|
|
||
| for (i = 0; i < 6; i++) { j[i] = prev[i] = start[i]; } | ||
| for (n = 0; n <= 24; n++) { walk_to(j, prev, n); } | ||
| for (n = 24; n >= 0; n--) { walk_to(j, prev, n); } | ||
|
|
||
| if (failures) { | ||
| rtapi_print_msg(RTAPI_MSG_ERR, "walkcheck: %d of %d pose(s) failed\n", | ||
| failures, poses); | ||
| hal_exit(comp_id); | ||
| return -ERANGE; | ||
| } | ||
| rtapi_print("walkcheck: joints continuous over %d pose(s)\n", poses); | ||
| hal_ready(comp_id); | ||
| return 0; | ||
| } | ||
|
|
||
| void rtapi_app_exit(void) { hal_exit(comp_id); } |
This file was deleted.
Oops, something went wrong.
This file was deleted.
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.
Uh oh!
There was an error while loading. Please reload this page.