ICRS Eurobot 2013

Dependencies:   mbed mbed-rtos Servo QEI

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers supportfuncs.h Source File

supportfuncs.h

00001 #ifndef SUPPORTFUNCS_H
00002 #define SUPPORTFUNCS_H
00003 
00004 #include <cmath>
00005 #include "globals.h"
00006 #include "tvmet/Matrix.h"
00007 
00008 //Constrains agles to +/- pi
00009 inline float constrainAngle(float x){
00010     x = fmod(x + PI, 2*PI);
00011     if (x < 0)
00012         x += 2*PI;
00013     return x - PI;
00014 }
00015 
00016 template <typename T>
00017 tvmet::Matrix <T, 2, 2> Rotmatrix(T theta) {
00018      tvmet::Matrix <T, 2, 2> outmatrix;
00019      outmatrix = cos(theta), -sin(theta),
00020                  sin(theta), cos(theta);
00021      return outmatrix;
00022 }
00023 
00024 #endif //SUPPORTFUNCS_H