- #1
- 19
- 1
What I am actually trying to do:
I actually want to program (better) smooth camera tracking of objects for a hobby project of mine: HLAE / AfxHookSource ( http://www.advancedfx.org )
I made some compromises already to make things not even more complicated, so I am down to trying to use a 3rd order motion profile (so not specifically for angular motion), assuming that the error will be a constant linear factor.
I already posted my question on math.stackexhange.com here:
http://math.stackexchange.com/questions/1750143/3rd-oder-motion-profile-programming-characterized-by-limits-for-jerk-accelerat [Broken]
But it looks as if won't get any feedback there and a friend recommended me to try this physics forum instead.
1. Problem
I am trying to program a 3rd order motion profile. It is driven by controlling the Jerk in a somewhat "sinusoidal" way. The acceleration and velocity are limited. There can be initial acceleration and velocity.
The closest graphical visualization I found is this (main difference is it starts with zero velocity and acceleration): https://en.wikipedia.org/wiki/Jerk_(physics)#/media/File:Schematic_diagram_of_Jerk,_Acceleration,_and_Speed.svg
It has these phases:
1.1. Input:
1.2. Output:
1.3. Further Equations:
The idea of those equations is that the model is controlled by driving the Jerk in a specific "sinusoidal" (?) way over a to be determined period of time (basically modelling the phases mentioned above).
1.3.1. Jerk
[tex]
\text{jerk}(1) = +\text{dir} \cdot \text{LimitJerk} \\
\text{jerk}(2) = 0 \\
\text{jerk}(3) = -\text{dir} \cdot \text{LimitJerk} \\
\text{jerk}(4) = 0 \\
\text{jerk}(5) = -\text{dir} \cdot \text{LimitJerk} \\
\text{jerk}(6) = 0 \\
\text{jerk}(7) = +\text{dir} \cdot \text{LimitJerk} \\
[/tex]
1.3.2. Acceleration
Derived by integrating the jerk.
[tex]
\text{accel}(0) = \text{lastAccel} \\
\text{accel}(1) = \text{accel}(0) +\text{jerk}(1) \cdot \text{phase1T} \\
\text{accel}(2) = \text{accel}(1) +\text{jerk}(2) \cdot \text{phase2T} \\
\text{accel}(3) = \text{accel}(2) +\text{jerk}(3) \cdot \text{phase3T} \\
\text{accel}(4) = \text{accel}(3) +\text{jerk}(4) \cdot \text{phase4T} \\
\text{accel}(5) = \text{accel}(4) +\text{jerk}(5) \cdot \text{phase5T} \\
\text{accel}(6) = \text{accel}(5) +\text{jerk}(6) \cdot \text{phase6T} \\
\text{accel}(7) = \text{accel}(6) +\text{jerk}(7) \cdot \text{phase7T} \\
\text{accel}(7) = 0
[/tex]
1.3.3. Acceleration limits
[tex]
-\text{LimitAccel} \leq \text{accel}(1) \leq \text{LimitAccel} \\
-\text{LimitAccel} \leq \text{accel}(2) \leq \text{LimitAccel} \\
-\text{LimitAccel} \leq \text{accel}(3) \leq \text{LimitAccel} \\
-\text{LimitAccel} \leq \text{accel}(4) \leq \text{LimitAccel} \\
-\text{LimitAccel} \leq \text{accel}(5) \leq \text{LimitAccel} \\
-\text{LimitAccel} \leq \text{accel}(6) \leq \text{LimitAccel} \\
-\text{LimitAccel} \leq \text{accel}(7) \leq \text{LimitAccel}
[/tex]
1.3.4. Velcoity
Derived by integrating the acceleration.
[tex]
\text{vel}(0) = \text{lastVel} \\
\text{vel}(1) = \text{vel}(0) +\text{accel}(0) \cdot \text{phase1T} +\text{jerk}(1)/2 \cdot \text{phase1T}^2 \\
\text{vel}(2) = \text{vel}(1) +\text{accel}(1) \cdot \text{phase2T} +\text{jerk}(2)/2 \cdot \text{phase2T}^2 \\
\text{vel}(3) = \text{vel}(2) +\text{accel}(2) \cdot \text{phase3T} +\text{jerk}(3)/2 \cdot \text{phase3T}^2 \\
\text{vel}(4) = \text{vel}(3) +\text{accel}(3) \cdot \text{phase4T} +\text{jerk}(4)/2 \cdot \text{phase4T}^2 \\
\text{vel}(5) = \text{vel}(4) +\text{accel}(4) \cdot \text{phase5T} +\text{jerk}(5)/2 \cdot \text{phase5T}^2 \\
\text{vel}(6) = \text{vel}(5) +\text{accel}(5) \cdot \text{phase6T} +\text{jerk}(6)/2 \cdot \text{phase6T}^2 \\
\text{vel}(7) = \text{vel}(6) +\text{accel}(6) \cdot \text{phase7T} +\text{jerk}(7)/2 \cdot \text{phase7T}^2 \\
\text{vel}(7) = 0
[/tex]
1.3.5. Velocity limits
[tex]
-\text{LimitVelocity } \leq \text{vel}(1) \leq \text{LimitVelocity } \\
-\text{LimitVelocity } \leq \text{vel}(2) \leq \text{LimitVelocity } \\
-\text{LimitVelocity } \leq \text{vel}(3) \leq \text{LimitVelocity } \\
-\text{LimitVelocity } \leq \text{vel}(4) \leq \text{LimitVelocity } \\
-\text{LimitVelocity } \leq \text{vel}(5) \leq \text{LimitVelocity } \\
-\text{LimitVelocity } \leq \text{vel}(6) \leq \text{LimitVelocity } \\
-\text{LimitVelocity } \leq \text{vel}(7) \leq \text{LimitVelocity }
[/tex]
1.3.6. Position
[tex]
\text{targetDeltaPos} = \text{targetPos} -\text{lastPos}
[/tex]
Derived by integrating the velocity:
[tex]
\text{resultDeltaPos} = 0
+\left( \text{vel}(0) \cdot \text{phase1T} +\text{accel}(0)/2 \cdot \text{phase1T}^2 +\text{jerk}(1)/6 * \text{phase1T}^3 \right)
+\left( \text{vel}(1) \cdot \text{phase2T} +\text{accel}(1)/2 \cdot \text{phase2T}^2 +\text{jerk}(2)/6 * \text{phase2T}^3 \right)
+\left( \text{vel}(2) \cdot \text{phase3T} +\text{accel}(2)/2 \cdot \text{phase3T}^2 +\text{jerk}(3)/6 * \text{phase3T}^3 \right)
+\left( \text{vel}(3) \cdot \text{phase4T} +\text{accel}(3)/2 \cdot \text{phase4T}^2 +\text{jerk}(4)/6 * \text{phase4T}^3 \right)
+\left( \text{vel}(4) \cdot \text{phase5T} +\text{accel}(4)/2 \cdot \text{phase5T}^2 +\text{jerk}(5)/6 * \text{phase5T}^3 \right)
+\left( \text{vel}(5) \cdot \text{phase6T} +\text{accel}(5)/2 \cdot \text{phase6T}^2 +\text{jerk}(6)/6 * \text{phase6T}^3 \right)
+\left( \text{vel}(6) \cdot \text{phase7T} +\text{accel}(6)/2 \cdot \text{phase7T}^2 +\text{jerk}(7)/6 * \text{phase7T}^3 \right)
[/tex]
1.4. Minimize:
2. Question(s)
Can this be solved without using non-linear programming?
If so, I'd welcome any hints on how to attempt to solve this problem or any literature (if possible freely accessible online) I should read for educating myself about it. I'd prefer practical / easy literature, because as you probably already figured I am not good at mathematics.
(I think non-linear mixed-integer programming can be avoided by trying to solve it for each possible value of [itex]\text{dir}[/itex], meaning solving two times and taking the "better" one of the feasible solutions (at least one should be feasible).)
I was actually hoping for solving it analytical with different cases or s.th. like that, but I can't even find a way to make it in a linear programming problem (maybe that is not possible).
Please hint me on typos or things I might have forgot, I will try to edit them in (if that is possible).
Other notes
If it helps anything, then I can try to write down everything by making the jerk a left-continuous step function and deriving acceleration, velocity and resultDeltaPos from that. However I am not sure if that would make things better, because the functions would still have many cases then.
I hope I posted in the right sub-forum, because this might be more of an artificial model than modelling some real motion.
I selected Intermediate level thread prefix, because I don't know if this is an advanced problem or not.
I actually want to program (better) smooth camera tracking of objects for a hobby project of mine: HLAE / AfxHookSource ( http://www.advancedfx.org )
I made some compromises already to make things not even more complicated, so I am down to trying to use a 3rd order motion profile (so not specifically for angular motion), assuming that the error will be a constant linear factor.
I already posted my question on math.stackexhange.com here:
http://math.stackexchange.com/questions/1750143/3rd-oder-motion-profile-programming-characterized-by-limits-for-jerk-accelerat [Broken]
But it looks as if won't get any feedback there and a friend recommended me to try this physics forum instead.
1. Problem
I am trying to program a 3rd order motion profile. It is driven by controlling the Jerk in a somewhat "sinusoidal" way. The acceleration and velocity are limited. There can be initial acceleration and velocity.
The closest graphical visualization I found is this (main difference is it starts with zero velocity and acceleration): https://en.wikipedia.org/wiki/Jerk_(physics)#/media/File:Schematic_diagram_of_Jerk,_Acceleration,_and_Speed.svg
It has these phases:
- acceleration (decelleration) build-up
- limit acceleration (decelleration)
- acceleration (decelleration) ramp-down
- limit speed
- deceleration (accelleration) build-up
- limit deceleration (accelleration)
- deceleration (accelleration) ramp-down
1.1. Input:
- [itex]\text{LimitVelocity} \in \mathbb{R}_{\gt 0}[/itex] - absolute velocity limit
- [itex]\text{LimitAcceleration} \in \mathbb{R}_{\gt 0}[/itex] - absolute acceleration limit
- [itex]\text{LimitJerk} \in \mathbb{R}_{\gt 0}[/itex] - absolute jerk limit
- [itex]\text{targetPos} \in \mathbb{R}[/itex] - target position
- [itex]\text{lastPos} \in \mathbb{R}[/itex] - last (initial) position
- [itex]\text{lastVel} \in \mathbb{R}[/itex] - last (initial) velocity, where [itex]\left| \text{lastVel} \right| \leq \text{LimitVelocity}[/itex]
- [itex]\text{lastAccel} \in \mathbb{R}[/itex] - last (initial) acceleration, where [itex]\left| \text{lastAccel} \right| \leq \text{LimitAcceleration}[/itex]
1.2. Output:
- [itex]\text{phase1T} \in \mathbb{R}_{\geq 0}[/itex] , [itex]\text{phase2T} \in \mathbb{R}_{\geq 0}[/itex] , [itex]\text{phase3T} \in \mathbb{R}_{\geq 0}[/itex] , [itex]\text{phase4T} \in \mathbb{R}_{\geq 0}[/itex] , [itex]\text{phase5T} \in \mathbb{R}_{\geq 0}[/itex] , [itex]\text{phase6T} \in \mathbb{R}_{\geq 0}[/itex] , [itex]\text{phase7T} \in \mathbb{R}_{\geq 0}[/itex] - Phase times
- [itex]\text{dir} \in \{-1, 1\}[/itex] - base/intital jerk direction
1.3. Further Equations:
The idea of those equations is that the model is controlled by driving the Jerk in a specific "sinusoidal" (?) way over a to be determined period of time (basically modelling the phases mentioned above).
1.3.1. Jerk
[tex]
\text{jerk}(1) = +\text{dir} \cdot \text{LimitJerk} \\
\text{jerk}(2) = 0 \\
\text{jerk}(3) = -\text{dir} \cdot \text{LimitJerk} \\
\text{jerk}(4) = 0 \\
\text{jerk}(5) = -\text{dir} \cdot \text{LimitJerk} \\
\text{jerk}(6) = 0 \\
\text{jerk}(7) = +\text{dir} \cdot \text{LimitJerk} \\
[/tex]
1.3.2. Acceleration
Derived by integrating the jerk.
[tex]
\text{accel}(0) = \text{lastAccel} \\
\text{accel}(1) = \text{accel}(0) +\text{jerk}(1) \cdot \text{phase1T} \\
\text{accel}(2) = \text{accel}(1) +\text{jerk}(2) \cdot \text{phase2T} \\
\text{accel}(3) = \text{accel}(2) +\text{jerk}(3) \cdot \text{phase3T} \\
\text{accel}(4) = \text{accel}(3) +\text{jerk}(4) \cdot \text{phase4T} \\
\text{accel}(5) = \text{accel}(4) +\text{jerk}(5) \cdot \text{phase5T} \\
\text{accel}(6) = \text{accel}(5) +\text{jerk}(6) \cdot \text{phase6T} \\
\text{accel}(7) = \text{accel}(6) +\text{jerk}(7) \cdot \text{phase7T} \\
\text{accel}(7) = 0
[/tex]
1.3.3. Acceleration limits
[tex]
-\text{LimitAccel} \leq \text{accel}(1) \leq \text{LimitAccel} \\
-\text{LimitAccel} \leq \text{accel}(2) \leq \text{LimitAccel} \\
-\text{LimitAccel} \leq \text{accel}(3) \leq \text{LimitAccel} \\
-\text{LimitAccel} \leq \text{accel}(4) \leq \text{LimitAccel} \\
-\text{LimitAccel} \leq \text{accel}(5) \leq \text{LimitAccel} \\
-\text{LimitAccel} \leq \text{accel}(6) \leq \text{LimitAccel} \\
-\text{LimitAccel} \leq \text{accel}(7) \leq \text{LimitAccel}
[/tex]
1.3.4. Velcoity
Derived by integrating the acceleration.
[tex]
\text{vel}(0) = \text{lastVel} \\
\text{vel}(1) = \text{vel}(0) +\text{accel}(0) \cdot \text{phase1T} +\text{jerk}(1)/2 \cdot \text{phase1T}^2 \\
\text{vel}(2) = \text{vel}(1) +\text{accel}(1) \cdot \text{phase2T} +\text{jerk}(2)/2 \cdot \text{phase2T}^2 \\
\text{vel}(3) = \text{vel}(2) +\text{accel}(2) \cdot \text{phase3T} +\text{jerk}(3)/2 \cdot \text{phase3T}^2 \\
\text{vel}(4) = \text{vel}(3) +\text{accel}(3) \cdot \text{phase4T} +\text{jerk}(4)/2 \cdot \text{phase4T}^2 \\
\text{vel}(5) = \text{vel}(4) +\text{accel}(4) \cdot \text{phase5T} +\text{jerk}(5)/2 \cdot \text{phase5T}^2 \\
\text{vel}(6) = \text{vel}(5) +\text{accel}(5) \cdot \text{phase6T} +\text{jerk}(6)/2 \cdot \text{phase6T}^2 \\
\text{vel}(7) = \text{vel}(6) +\text{accel}(6) \cdot \text{phase7T} +\text{jerk}(7)/2 \cdot \text{phase7T}^2 \\
\text{vel}(7) = 0
[/tex]
1.3.5. Velocity limits
[tex]
-\text{LimitVelocity } \leq \text{vel}(1) \leq \text{LimitVelocity } \\
-\text{LimitVelocity } \leq \text{vel}(2) \leq \text{LimitVelocity } \\
-\text{LimitVelocity } \leq \text{vel}(3) \leq \text{LimitVelocity } \\
-\text{LimitVelocity } \leq \text{vel}(4) \leq \text{LimitVelocity } \\
-\text{LimitVelocity } \leq \text{vel}(5) \leq \text{LimitVelocity } \\
-\text{LimitVelocity } \leq \text{vel}(6) \leq \text{LimitVelocity } \\
-\text{LimitVelocity } \leq \text{vel}(7) \leq \text{LimitVelocity }
[/tex]
1.3.6. Position
[tex]
\text{targetDeltaPos} = \text{targetPos} -\text{lastPos}
[/tex]
Derived by integrating the velocity:
[tex]
\text{resultDeltaPos} = 0
+\left( \text{vel}(0) \cdot \text{phase1T} +\text{accel}(0)/2 \cdot \text{phase1T}^2 +\text{jerk}(1)/6 * \text{phase1T}^3 \right)
+\left( \text{vel}(1) \cdot \text{phase2T} +\text{accel}(1)/2 \cdot \text{phase2T}^2 +\text{jerk}(2)/6 * \text{phase2T}^3 \right)
+\left( \text{vel}(2) \cdot \text{phase3T} +\text{accel}(2)/2 \cdot \text{phase3T}^2 +\text{jerk}(3)/6 * \text{phase3T}^3 \right)
+\left( \text{vel}(3) \cdot \text{phase4T} +\text{accel}(3)/2 \cdot \text{phase4T}^2 +\text{jerk}(4)/6 * \text{phase4T}^3 \right)
+\left( \text{vel}(4) \cdot \text{phase5T} +\text{accel}(4)/2 \cdot \text{phase5T}^2 +\text{jerk}(5)/6 * \text{phase5T}^3 \right)
+\left( \text{vel}(5) \cdot \text{phase6T} +\text{accel}(5)/2 \cdot \text{phase6T}^2 +\text{jerk}(6)/6 * \text{phase6T}^3 \right)
+\left( \text{vel}(6) \cdot \text{phase7T} +\text{accel}(6)/2 \cdot \text{phase7T}^2 +\text{jerk}(7)/6 * \text{phase7T}^3 \right)
[/tex]
1.4. Minimize:
- Position error: [itex]\left| \text{targetDeltaPos} -\text{resultDeltaPos} \right|[/itex]
- Position time: [itex]\text{phase1T} +\text{phase2T} +\text{phase3T} +\text{phase4T} +\text{phase5T} +\text{phase6T} +\text{phase7T}[/itex]
2. Question(s)
Can this be solved without using non-linear programming?
If so, I'd welcome any hints on how to attempt to solve this problem or any literature (if possible freely accessible online) I should read for educating myself about it. I'd prefer practical / easy literature, because as you probably already figured I am not good at mathematics.
(I think non-linear mixed-integer programming can be avoided by trying to solve it for each possible value of [itex]\text{dir}[/itex], meaning solving two times and taking the "better" one of the feasible solutions (at least one should be feasible).)
I was actually hoping for solving it analytical with different cases or s.th. like that, but I can't even find a way to make it in a linear programming problem (maybe that is not possible).
Please hint me on typos or things I might have forgot, I will try to edit them in (if that is possible).
Other notes
If it helps anything, then I can try to write down everything by making the jerk a left-continuous step function and deriving acceleration, velocity and resultDeltaPos from that. However I am not sure if that would make things better, because the functions would still have many cases then.
I hope I posted in the right sub-forum, because this might be more of an artificial model than modelling some real motion.
I selected Intermediate level thread prefix, because I don't know if this is an advanced problem or not.
Last edited by a moderator: