00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00036 #ifndef __MISCELLANEOUS_H_
00037 #define __MISCELLANEOUS_H_
00038
00039 #include <stdio.h>
00040 #include <stdlib.h>
00041 #include <ctype.h>
00042 #include <string.h>
00043 #include <math.h>
00044 #include <time.h>
00045
00046 #include <iostream>
00047 #include <vector>
00048
00049 #include <Eigen/Dense>
00050 #include <armadillo>
00051
00052 #include <types.h>
00053
00054
00055 #define PFLN {printf("Passing through File [%s] @ Line [%d].\n", __FILE__, __LINE__);}
00056
00064 template <typename Type>
00065 Type RetrievePrecisionFromDouble(Type original, Type precision)
00066 {
00067 int integer=(int)original;
00068 Type sub1=(1.0/precision)*(original-(Type)integer);
00069 return (Type)integer+precision*((Type)round(sub1));
00070 }
00071
00078 template <typename Type>
00079 Type DegToRad(Type deg)
00080 {
00081 #if ROS_VERSION_MINIMUM(1, 8, 0) //At least FUERTE , V. Santos, 27-Mai-2013
00082 return (deg * (Type)M_PI / (Type)180.0);
00083 #else
00084 return (deg * (Type)arma::datum::pi / (Type)180.0);
00085 #endif
00086 }
00087
00094 template <typename Type>
00095 Type RadToDeg(Type rad)
00096 {
00097 #if ROS_VERSION_MINIMUM(1, 8, 0) //At least FUERTE , V. Santos, 27-Mai-2013
00098 return (rad * (Type)180.0 / (Type)M_PI);
00099 #else
00100 return (rad * (Type)180.0 / (Type)arma::datum::pi);
00101 #endif
00102 }
00103
00115 void CalculateAverageCartesianSpeed(double diffX, double diffY, double diffZ, long double time_interval, double *return_vector);
00116
00124 double pc_mean(double *v, int len);
00125
00131 Eigen::Matrix3d rotx(double angle_in_degrees);
00132
00138 Eigen::Matrix3d roty(double angle_in_degrees);
00139
00145 Eigen::Matrix3d rotz(double angle_in_degrees);
00146
00154 template <class T>
00155 T pc_mean(std::vector<T> vect)
00156 {
00157 T sum = 0;
00158
00159 for(uint i = 0; i < vect.size(); i++)
00160 sum += vect[i];
00161
00162 return sum / vect.size();
00163 }
00164
00172 template <typename Type>
00173 bool IsWithinRange(Type value, Type lower_bound, Type upper_bound)
00174 {
00175 if(value >= lower_bound && value < upper_bound)
00176 {
00177 return TRUE;
00178 }
00179 else if(value > lower_bound && value <= upper_bound)
00180 {
00181 return TRUE;
00182 }
00183 else
00184 {
00185 return FALSE;
00186 }
00187 }
00188
00189 #ifdef _cplusplus
00190 extern "C" {
00191 #endif // _cplusplus
00192
00201 int isNumeric (const char * s);
00202
00210 double get_sign(double x);
00211
00212
00213
00214
00220 void print_help(void);
00221
00228 void print_greeting(shared_vars_t*RobotVars);
00229
00230
00237 int GetNbrFromKeyboard(void);
00238
00245 char GetStrFromKeyboard(void);
00246
00253 double GetDblFromKeyboard(void);
00254
00260 void ScreenClear(void);
00261
00262
00266 #define RESET 0
00267 #define BRIGHT 1
00268 #define DIM 2
00269 #define UNDERLINE 3
00270 #define BLINK 4
00271 #define REVERSE 7
00272 #define HIDDEN 8
00273
00277 #define BLACK 0
00278 #define RED 1
00279 #define GREEN 2
00280 #define YELLOW 3
00281 #define BLUE 4
00282 #define MAGENTA 5
00283 #define CYAN 6
00284 #define GRAY 7
00285 #define WHITE 8
00286
00287
00289
00297 void textcolor(int attr, int fg, int bg);
00298
00304 void PrintRedLine(void);
00305
00311 void ResetTextColors(void);
00312
00318 void HighLightText(void);
00319
00320 #ifdef _cplusplus
00321 }
00322 #endif // _cplusplus
00323
00324 #endif
00325