Wiselib
wiselib.testing/external_interface/pc/roomba_angle.h
Go to the documentation of this file.
00001 // vim: set noexpandtab ts=4 sw=4:
00002 
00003 #ifndef ROOMBA_ANGLE_H
00004 #define ROOMBA_ANGLE_H
00005 
00006 namespace wiselib {
00007    
00008    template<typename Math_P>
00009    class RoombaAngle {
00010       public:
00011          typedef Math_P Math;
00012          
00013          static const double GAUGE = 1.0;
00014          
00015          RoombaAngle() : radians_(0) { };
00016          RoombaAngle(double radians) : radians_(radians) { };
00017          
00018          RoombaAngle& operator=(RoombaAngle& other) {
00019             radians_ = other.radians_;
00020             return *this;
00021          }
00022          
00023          RoombaAngle& operator=(double r) {
00024             radians_ = r;
00025             return *this;
00026          }
00027          
00028          RoombaAngle& operator+=(double r) {
00029             radians_ += r;
00030             return *this;
00031          }
00032          
00033          operator double() { return radians_; }
00034          
00035          int16_t roomba_units_() {
00036             // Roomba uses a system where 1 unit equals 3 degrees
00037             return Math::round(Math::radians_to_degrees(radians_ / GAUGE)) % 120;
00038          }
00039          
00040          void set_roomba_units_(int16_t r) {
00041             radians_ = Math::degrees_to_radians(r * GAUGE);
00042          }
00043       private:
00044          double radians_;
00045    };
00046    
00047 }
00048 
00049 #endif // ROOMBA_ANGLE_H
00050 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines