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

RSDK-9076 make ik functions more generic #4467

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

biotinker
Copy link
Member

This PR removes the concept of Frames from IK, in preparation for motion planning supporting solving for framesystem states in general rather than simply the pose of one component relative to another.

This involves making some minor tweaks to our PTG and InverseKinematics interfaces, and also alters nlopt IK removing the restricted solving range, something that was very arm-centric and questionably useful

@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Oct 18, 2024
Copy link
Contributor

Availability

Scene # viamrobotics:main biotinker:20241018_RSDK-9076-make-ik-functions-more-generic Percent Improvement Health
1 100% 100% 0%
2 100% 100% 0%
3 100% 100% 0%
4 100% 100% 0%
5 90% 90% 0%
6 80% 70% -12%
7 30% 30% 0%
8 100% 100% 0%
9 100% 100% 0%
10 100% 100% 0%
11 100% 100% 0%
12 100% 100% 0%
13 100% 100% 0%
14 100% 100% 0%
15 100% 100% 0%
16 100% 100% 0%
17 100% 100% 0%
18 50% 40% -20%

Quality

Scene # viamrobotics:main biotinker:20241018_RSDK-9076-make-ik-functions-more-generic Percent Improvement Probability of Improvement Health
1 1.31±0.00 1.31±0.00 -0% 0%
2 0.90±0.00 0.90±0.00 0% 100%
3 3.83±1.70 3.49±1.60 9% 56%
4 4.36±1.23 4.16±1.00 5% 55%
5 19.84±11.79 16.50±11.39 17% 58%
6 13.06±4.84 15.40±4.79 -18% 37%
7 6.57±3.36 4.78±1.79 27% 68%
8 4.54±0.88 4.74±0.49 -4% 42%
9 4.35±0.22 4.41±0.44 -1% 45%
10 4.21±0.50 4.45±0.44 -6% 36%
11 4.88±0.60 5.55±0.72 -14% 24%
12 3.73±1.17 3.96±1.11 -6% 44%
13 904.77±13.78 904.77±13.78 -0% 50%
14 1731.30±554.13 2129.60±711.35 -23% 33%
15 52301.78±6616.50 50549.88±4594.49 3% 59%
16 60951.17±7299.39 54723.04±11672.98 10% 67%
17 16340.41±2147.25 15859.97±5452.61 3% 53%
18 126233.73±8856.54 134694.32±34143.39 -7% 41%

Performance

Scene # viamrobotics:main biotinker:20241018_RSDK-9076-make-ik-functions-more-generic Percent Improvement Probability of Improvement Health
1 0.09±0.00 0.09±0.00 -4% 31%
2 0.11±0.01 0.16±0.02 -55% 0%
3 0.53±0.31 0.56±0.26 -5% 47%
4 1.99±0.13 2.00±0.11 -1% 46%
5 2.95±1.24 2.95±0.89 -0% 50%
6 2.43±1.07 3.09±1.08 -27% 33%
7 3.69±1.29 2.07±0.16 44% 89%
8 0.54±0.48 0.26±0.13 51% 71%
9 4.88±0.41 4.96±0.21 -2% 43%
10 0.13±0.02 0.13±0.02 0% 51%
11 0.10±0.00 0.10±0.01 5% 76%
12 0.13±0.01 0.12±0.01 3% 68%
13 0.07±0.01 0.08±0.01 -8% 25%
14 0.75±0.31 0.72±0.24 3% 52%
15 1.22±0.12 1.45±0.23 -19% 19%
16 2.26±1.08 2.42±1.29 -7% 46%
17 1.41±0.22 1.50±0.26 -6% 39%
18 4.91±0.21 4.70±0.57 4% 63%

The above data was generated by running scenes defined in the motion-testing repository
The SHA1 for viamrobotics:main is: 900738751a11aa6be03dd90a3932f38e1c35f187
The SHA1 for biotinker:20241018_RSDK-9076-make-ik-functions-more-generic is: 900738751a11aa6be03dd90a3932f38e1c35f187

  • 10 samples were taken for each scene
  • A timeout of 5.0 seconds was imposed for each trial

Copy link
Member

@nfranczak nfranczak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall lgtm, just questions and some nits.

motionplan/ik/inverseKinematics.go Show resolved Hide resolved
@@ -59,21 +55,24 @@ type optimizeReturn struct {
// CreateNloptIKSolver creates an nloptIK object that can perform gradient descent on metrics for Frames. The parameters are the Frame on
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] comment should be updated here

motionplan/ik/nloptInverseKinematics.go Show resolved Hide resolved
if len(gradient) > 0 {
// Yes, the for loop below is logically equivalent to not having this if statement. But CPU branch prediction means having the
// if statement is faster.
for i := range gradient {
jumpVal = jump[i]
flip := false
inputs[i].Value += jumpVal
x[i] += jumpVal
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] should use something more descriptive than x

PTG

// Returns the set of trajectory nodes along the given trajectory, out to the requested distance.
// This will return `TrajNode`s starting at dist=start, and every `resolution` increments thereafter, and finally at `end` exactly.
// This could
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops. Not sure where that came from!

components/base/kinematicbase/execution.go Show resolved Hide resolved
logger logging.Logger
solvers []InverseKinematics
logger logging.Logger
lowerBound []float64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this is "in preparation for motion planning supporting solving for framesystem states in general" wouldn't it make more sense for lowerBound to be of type [][]float64?

Is the overall motivation of supporting solving for framesystem states so that we can plan for coordinated motion?
What is general motivation of this work?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want [][]float64, because ik still operates on arrays of floats; it is simply a generic function rather than specifically a Frame on which Transform is called.

The overall motivation is to make it easy for motionplan to solve for framesystem states, yes. But that is not the same thing as actually passing framesystems into ik, that's not what we want. We just want ik here to be a generic function, so that we may create a distance function which measures a frame system, a single frame, or something else unrelated to frames.

for i, l := range lowerBound {
u := upperBound[i]

// Default to [-999,999] as range if limits are infinite
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this range and not [-9999,9999]?
why these numbers specifically?
[opt] 999 could probably be turned into a constant?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is essentially a random number. There's no reason for 999 or 9999 except that 999 is what we've always used. This function has simply moved from being a method on nlopt.

We need something to set as the limits in the event of infinity, and the actual value chosen should not matter very much as gradient descent should take care of it.

Agree this should be a constant.

motionplan/ik/inverseKinematics.go Show resolved Hide resolved
motionplan/motionPlanner.go Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test This pull request is marked safe to test from a trusted zone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants