HolonomicMotionModel.cc
Go to the documentation of this file.00001 #include "HolonomicMotionModel.h"
00002
00003 void computeHolonomicMotion(float xvel, float yvel, float avel, float time, float& xpos, float& ypos, float& apos) {
00004 float speed = std::sqrt(xvel*xvel + yvel*yvel);
00005 if (std::fabs(avel)*1e6 <= speed) {
00006
00007 float distmovx = time * xvel;
00008 float distmovy = time * yvel;
00009 float c=std::cos(apos);
00010 float s=std::sin(apos);
00011 xpos += distmovx*c - distmovy*s;
00012 ypos += distmovx*s + distmovy*c;
00013
00014
00015 } else {
00016 float radius = speed / avel;
00017 float anglturn = time * avel;
00018 float heading = apos + std::atan2(yvel,xvel);
00019 heading += anglturn/2;
00020 float distmov = 2 * radius * std::sin(anglturn/2);
00021
00022
00023 xpos += distmov*std::cos(heading);
00024 ypos += distmov*std::sin(heading);
00025 apos += anglturn;
00026 }
00027 }