|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Re: calculating position using follower wheels
Just for fun. Last edited by Ether : 07-10-2013 at 17:20. Reason: added plot with sensor error |
|
#2
|
||||
|
||||
|
Re: calculating position using follower wheels
Quote:
|
|
#3
|
||||
|
||||
|
Re: calculating position using follower wheels
Quote:
forward = 5*sin(t/2) ft/s5a) What are the XY coordinates 30 seconds later? 5b) What is the path length traveled during that 30 seconds? |
|
#4
|
|||
|
|||
|
Re: calculating position using follower wheels
Spoiler for solution:
MATLAB: Spoiler for code:
Last edited by flameout : 07-10-2013 at 19:04. Reason: Units and nicer MATLAB output |
|
#5
|
||||
|
||||
|
Re: calculating position using follower wheels
Impressive. Reps to you.
|
|
#6
|
||||
|
||||
|
Re: calculating position using follower wheels
Spoiler for 5a:
Spoiler for 5b:
|
|
#7
|
||||
|
||||
|
Re: calculating position using follower wheels
Nice work too. You guys rock.
|
|
#8
|
||||
|
||||
|
Re: calculating position using follower wheels
In one hour from the time of this post, I will post Question 6. |
|
#9
|
|||
|
|||
|
Re: calculating position using follower wheels
I've refactored my code to be much faster (using basic manual Euler integration instead of MATLAB's integral() function) and plotted the robot's position for problem 5. The plot is attached.
Here is the code. I would have done this in C++, but MATLAB lets me plot much more easily Spoiler for code:
Last edited by flameout : 07-10-2013 at 20:04. Reason: Inserting forgotten code tags |
|
#10
|
||||
|
||||
|
Re: calculating position using follower wheels
How slow was it before? Maxima solves Question 5 in less than half a second:
Code:
Maxima 5.27.0 http://maxima.sourceforge.net
using Lisp GNU Common Lisp (GCL) GCL 2.6.8
assume(t>0)$
Qo: 15/180*%pi$
dFdT: 5.0*sin(t/2.0)$
dSdT: 4.0*sin(t/2.2)$
dQdT: 1.5*sin(t/2.5)$
Q: Qo + integrate(dQdT,t,0,t)$
dXdT: dFdT*sin(Q)+dSdT*cos(Q)$
dYdT: dFdT*cos(Q)-dSdT*sin(Q)$
dLdT: sqrt(dXdT^2+dYdT^2)$
quad_qags(dXdT, t, 0, 30);
[- 5.94428316349145, 5.1523954241625701E-10, 315, 0]
quad_qags(dYdT, t, 0, 30);
[- 9.110270199929753, 3.4870273187953572E-10, 315, 0]
quad_qags(dLdT, t, 0, 30);
[129.5971872631463, 1.1496649242892635E-6, 441, 0]
Quote:
Also see Post 13 for a simple change to improve accuracy so you can use fewer steps and run even faster. Post 15 explains why. Quote:
|
|
#11
|
||||
|
||||
|
Re: calculating position using follower wheels
Quote:
Where it was painfully slow was plotting the position trajectory, where it needed to run the numerical integration inside a numerical integration over and over (plenty of redundant calculations). To get a high-quality plot would have taken over an hour of execution time. Quote:
Another good technique would be to use an ODE solver rather than pure integration -- if I were to do this, I'd probably use MATLAB's built in 4th/5th order adaptive Runge-Kutta solver (ode45). This would probably be plenty fast as well. Quote:
Quote:
Last edited by flameout : 07-10-2013 at 20:42. |
|
#12
|
||||
|
||||
|
Re: calculating position using follower wheels
Quote:
Quote:
|
|
#13
|
|||
|
|||
|
Re: calculating position using follower wheels
Quote:
Quote:
Here's code that solves it using one of MATLAB's adaptive ODE solvers (4/5th-order Runge-Kutta (I don't recall which formulation it is)): Spoiler for more code:
|
|
#14
|
||||
|
||||
|
Re: calculating position using follower wheels
Question 6: Same as Question 5, except: 15 seconds instead of 30 and rotate_CW = (e^T-1)^(1/17) radians/sec Last edited by Ether : 07-10-2013 at 21:22. |
|
#15
|
|||
|
|||
|
Re: calculating position using follower wheels
Question 6 solution:
Spoiler for solution:
Code (slightly modified from my last script): Spoiler for code:
Perhaps I should stop and give someone else a chance to answer first -- this is way too easy when all I need to do is change a script I already wrote. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|