Robot Simulator of the Robotics Group for Self-Organization of Control  0.8.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
controller_misc.cpp File Reference
#include "controller_misc.h"
#include <algorithm>
Include dependency graph for controller_misc.cpp:

Functions

double one_over (double x)
 calculates 1/x More...
 
double constant (double c, double)
 returns c (useful for Matrix::mapP to fill matrix with constant value) More...
 
double power (void *c, double x)
 returns x the power c (as a double) More...
 
double power3 (double x)
 power 3 for matrix::map More...
 
double random_minusone_to_one (double)
 creates random number from -1 to 1 More...
 
double random_minusone_to_one (void *r, double)
 creates random number from -1 to 1 More...
 
double clip (double r, double x)
 clipping function for mapP More...
 
double lowercutof (void *theta, double x)
 cutof function for mapP More...
 
double toBinaryWithProbability (void *r, double x)
 returns -1 if probability is to low, otherwise 1 for mapP More...
 
double toBinaryWithThreshold (double x, double threshold)
 returns -1 if below threshold, otherwise 1 for map2 More...
 
double plus_ (double b, double a)
 plus function for mapP More...
 
list< Dstore4x4AndDiagonal (const Matrix &m)
 stores at least left top 4x4 submatrix (row-wise) (if exists) and then the rest of the diagonal elements into a list More...
 
I store4x4AndDiagonal (const Matrix &m, D *buffer, I len)
 stores at least left top 4x4 submatrix (row-wise) (if exists) and then the rest of the diagonal elements More...
 
I get4x4AndDiagonalSize (const Matrix &m)
 returns the number of elements stored by store4x4AndDiagonal (should be min(getN(),4)*min(getM(),4)+ max(0,min(getM()-4,getN()-4))) More...
 
list< Inspectable::iparamkeystore4x4AndDiagonalFieldNames (const Matrix &m, const std::string &matrixName)
 writes the names of the fields stored by store4x4AndDiagonal into a list More...
 
I store4x4AndDiagonalFieldNames (const Matrix &m, const std::string &matrixName, char **keylist, I len)
 stores the names of the fields stored by store4x4AndDiagonal More...
 
list< Inspectable::iparamkeystoreMatrixFieldNames (const Matrix &m, const string &matrixName)
 
list< Inspectable::iparamkeystoreVectorFieldNames (const Matrix &m, const string &vectorName)
 
I storeMatrixFieldNames (const Matrix &m, const char *matrixName, char **keylist, I len)
 stores the names of all matrix fieldnames in the order produced by convertToBuffer (row-wise) More...
 
I storeVectorFieldNames (const Matrix &m, const char *vectorName, char **keylist, I len)
 stores the names of all vector (mx1 or 1xn matrix) fieldnames in the order produced by convertToBuffer (row-wise) More...
 
Matrix noiseMatrix (I m, I n, NoiseGenerator &ng, double strength, double unused)
 returns a Matrix with values generated by the given noise generator More...
 
RandGensplitRandGen (RandGen *randGen)
 geneterates deterministically a new random generator from the given one. More...
 
double matrixNorm1 (const matrix::Matrix &m)
 calculates to linear matrix norm (sum of absolute values divided by number of values (m*n) ) More...
 
double matrixNorm2 (const matrix::Matrix &m)
 calculates to square matrix norm (sum of square values divided by number of values (m*n) ) More...
 
matrix::Matrix matrixNormalized (const matrix::Matrix &m)
 Matrix/matrixNorm2 ) More...
 
double getKthLargestElement (Matrix &vec, I k)
 returns the k. More...
 
double getKthSmallestElement (Matrix &vec, I k)
 returns the k. More...
 
I argmin (const Matrix &v)
 considers the matrix as vector (mx1) and returns the index of the smallest element More...
 
I argmax (const Matrix &v)
 considers the matrix as vector (mx1) and returns the index of the largest element More...
 
double min (const matrix::Matrix &v)
 returns the smallest element More...
 
double min (double a, double b)
 minimum function for doubles without templates More...
 
double max (const matrix::Matrix &v)
 returns the largest element More...
 
double max (double a, double b)
 maximum function for doubles without templates More...
 
I sample (const matrix::Matrix &pdf)
 samples from the pdf (rowwise stored with sum = 1) More...
 
double adapt (double p, double actual, double nominal, double up_rate, double down_rate)
 parameter adaptation algorithm. More...
 
double adaptMinMax (double p, double actual, double _min, double _max, double up_rate, double down_rate)
 like adapt but that the adaption is just done if the actual value is outside the given interval (_min, _max) More...
 
list< Inspectable::iparamvalconvertArrayToList (double *array, int arraySize)
 Helper function for converting an array with double values to a list. More...
 
list< Inspectable::iparamkeygetArrayNames (int arraySize, const char *name)
 Helper function for getting the array names of an array Is used for the method getInternalParamNames() interface inspectable. More...
 

Function Documentation

double adapt ( double  p,
double  actual,
double  nominal,
double  up_rate,
double  down_rate 
)

parameter adaptation algorithm.

double adaptMinMax ( double  p,
double  actual,
double  _min,
double  _max,
double  up_rate,
double  down_rate 
)

like adapt but that the adaption is just done if the actual value is outside the given interval (_min, _max)

I argmax ( const Matrix v)

considers the matrix as vector (mx1) and returns the index of the largest element

I argmin ( const Matrix v)

considers the matrix as vector (mx1) and returns the index of the smallest element

double clip ( double  r,
double  x 
)

clipping function for mapP

clipping function to the interval [-r, r] (for use with mapP)

double constant ( double  c,
double   
)

returns c (useful for Matrix::mapP to fill matrix with constant value)

list<Inspectable::iparamval> convertArrayToList ( double *  array,
int  arraySize 
)

Helper function for converting an array with double values to a list.

Is used for the method getInternalParams() interface inspectable.

I get4x4AndDiagonalSize ( const Matrix m)

returns the number of elements stored by store4x4AndDiagonal (should be min(getN(),4)*min(getM(),4)+ max(0,min(getM()-4,getN()-4)))

list<Inspectable::iparamkey> getArrayNames ( int  arraySize,
const char *  name 
)

Helper function for getting the array names of an array Is used for the method getInternalParamNames() interface inspectable.

double getKthLargestElement ( matrix::Matrix matrix,
matrix::I  k 
)

returns the k.

largest element of the matrix Attention: it will detroy the given matrix! (sorting) Assumption: k>0 and k<=matrixsize

double getKthSmallestElement ( matrix::Matrix matrix,
matrix::I  k 
)

returns the k.

smallest element of the matrix Attention: it will detroy the given matrix! (sorting) Assumption: k>0 and k<=matrixsize

double lowercutof ( void *  theta,
double  x 
)

cutof function for mapP

double matrixNorm1 ( const matrix::Matrix m)

calculates to linear matrix norm (sum of absolute values divided by number of values (m*n) )

double matrixNorm2 ( const matrix::Matrix m)

calculates to square matrix norm (sum of square values divided by number of values (m*n) )

matrix::Matrix matrixNormalized ( const matrix::Matrix m)

Matrix/matrixNorm2 )

double max ( const matrix::Matrix v)

returns the largest element

double max ( double  a,
double  b 
)

maximum function for doubles without templates

double min ( const matrix::Matrix v)

returns the smallest element

Examples:
sphererobot3masses.cpp.
double min ( double  a,
double  b 
)

minimum function for doubles without templates

Matrix noiseMatrix ( I  m,
I  n,
NoiseGenerator ng,
double  strength,
double  unused 
)

returns a Matrix with values generated by the given noise generator

double one_over ( double  x)

calculates 1/x

double plus_ ( double  b,
double  a 
)

plus function for mapP

double power ( void *  c,
double  x 
)

returns x the power c (as a double)

double power3 ( double  x)

power 3 for matrix::map

double random_minusone_to_one ( double  )

creates random number from -1 to 1

double random_minusone_to_one ( void *  r,
double   
)

creates random number from -1 to 1

I sample ( const matrix::Matrix pdf)

samples from the pdf (rowwise stored with sum = 1)

RandGen* splitRandGen ( RandGen randGen)

geneterates deterministically a new random generator from the given one.

If null then rand() is used for the seed;

list<D> store4x4AndDiagonal ( const matrix::Matrix m)

stores at least left top 4x4 submatrix (row-wise) (if exists) and then the rest of the diagonal elements into a list

Returns
list of values
I store4x4AndDiagonal ( const matrix::Matrix m,
matrix::D buffer,
matrix::I  len 
)

stores at least left top 4x4 submatrix (row-wise) (if exists) and then the rest of the diagonal elements

Parameters
mmatrix to be stored
lenLength of the provided buffer (should be min(getN(),4)*min(getM(),4)+ max(0,min(getM()-4,getN()-4)))
Returns
number of actually written elements
list<Inspectable::iparamkey> store4x4AndDiagonalFieldNames ( const matrix::Matrix m,
const std::string &  matrixName 
)

writes the names of the fields stored by store4x4AndDiagonal into a list

Parameters
mmatrix to be stored
matrixNamename of the matrix (prefix for all fields)
Returns
list of keys
I store4x4AndDiagonalFieldNames ( const matrix::Matrix m,
const std::string &  matrixName,
char **  keylist,
matrix::I  len 
)

stores the names of the fields stored by store4x4AndDiagonal

Parameters
mmatrix to be stored
matrixNamename of the matrix (prefix for all fields)
keylistlist for field names
lenLength of the provided buffer (should be min(getN(),4)*min(getM(),4)+ max(0,min(getM()-4,getN()-4)))
Returns
number of actually written elements
list<Inspectable::iparamkey> storeMatrixFieldNames ( const Matrix m,
const string &  matrixName 
)
I storeMatrixFieldNames ( const matrix::Matrix m,
const char *  matrixName,
char **  keylist,
matrix::I  len 
)

stores the names of all matrix fieldnames in the order produced by convertToBuffer (row-wise)

Parameters
mmatrix to be stored
matrixNamename of the matrix (prefix for all fields)
keylistlist for field names
lenLength of the provided buffer (should be getN()*getM()
Returns
number of actually written elements
list<Inspectable::iparamkey> storeVectorFieldNames ( const Matrix m,
const string &  vectorName 
)
I storeVectorFieldNames ( const matrix::Matrix m,
const char *  vectorName,
char **  keylist,
matrix::I  len 
)

stores the names of all vector (mx1 or 1xn matrix) fieldnames in the order produced by convertToBuffer (row-wise)

Parameters
mvector to be stored
vectorNamename of the vector (prefix for all fields)
keylistlist for field names
lenLength of the provided buffer (should be getM())
Returns
number of actually written elements
double toBinaryWithProbability ( void *  r,
double  x 
)

returns -1 if probability is to low, otherwise 1 for mapP

double toBinaryWithThreshold ( double  x,
double  threshold 
)

returns -1 if below threshold, otherwise 1 for map2