Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

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     // straight line motion
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     //cout << "Dist Moved X: " << distmovx << endl;  // .f floating point
00014     //cout << "Dist Moved Y: " << distmovy << endl;  // .f floating point
00015   } else {
00016     float radius = speed / avel; // when walking while turning, circle created...radius of that circle
00017     float anglturn = time * avel; // amount turned
00018     float heading = apos + std::atan2(yvel,xvel); // direction of instantaneous motion
00019     heading += anglturn/2; // plus the offset that will occur due to curvature over time
00020     float distmov = 2 * radius * std::sin(anglturn/2); // displacement that will result along heading
00021     
00022     //cout << "radius: " << radius << " Angle Turned: " << anglturn << " Dist Moved: " << distmov << " Heading: " << heading << endl;
00023     xpos += distmov*std::cos(heading);
00024     ypos += distmov*std::sin(heading);
00025     apos += anglturn;
00026   }
00027 }

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:41 2016 by Doxygen 1.6.3