Project

General

Profile

Statistics
| Revision:

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

History | View | Annotate | Download (882 Bytes)

1
function [x, y, theta,  phi, state, wheels] = motionModel(v,omega,xold,yold,thetaold,dt,state, n)
2

    
3
[numRobots,z] = size(v);
4

    
5
wheelMax = [4 * pi;4 * pi];
6
wheelMin = [-4 * pi;-4 * pi];
7

    
8
R = 3.5;
9
L = 12.75;
10
noise = 0.5;
11

    
12
transform = [ R/2 R/2; -R/L R/L];
13
inverseTransform = inv(transform);
14

    
15
%Transforms from v, omega into wheel speed, limits wheel speed and adds noise, then translates back.
16
for i=2:numRobots,
17
	
18
    wheels = inverseTransform * [v(i); omega(i)] + noise * randn(2, n);
19
    wheels = min(wheels, wheelMax); 
20
	wheels = max(wheels, wheelMin);
21
	q = transform * wheels;
22
	v(i) = q(1);
23
	omega(i) = q(2);
24
	
25
end 
26

    
27

    
28
x = zeros(numRobots,1);
29
y = zeros(numRobots,1);
30
theta = zeros(numRobots,1);
31
phi = zeros(numRobots,1);
32

    
33

    
34

    
35
    x = xold + cos(thetaold)*v*dt;
36
    y = yold(i) + sin(thetaold)*v*dt;
37
    theta = thetaold + omega*dt;
38
    
39
    phi = theta - atan2(y(-y(1), x-x(1));
40

    
41

    
42

    
43
end