function startAnimation(hcarGUI,order,dir,rate)
%order is a cell array of vectors. Each vector is a list of arrows that need to be animated simultaneously
global tmr
period = 1/rate;
period = round(period*1000)/1000;
if(~isnumeric(tmr) && isvalid(tmr))
stop(tmr);
delete(tmr);
tmr = timer('TimerFcn',{'timerFcn',hcarGUI,order,dir},'StartFcn',{'timerStartFcn',hcarGUI,order,dir},'StopFcn',...
{'timerStopFcn',hcarGUI,order,dir},'Period',period,'ExecutionMode','fixedrate');
start(tmr);
else
tmr = timer('TimerFcn',{'timerFcn',hcarGUI,order,dir},'StartFcn',{'timerStartFcn',hcarGUI,order,dir},'StopFcn',...
{'timerStopFcn',hcarGUI,order,dir},'Period',period,'ExecutionMode','fixedrate');
start(tmr);
end