miscellaneous.h File Reference

miscellaneous.h file for this module. Contains prototypes, includes and defines. More...

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <vector>
#include <Eigen/Dense>
#include <armadillo>
#include <phua_haptic/types.h>
Include dependency graph for miscellaneous.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

#define PFLN   {printf("Passing through File [%s] @ Line [%d].\n", __FILE__, __LINE__);}
 
#define RESET   0
 
#define BRIGHT   1
 
#define DIM   2
 
#define UNDERLINE   3
 
#define BLINK   4
 
#define REVERSE   7
 
#define HIDDEN   8
 
#define BLACK   0
 
#define RED   1
 
#define GREEN   2
 
#define YELLOW   3
 
#define BLUE   4
 
#define MAGENTA   5
 
#define CYAN   6
 
#define GRAY   7
 
#define WHITE   8
 
template<typename Type >
Type RetrievePrecisionFromDouble (Type original, Type precision)
 Retrieve a value cropped with the required precision. More...
 
template<typename Type >
Type DegToRad (Type deg)
 Templated degree to radian conversion function. More...
 
template<typename Type >
Type RadToDeg (Type rad)
 Templated radian to degree conversion function. More...
 
void CalculateAverageCartesianSpeed (double diffX, double diffY, double diffZ, long double time_interval, double *return_vector)
 Function acumulate position differences and calculate average speed. More...
 
double pc_mean (double *v, int len)
 Function to calculate mean value of an array [Taken from http://rosettacode.org/]. More...
 
Eigen::Matrix3d rotx (double angle_in_degrees)
 Function to calculate rotation matrix over the X axis. More...
 
Eigen::Matrix3d roty (double angle_in_degrees)
 Function to calculate rotation matrix over the Y axis. More...
 
Eigen::Matrix3d rotz (double angle_in_degrees)
 Function to calculate rotation matrix over the Z axis. More...
 
template<class T >
pc_mean (std::vector< T > vect)
 Template function to calculate mean value of an array. More...
 
template<typename Type >
bool IsWithinRange (Type value, Type lower_bound, Type upper_bound)
 Template function to determine if a given value is within a give range. More...
 
int isNumeric (const char *s)
 Function to check if string is numeric. More...
 
double get_sign (double x)
 Function to determine sign of a given number. More...
 
void print_help (void)
 Prints to stdout the program help tips. More...
 
void print_greeting (shared_vars_t *RobotVars)
 Prints to stdout the program greeting. More...
 
int GetNbrFromKeyboard (void)
 Gets a number from keyboard input. More...
 
char GetStrFromKeyboard (void)
 Gets a character from keyboard input. More...
 
double GetDblFromKeyboard (void)
 Gets a double number from keyboard input. More...
 
void ScreenClear (void)
 Sends equivalent shell command "clean" to stdout. More...
 
void textcolor (int attr, int fg, int bg)
 FUNCTIONS CREATED BY VITOR SANTOS(vitor.nosp@m.@ua..nosp@m.pt) | ALL CREDITS GO TO HIM... :-) More...
 
void PrintRedLine (void)
 Printf of an horizontal separator red line. More...
 
void ResetTextColors (void)
 Reset color text. More...
 
void HighLightText (void)
 Make somesort of highlight text. More...
 

Detailed Description

miscellaneous.h file for this module. Contains prototypes, includes and defines.

This modules contains several functions used overall.

Author
pedro_cruz
Version
2.0
Date
3 May 2012

Definition in file miscellaneous.h.

Macro Definition Documentation

#define BLACK   0

@ Colors

Definition at line 277 of file miscellaneous.h.

#define BLINK   4

Definition at line 270 of file miscellaneous.h.

#define BLUE   4

Definition at line 281 of file miscellaneous.h.

#define BRIGHT   1

Definition at line 267 of file miscellaneous.h.

#define CYAN   6

Definition at line 283 of file miscellaneous.h.

#define DIM   2

Definition at line 268 of file miscellaneous.h.

#define GRAY   7

Definition at line 284 of file miscellaneous.h.

#define GREEN   2

Definition at line 279 of file miscellaneous.h.

#define HIDDEN   8

Definition at line 272 of file miscellaneous.h.

#define MAGENTA   5

Definition at line 282 of file miscellaneous.h.

#define PFLN   {printf("Passing through File [%s] @ Line [%d].\n", __FILE__, __LINE__);}

Definition at line 55 of file miscellaneous.h.

#define RED   1

Definition at line 278 of file miscellaneous.h.

#define RESET   0

@ Attributes

Definition at line 266 of file miscellaneous.h.

#define REVERSE   7

Definition at line 271 of file miscellaneous.h.

#define UNDERLINE   3

Definition at line 269 of file miscellaneous.h.

#define WHITE   8

Definition at line 285 of file miscellaneous.h.

#define YELLOW   3

Definition at line 280 of file miscellaneous.h.

Function Documentation

void CalculateAverageCartesianSpeed ( double  diffX,
double  diffY,
double  diffZ,
long double  time_interval,
double *  return_vector 
)

Function acumulate position differences and calculate average speed.

This function stores position diffencial values and calculates mean value over time.

Parameters
[in]diffXxx axis position differences.
[in]diffYyy axis position differences.
[in]diffZzz axis position differences.
[in]time_intervaltime intervals of each given space differences.
[out]return_vectordestination return array.
Returns
none.

Definition at line 121 of file miscellaneous.cpp.

template<typename Type >
Type DegToRad ( Type  deg)

Templated degree to radian conversion function.

Parameters
[in]degangle in degrees.
Returns
angle in radians.

Definition at line 79 of file miscellaneous.h.

double get_sign ( double  x)

Function to determine sign of a given number.

This function determines the sign of a number and return -1 or 1, for negative or positive respectively.

Parameters
[in]xnumber to evaluate.
Returns
-1 for negative, 1 for positive.

Definition at line 254 of file miscellaneous.cpp.

double GetDblFromKeyboard ( void  )

Gets a double number from keyboard input.

This function retrieves a double number from a keyboard input.

Returns
returns a double number from input.

Definition at line 275 of file miscellaneous.cpp.

int GetNbrFromKeyboard ( void  )

Gets a number from keyboard input.

This function retrieves a number from a keyboard input.

Returns
returns an integer from input.

Definition at line 259 of file miscellaneous.cpp.

char GetStrFromKeyboard ( void  )

Gets a character from keyboard input.

This function retrieves a character from a keyboard input.

Returns
returns a character from input.

Definition at line 267 of file miscellaneous.cpp.

void HighLightText ( void  )

Make somesort of highlight text.

Returns
Nothing

Definition at line 308 of file miscellaneous.cpp.

int isNumeric ( const char *  s)

Function to check if string is numeric.

Returns true (non-zero) if character-string parameter represents a signed or unsigned floating-point number. Otherwise returns false (zero). [Taken from http://rosettacode.org/] | my edit: strtod() warning supression

Parameters
[in]sa const char array to evaluate.
Returns
true (non-zero) / otherwise returns false (zero).

Definition at line 244 of file miscellaneous.cpp.

template<typename Type >
bool IsWithinRange ( Type  value,
Type  lower_bound,
Type  upper_bound 
)

Template function to determine if a given value is within a give range.

Parameters
[in]valuethe value to evaluate.
[in]lower_boundthe lower bound of the range.
[in]upper_boundthe upper bound of the range.
Returns
TRUE if value is within range,FALSE if not.

Definition at line 173 of file miscellaneous.h.

double pc_mean ( double *  v,
int  len 
)

Function to calculate mean value of an array [Taken from http://rosettacode.org/].

Parameters
[in]vpointer to the array to calculate.
[in]lenlenght of array elements to use in the calculation.
Returns
mean value calculated.

Definition at line 235 of file miscellaneous.cpp.

template<class T >
T pc_mean ( std::vector< T >  vect)

Template function to calculate mean value of an array.

This function calculates the mean value of an a given vector, that can be of any type.

Parameters
[in]vectvector to calculated mean.
Returns
mean value calculated.

Definition at line 155 of file miscellaneous.h.

void print_greeting ( shared_vars_t RobotVars)

Prints to stdout the program greeting.

This function prints to stdout a greeting message.

Parameters
[in]RobotVarsstructure defined in types.h with the joint values.

Definition at line 91 of file miscellaneous.cpp.

void print_help ( void  )

Prints to stdout the program help tips.

This function prints to stdout a set of program help tips.

Definition at line 37 of file miscellaneous.cpp.

void PrintRedLine ( void  )

Printf of an horizontal separator red line.

Returns
Nothing

Definition at line 294 of file miscellaneous.cpp.

template<typename Type >
Type RadToDeg ( Type  rad)

Templated radian to degree conversion function.

Parameters
[in]radangle in radians.
Returns
angle in degree.

Definition at line 95 of file miscellaneous.h.

void ResetTextColors ( void  )

Reset color text.

Returns
Nothing

Definition at line 303 of file miscellaneous.cpp.

template<typename Type >
Type RetrievePrecisionFromDouble ( Type  original,
Type  precision 
)

Retrieve a value cropped with the required precision.

Parameters
[in]originalthe original value to be cropped.
[in]precisionthe precision required.
Returns
the cropped value.

Definition at line 65 of file miscellaneous.h.

Eigen::Matrix3d rotx ( double  angle_in_degrees)

Function to calculate rotation matrix over the X axis.

Parameters
[in]angle_in_degreesangle for rotation.
Returns
rotation matrix.

Definition at line 157 of file miscellaneous.cpp.

Eigen::Matrix3d roty ( double  angle_in_degrees)

Function to calculate rotation matrix over the Y axis.

Parameters
[in]angle_in_degreesangle for rotation.
Returns
rotation matrix.

Definition at line 183 of file miscellaneous.cpp.

Eigen::Matrix3d rotz ( double  angle_in_degrees)

Function to calculate rotation matrix over the Z axis.

Parameters
[in]angle_in_degreesangle for rotation.
Returns
rotation matrix.

Definition at line 209 of file miscellaneous.cpp.

void ScreenClear ( void  )

Sends equivalent shell command "clean" to stdout.

Returns
none.

Definition at line 283 of file miscellaneous.cpp.

void textcolor ( int  attr,
int  fg,
int  bg 
)

FUNCTIONS CREATED BY VITOR SANTOS(vitor.nosp@m.@ua..nosp@m.pt) | ALL CREDITS GO TO HIM... :-)

Set the color of text that follows

Parameters
[in]attrType of attribute (RESET, BRIGHT, BLINK, etc...
[in]fgColor of foreground
[in]bgColor of background
Returns
Nothing

Definition at line 289 of file miscellaneous.cpp.



phua_haptic
Author(s): Pedro Cruz
autogenerated on Mon Mar 2 2015 01:32:36