|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Re: numerical solution of differential equations
Unless I was careless with the algebra (it happens when I'm tired), Steve's catapult can be modeled with an ODE of the form θ'' = k1 + k2∙cos(θ) + k3∙θ' Attached is an Octave script that uses Octave's built-in ODE solver "lsode" to numerically integrate arbitrary ODEs of the form x'' = f(t,x,x') |
|
#2
|
||||
|
||||
|
Re: numerical solution of differential equations
Hillbilly solution:
one forward Euler integration, one backward Euler integration, less typing and good enough for government work. Surprising how often that works... Cheers, Steve. P.S. The equation (for the catapult) should be something like θ" = K1∙(K2 - θ'), θ is just along for the ride. Last edited by sspoldi : 12-23-2016 at 12:01 PM. |
|
#3
|
|||||
|
|||||
|
Re: numerical solution of differential equations
Quote:
Code:
x'[n+1] = x'[n] + dt*x''[n] //backward looking x[n+1] = x[n] + dt*x'[n+1] //forward looking x''[n+1] = -x[n+1] The cosθ term is gravity acting on the boulder (and lever arm). Last edited by GeeTwo : 12-23-2016 at 12:20 PM. |
|
#4
|
||||
|
||||
|
Re: numerical solution of differential equations
Yea, I'd like to say we just ignore stuff like that, but sometimes it's a real factor. In 2014 we had a hammer with a 3 pound head on a 1 foot arm, gravity definitely made a difference.
Since we typically don't have a lot of time (who does), I like to get the kids to do a simple model up front, and then we do some system id and fit the actual robot behavior to a model. This way we can tune control systems quickly, and it gives them a chance to do some data based optimization in addition to a little physics up front. Cheers, Steve. |
|
#5
|
||||
|
||||
|
Re: numerical solution of differential equations
Vn+1 = Vn + An∙dt;
Xn+1 = Xn + Vn+1∙dt; Maybe provides some insight: the above is algebraically equivalent to Vn+1 = Vn + An∙dt; Xn+1 = Xn + dt∙(Vn+Vn+1)/2 + ½∙An∙dt2 |
|
#6
|
|||||
|
|||||
|
Re: numerical solution of differential equations
..so counting the constant acceleration term twice in the position calculation mostly offsets not counting the jerk in the velocity calculation..at least in this case.
|
|
#7
|
||||
|
||||
|
Re: numerical solution of differential equations
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|