-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmmodel.m
More file actions
20 lines (15 loc) · 707 Bytes
/
mmodel.m
File metadata and controls
20 lines (15 loc) · 707 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function [xspeed, yspeed, rotspd] = mmodel(omega1, omega2, heading)
% Model constants, keep consistent with those ones in invmodel.m!
R = 1;
la = 3;
lb = 0;
sps = 1; % Steps per second
vx = (R/(2*la))*(-lb*omega1 + lb*omega2);
vy = (R/(2*la))*(-la*omega1 - la*omega2);
% Convert degrees to radians
heading = pi*heading/180;
% vx and vy are in robot's coordinate system -> need conversion to 'global' coordinates
xspeed = (vx * cos(heading + pi) + vy * cos(heading + pi)) / sps;
yspeed = (vx * sin(heading + pi) + vy * sin(heading + pi)) / sps;
% rotspd has to be converted into degrees per second (used in update.m)
rotspd = ((R/(2*la))*(-omega1 + omega2)*180/pi) / sps;