Project

General

Profile

Statistics
| Revision:

root / branches / 16299_s10 / matlab / motionModel.m @ 1812

History | View | Annotate | Download (1017 Bytes)

1 1712 bbland
function [x, y, theta, r, phi, state] = motionModel(v,omega,xold,yold,thetaold,dt,state)
2 1708 bneuman
3 1713 bneuman
[numRobots,z] = size(v);
4 1708 bneuman
5 1812 cbrownel
wheelMax = [4 * pi;4 * pi];
6
wheelMin = [-4 * pi;-4 * pi];
7 1795 cbrownel
8 1812 cbrownel
R = 3.5;
9
L = 12.75;
10
noise = 0.5;
11 1795 cbrownel
12
transform = [ R/2 R/2; -R/L R/L];
13
inverseTransform = inv(transform);
14
15 1812 cbrownel
%Transforms from v, omega into wheel speed, limits wheel speed and adds noise, then translates back.
16
for i=2:numRobots,
17 1795 cbrownel
18 1802 bneuman
    wheels = inverseTransform * [v(i); omega(i)];
19 1812 cbrownel
    wheels = min(wheels, wheelMax) + noise * randn;
20
	wheels = max(wheels, wheelMin) + noise * randn;
21 1797 bneuman
	q = transform * wheels;
22 1795 cbrownel
	v(i) = q(1);
23
	omega(i) = q(2);
24
25
end
26
27
28 1712 bbland
x = zeros(numRobots,1);
29
y = zeros(numRobots,1);
30
theta = zeros(numRobots,1);
31
r = zeros(numRobots,1);
32
phi = zeros(numRobots,1);
33
34
for i=1:numRobots,
35
36
    x(i) = xold(i) + cos(thetaold(i))*v(i)*dt;
37
    y(i) = yold(i) + sin(thetaold(i))*v(i)*dt;
38
    theta(i) = thetaold(i) + omega(i)*dt;
39
40
    r(i) = sqrt((x(i)-x(1))^2 + (y(i)-y(1))^2);
41 1713 bneuman
    phi(i) = theta(1) - atan2(y(i)-y(1), x(i)-x(1));
42 1712 bbland
43 1708 bneuman
end
44 1712 bbland
45
end