|
Hormodular 1.0
Locomotion gait discovery by using digital hormones on modular robots
|
00001 //------------------------------------------------------------------------------ 00002 //-- Orientation 00003 //------------------------------------------------------------------------------ 00004 //-- 00005 //-- 3D vector representing the orientation of a module 00006 //-- 00007 //------------------------------------------------------------------------------ 00008 //-- 00009 //-- This file belongs to the Hormodular project 00010 //-- (https://github.com/David-Estevez/hormodular.git) 00011 //-- 00012 //------------------------------------------------------------------------------ 00013 //-- Author: David Estevez-Fernandez 00014 //-- 00015 //-- Released under the GPL license (more info on LICENSE.txt file) 00016 //------------------------------------------------------------------------------ 00017 00024 #ifndef ORIENTATION_H 00025 #define ORIENTATION_H 00026 00027 #include <string> 00028 #include <sstream> 00029 #include <iostream> 00030 #include <cmath> 00031 00032 #include <eigen3/Eigen/Geometry> 00033 #include "Utils.hpp" 00034 00035 namespace hormodular { 00036 00042 class Orientation 00043 { 00044 public: 00045 Orientation(); 00046 Orientation(int roll, int pitch, int yaw); 00047 00055 Orientation(std::string serialized_orientation); 00056 00057 00058 00060 Orientation& operator+=(const Orientation& a); 00061 00063 friend Orientation operator+(Orientation& a, Orientation& b); 00064 00066 Orientation& operator-=(const Orientation& b); 00067 00069 friend Orientation operator-(Orientation& a, Orientation& b); 00070 00071 00072 00073 int getRoll() const; 00074 void setRoll(int value); 00075 int getPitch() const; 00076 void setPitch(int value); 00077 int getYaw() const; 00078 void setYaw(int value); 00079 00080 00081 00087 std::string str(); 00088 00097 static int getRelativeOrientation( int connector, Orientation localOrient, Orientation remoteOrient ); 00098 00099 00100 private: 00101 int roll; 00102 int pitch; 00103 int yaw; 00104 00106 int angle0to360(int angle); 00107 00109 static double deg2rad( double angle); 00110 00112 static double rad2deg(double angle); 00113 00115 static bool vector_equal( Eigen::Vector3d a, Eigen::Vector3d b); 00116 }; 00117 00119 Orientation operator+(Orientation& a, Orientation& b); 00120 00122 Orientation operator-(Orientation& a, Orientation& b); 00123 00124 } 00125 #endif //-- ORIENTATION_H
1.7.4