scurve trajectory planner

  • Grotius
  • Grotius's Avatar Topic Author
  • Away
  • Platinum Member
  • Platinum Member
More
15 Feb 2025 20:52 #321661 by Grotius
Replied by Grotius on topic scurve trajectory planner
github.com/dkogan/libdogleg

Dogleg runs.
You basicly provide the equatation in a callback function. Then it iterates until result is within treshold.

Startvalue a=1
Startvalue b= 1
Increment a= 1
Increment b = 1

10 = 3 + a x b

This will do
result = left hand - right hand
0 = 10 - 3 + 1 x 1
Finally
0 = 0
The following user(s) said Thank You: tommylight, HalaszAttila

Please Log in or Create an account to join the conversation.

  • Grotius
  • Grotius's Avatar Topic Author
  • Away
  • Platinum Member
  • Platinum Member
More
17 Feb 2025 14:33 #321837 by Grotius
Replied by Grotius on topic scurve trajectory planner
Hi,

At this stage, we are able to plot something with gnu plot.

In the main.c there is a 2d & 3d example.

When having problems, i decided to revert to implement the 2d solution from eq.46, to get a more simpler overall calculation.

To focus on the 2d solution. The plot is not as should be.
It plots 4 connected clothoids. But the start angle of upcoming clothoid looks to be inverted.
The clothoid compound start, end angle seems to be ok. Start at 45 degrees, end at -45 degrees.

This 2d examples does not focus on the transformation equations. As these transformations can be seen completely seperate.
And it does not use the dogleg solver. It turns out without dogleg solver, initial guess values are most of time ok.

For 2d, there are 2 unknown variables. y21 & s1. In the sample i set a value for y21=1 & for s1=1, this seems to work ok.

Reviewing my code would be appreciated.

updated source
Here is the 2d plot.


 
Attachments:
The following user(s) said Thank You: Aciera

Please Log in or Create an account to join the conversation.

More
17 Feb 2025 16:36 #321845 by Aciera
Replied by Aciera on topic scurve trajectory planner
Thanks for all the work!
At a first glance I'm a bit confused what you are doing in your test. Why are you using equations 17..20 and 44?

In my opinion the workflow should be like this.
1. eq 25, 26 or 29,30 depending on type of segments (line or arc)
2. eq 31, 32, 33 to calculate the transformation matrix T
3. eq 35 calculate the transformed derivatives
4. eq 39 calculate theta_1,0, _2,0, _1,4 and _2,4
5. eq 40 calculate kappa_1,0, _2,0, _1,4 and _2,4
6. eq 43,42 calculate c_1,0, _2,0, _1,4 and _2,4
7. dogleg to calculate gamma_1,1, _2,1 and s1
8. eq 45 to calculate the rest.

I'll have a more in depth look tomorrow.
The following user(s) said Thank You: Grotius

Please Log in or Create an account to join the conversation.

More
17 Feb 2025 18:20 #321851 by Aciera
Replied by Aciera on topic scurve trajectory planner
please, could you also put the 'dogleg' dependency on the repo?
The following user(s) said Thank You: Grotius

Please Log in or Create an account to join the conversation.

  • Grotius
  • Grotius's Avatar Topic Author
  • Away
  • Platinum Member
  • Platinum Member
More
17 Feb 2025 19:52 - 17 Feb 2025 20:01 #321861 by Grotius
Replied by Grotius on topic scurve trajectory planner
@Arciera,

Thanks for all the work!
Pff. If you don't know what you are doing. It's kind off keeping the patience for a long long time.

updated source
I removed the dogleg dependencies for now. it's not used at this moment. Later on will activate it again.

To know more about eq44 and how it works, i started at your item 7, and used not the dogleg, but a initial guess value.
Then to item 8.

It seems now to plot a clothoid 4 compound in 3d.
I used eq.14 as a startpoint to get succes.

Using xy angle 45 degrees at start.
Using z angle 45 degrees at end.


Basicly i understand how the dogleg algo works.
It run's a given function until the function result is within treshold, <1e-6.
It uses one or more variables with a initial guess value. It also updates a inverse jacobian "J" in the iteration, wich
i think we need, but not for sure.

However, if you compute function eq44_G123, the function error is alway's near absolute zero.
As a result of that, the dogleg solver does nothing at this moment.

1. Basicly eq44 is not ok. It should return a error value, then dogleg can optimize.
2. I don't understand yet, how to get the clothoid compound to fit the given end point.

And for info. I did not use any fresnel header file, fresnels are not used, maybe also wrong.
Attachments:
Last edit: 17 Feb 2025 20:01 by Grotius.
The following user(s) said Thank You: HalaszAttila

Please Log in or Create an account to join the conversation.

More
18 Feb 2025 07:40 - 18 Feb 2025 08:14 #321898 by Aciera
Replied by Aciera on topic scurve trajectory planner

Basicly eq44 is not ok. It should return a error value, then dogleg can optimize

I guess the error is in the end position (se)

I don't understand yet, how to get the clothoid compound to fit the given end point.

In my opinion that is what the dogleg is supposed to work with:
 

subtract the right side from the left we get 3 equations :

x_traj(s0) + integral_term - x_traj(se) = 0
y_traj(s0) + integral_term - y_traj(se) = 0
z_traj(s0) + integral_term - z_traj(se) = 0

However I don't know how to calculate the integral_terms in the algorithm.


Also we need dogleg to solve for 3 unknown variables using the system of 3 equations above which it apparently can do but I have no idea how to set that up.
Attachments:
Last edit: 18 Feb 2025 08:14 by Aciera.
The following user(s) said Thank You: Grotius

Please Log in or Create an account to join the conversation.

More
18 Feb 2025 08:28 #321900 by Aciera
Replied by Aciera on topic scurve trajectory planner
Looking at the readme in the dogleg library:
github.com/dkogan/libdogleg?tab=readme-ov-file

It seems that we might want to start with 'dogleg_optimize_dense' or 'dogleg_optimize_dense2' as these calls don't expect a Jacobian.

 

'p' would be a vector with 3 elements [gamma_1,1, gamma_2,1, s_1] containing our initial guesses when calling and the optimized results in the end.

'Nstate' = 3

'f' would be the system of 3 equations in the last post. This is where I'm stuck at the moment.
 
Attachments:
The following user(s) said Thank You: Grotius

Please Log in or Create an account to join the conversation.

  • Grotius
  • Grotius's Avatar Topic Author
  • Away
  • Platinum Member
  • Platinum Member
More
18 Feb 2025 09:48 #321904 by Grotius
Replied by Grotius on topic scurve trajectory planner
@Arciera,

Thanks for your responce.

Indeed, the error is likely the endpos. I was thinking the same yesterday night.

error = distance "requested endpos" - "guess endpos"

When playing with different Y11, 21 gues values using the same length s1:
Changing the guess values Y11, Y21 will influence the rigid of the clothoid compound.

Picture values from left to right :      
Y11=1 Y21=1
Y11=0.5 Y21=0.5
Y11=0.1 Y21=0.1
 

Now i will try to setup the dogleg method. Using our new criteria.

The Jacobian usage seems to be more effiecient in finding the solution. But without is also no problem and
will result in more iterations to find the fit solution.

Your point at eq44 if solved here as a example : eq14
This eq14 is not a optimized function yet.  And for calculating the clothoid endpoint, i want to make a
few one liners today.

Plan :
1. Create a function to calculate the spline endpoint efficient, using y11, y21, s1.  Eq14 current code is not effiecient for this.
2. Create a Dogleg fit function to optimize y11, y21, s1 values that the spline compound fit's the given endpoint. (Magic function).

For info, to be aware off:
In linuxcnc we use G2,G3 as helix. This abstact isn't taking account of helixes. Only flat arc's for input,
We will create a solution that uses a end vector of any type of curve.

For info:
Deepseek is better in reading pdf files than Chatgpt.
Also the code example from Deepseek are better.
So i often just upload the clothoid_3d.pdf to deekseek and start asking questions.
This really helps the process. Deepseek just throw's out a full dogleg c implementation. It's amazing.

Let's hope the Magic Function will find the solution for endpos.
Attachments:
The following user(s) said Thank You: Aciera

Please Log in or Create an account to join the conversation.

More
18 Feb 2025 10:10 - 18 Feb 2025 10:12 #321905 by Aciera
Replied by Aciera on topic scurve trajectory planner
yes, eq 14 :
 

because we set s1=s2=s3=s4 we need to integrate from 0 to 4*s1.

It's still unclear to me how dogleg optimizes a system of 3 equations as it would not get back a single residual value but rather a vector with 3 residual elements.
 
Attachments:
Last edit: 18 Feb 2025 10:12 by Aciera.
The following user(s) said Thank You: Grotius

Please Log in or Create an account to join the conversation.

More
18 Feb 2025 10:23 #321907 by Aciera
Replied by Aciera on topic scurve trajectory planner
I guess we could simply calculate the length of our 3D residual vector and pass that back as the error value to be minimized.
The following user(s) said Thank You: Grotius

Please Log in or Create an account to join the conversation.

Time to create page: 0.151 seconds
Powered by Kunena Forum