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
use_java_controller Class Reference

class for robot control with sine and cosine More...

#include <use_java_controller.h>

Inheritance diagram for use_java_controller:
Collaboration diagram for use_java_controller:

Public Member Functions

 use_java_controller (const char *port_controller="4444", const char *port_internalParams=NULL, const char *name="defaultRobot")
 Konstruktor: Initialisiert die Serververbindungen zu Java. More...
 
virtual ~use_java_controller ()
 
virtual void init (int sensornumber, int motornumber, RandGen *randgen=0)
 initialisation of the controller with the given sensor/ motornumber Must be called before use. More...
 
virtual int getSensorNumber () const
 
virtual int getMotorNumber () const
 
virtual void step (const sensor *sensors, int sensornumber, motor *motors, int motornumber)
 performs one step (includes learning). More...
 
virtual void stepNoLearning (const sensor *, int number_sensors, motor *, int number_motors)
 performs one step without learning. More...
 
void sendToJava (const char *message, bool abbruch, const char *meldung="Fehler beim Senden der Daten zum Java-Controller\n")
 Methode verschickt message an Java-controller. More...
 
void closeJavaController ()
 Methode verschickt Protokolle nach Java. More...
 
virtual std::list< iparamkeygetInternalParamNames () const
 executed once when guilogger or neuronvis or file logger is started to get the names of the inspectable parameters (names should be sent from java-controller and returned) More...
 
virtual std::list< iparamvalgetInternalParams () const
 executed every step when guilogger or neuronvis or file logger is active to get the values of the inspectable parameters (values should be sent from java-controller and returned) More...
 
virtual paramval getParam (const paramkey &key) const
 executed when a parameter is asked from the console (value should be sent from java-controller and returned) More...
 
virtual bool setParam (const paramkey &key, paramval val)
 executed when a parameter is set on the console (new value should be sent to java-controller) More...
 
virtual paramlist getParamList () const
 executed once from simulation for asking the parameter names (parameter names should be sent from java-controller and returned) More...
 
virtual bool store (FILE *f) const
 stores the object to the given file stream (ASCII preferred). More...
 
virtual bool restore (FILE *f)
 loads the object from the given file stream (ASCII preferred). More...
 
- Public Member Functions inherited from AbstractController
 AbstractController (const std::string &name, const std::string &revision)
 contructor (hint: use $ID$ for revision) More...
 
virtual void motorBabblingStep (const sensor *, int number_sensors, const motor *, int number_motors)
 called in motor babbling phase. More...
 
virtual void sensorInfos (std::list< SensorMotorInfo > sensorInfos)
 the controller is notified about the information on sensor. More...
 
virtual void motorInfos (std::list< SensorMotorInfo > motorInfos)
 the controller is notified about the information on motors. More...
 
virtual int SIdx (const std::string &name)
 returns the index of the sensor with the given name (if not found then 0 and all sensor names are printed) More...
 
virtual int MIdx (const std::string &name)
 returns the index of the motor with the given name (if not found then 0 and all motor names are printed) More...
 
virtual SensorMotorInfo SInfo (int index)
 returns the Information for the sensor with given index More...
 
virtual SensorMotorInfo MInfo (int index)
 returns the Information for the motor with given index More...
 
- Public Member Functions inherited from Configurable
 Configurable ()
 
 Configurable (const std::string &name, const std::string &revision)
 intialise with name and revision (use "$ID$") More...
 
virtual ~Configurable ()
 
virtual void notifyOnChange (const paramkey &key)
 Is called when a parameter was changes via setParam(). More...
 
virtual void addParameter (const paramkey &key, paramval *val, paramval minBound, paramval maxBound, const paramdescr &descr=paramdescr())
 This is the new style for adding configurable parameters. More...
 
virtual void addParameter (const paramkey &key, paramval *val, const paramdescr &descr=paramdescr())
 See addParameter(const paramkey& key, paramval* val, paramval minBound, paramval maxBound, const paramdescr& descr) More...
 
virtual void addParameter (const paramkey &key, parambool *val, const paramdescr &descr=paramdescr())
 See addParameter(const paramkey& key, paramval* val) but for bool values. More...
 
virtual void addParameter (const paramkey &key, paramint *val, paramint minBound, paramint maxBound, const paramdescr &descr=paramdescr())
 See addParameter(const paramkey& key, paramval* val) but for int values. More...
 
virtual void addParameter (const paramkey &key, paramint *val, const paramdescr &descr=paramdescr())
 
virtual void addParameterDef (const paramkey &key, paramval *val, paramval def, paramval minBound, paramval maxBound, const paramdescr &descr=paramdescr())
 This function is only provided for convenience. More...
 
virtual void addParameterDef (const paramkey &key, paramval *val, paramval def, const paramdescr &descr=paramdescr())
 
virtual void addParameterDef (const paramkey &key, parambool *val, parambool def, const paramdescr &descr=paramdescr())
 See addParameterDef(const paramkey&, paramval*, paramval) More...
 
virtual void addParameterDef (const paramkey &key, paramint *val, paramint def, paramint minBound, paramint maxBound, const paramdescr &descr=paramdescr())
 See addParameterDef(const paramkey&, paramval*, paramval) More...
 
virtual void addParameterDef (const paramkey &key, paramint *val, paramint def, const paramdescr &descr=paramdescr())
 
virtual void setParamDescr (const paramkey &key, const paramdescr &descr, bool traverseChildren=true)
 sets a description for the given parameter More...
 
int getId () const
 return the id of the configurable objects, which is created by random on initialisation More...
 
virtual paramkey getName () const
 return the name of the object More...
 
virtual paramkey getRevision () const
 returns the revision of the object More...
 
virtual void setName (const paramkey &name, bool callSetNameOfInspectable=true)
 Sets the name of the configurable. More...
 
virtual void setRevision (const paramkey &revision)
 sets the revision Hint: { return "$ID$"; } More...
 
virtual paramval getParam (const paramkey &key, bool traverseChildren=true) const
 returns the value of the requested parameter or 0 (+ error message to stderr) if unknown. More...
 
virtual bool hasParam (const paramkey &key, bool traverseChildren=true) const
 Returns if the requested parameter is part of the configurable or their children. More...
 
virtual bool setParam (const paramkey &key, paramval val, bool traverseChildren=true)
 sets the value of the given parameter or does nothing if unknown. More...
 
virtual void setParamBounds (const paramkey &key, paramval minBound, paramval maxBound, bool traverseChildren=true)
 Sets the bounds (minBound and maxBound) of the given parameter. More...
 
virtual void setParamBounds (const paramkey &key, paramint minBound, paramint maxBound, bool traverseChildren=true)
 
virtual void setParamBounds (const paramkey &key, paramvalBounds bounds, bool traverseChildren=true)
 
virtual void setParamBounds (const paramkey &key, paramintBounds bounds, bool traverseChildren=true)
 
virtual std::list< paramkeygetAllParamNames (bool traverseChildren=true)
 returns all names that are configureable More...
 
virtual parammap getParamValMap () const
 
virtual paramintmap getParamIntMap () const
 
virtual paramboolmap getParamBoolMap () const
 
virtual paramdescr getParamDescr (const paramkey &key, bool traverseChildren=true) const
 returns the description for the given parameter More...
 
virtual paramvalBounds getParamvalBounds (const paramkey &key, bool traverseChildren=true) const
 
virtual paramintBounds getParamintBounds (const paramkey &key, bool traverseChildren=true) const
 
virtual bool hasParamDescr (const paramkey &key, bool traverseChildren=true) const
 
virtual bool hasParamvalBounds (const paramkey &key, bool traverseChildren=true) const
 
virtual bool hasParamintBounds (const paramkey &key, bool traverseChildren=true) const
 
virtual bool storeCfg (const char *filenamestem, const std::list< std::string > &comments=std::list< std::string >())
 stores the key values paires into the file : filenamestem.cfg including the comments given in the list More...
 
virtual bool restoreCfg (const char *filenamestem)
 restores the key values paires from the file : filenamestem.cfg More...
 
void print (FILE *f, const char *prefix, int columns=90, bool traverseChildren=true) const
 prints the keys, values and descriptions to the file. Each line is prefixed More...
 
bool parse (FILE *f, const char *prefix=0, bool traverseChildren=true)
 parses the configuration from the given file More...
 
virtual void addConfigurable (Configurable *conf)
 Adds a configurable as a child object. More...
 
virtual void removeConfigurable (Configurable *conf)
 Removes a configurable as a child object. More...
 
virtual const configurableListgetConfigurables () const
 Returns the list containing all configurable children. More...
 
virtual void configurableChanged ()
 Indicates that the configurable itself or the configurable children attached to this configurable have changed. More...
 
- Public Member Functions inherited from BackCaller
 BackCaller ()
 
virtual ~BackCaller ()
 
virtual void addCallbackable (Callbackable *callbackableInstance, CallbackableType type=BackCaller::DEFAULT_CALLBACKABLE_TYPE)
 Adds a Callbackable instance to this caller instance. More...
 
virtual void removeCallbackable (Callbackable *callbackableInstance, CallbackableType type=BackCaller::DEFAULT_CALLBACKABLE_TYPE)
 Removes a Callbackable instance from this caller instance. More...
 
virtual void removeAllCallbackables (CallbackableType type)
 Removes all Callbackable instances from this caller instance. More...
 
virtual void callBack (CallbackableType type=BackCaller::DEFAULT_CALLBACKABLE_TYPE)
 Calls all registered callbackable classes of the determined type. More...
 
virtual void callBackQMP (CallbackableType type=BackCaller::DEFAULT_CALLBACKABLE_TYPE)
 Calls all registered callbackable classes of the determined type. More...
 
- Public Member Functions inherited from Inspectable
 Inspectable (const iparamkey &name="")
 TYPEDEFS END. More...
 
virtual ~Inspectable ()
 
virtual iparamvalptrlist getInternalParamsPtr () const
 be careful: matrices will be ignored More...
 
virtual ilayerlist getStructuralLayers () const
 Specifies which parameter vector forms a structural layer (in terms of a neural network) The ordering is important. More...
 
virtual iconnectionlist getStructuralConnections () const
 Specifies which parameter matrix forms a connection between layers (in terms of a neural network) The orderning is not important. More...
 
virtual void addInspectableValue (const iparamkey &key, iparamval const *val, const std::string &descr=std::string())
 This is the new style for adding inspectable values. More...
 
virtual void addInspectableMatrix (const iparamkey &key, const matrix::Matrix *m, bool only4x4AndDiag=true, const std::string &descr=std::string())
 This is the new style for adding inspectable values. More...
 
virtual void addInspectableDescription (const iparamkey &key, const std::string &descr)
 adds a description for the given parameter using info-lines The line will start (appart from the #I) with a D for description followed by the key end then followed by the string. More...
 
virtual void addInfoLine (std::string infoLine)
 Adds an info line to this inspectable instance. More...
 
virtual void addInfoLines (std::list< std::string > infoLineList)
 Adds a bunch of infolines with addInfoLine to this inspectable instance. More...
 
virtual void removeInfoLines ()
 Removes all infolines from this inspectable instance. More...
 
virtual const infoLinesListgetInfoLines () const
 Returns all infolines added to this inspectable instance. More...
 
virtual void addInspectable (Inspectable *insp)
 Adds an inspectable as a child object. More...
 
virtual void removeInspectable (Inspectable *insp)
 Removes an inspectable as a child object. More...
 
virtual void setNameOfInspectable (const iparamkey &name)
 set the name of the inspectable More...
 
virtual const iparamkey getNameOfInspectable () const
 return the name of the inspectable, getName() would conflict with Configurable::getName() too often More...
 
virtual const inspectableListgetInspectables () const
 Returns the list containing all inspectable children. More...
 
- Public Member Functions inherited from Storeable
virtual ~Storeable ()
 
bool storeToFile (const char *filename) const
 Provided for convenience. More...
 
bool restoreFromFile (const char *filename)
 Provided for convenience. More...
 

Static Public Member Functions

static void addController ()
 

Static Public Attributes

static int anzahl_Java_controller =0
 
- Static Public Attributes inherited from Configurable
static const CallbackableType CALLBACK_CONFIGURABLE_CHANGED = 11
 
- Static Public Attributes inherited from BackCaller
static const CallbackableType DEFAULT_CALLBACKABLE_TYPE = 0
 This is the default Callbackable type. More...
 

Protected Attributes

int t
 
const char * name
 
int number_sensors
 
int number_motors
 
int number_controlled
 
bool serverOK
 
int server_controller
 
int server_internalParams
 
int client_controller
 
int client_internalParams
 
socklen_t client_controller_size
 
socklen_t client_internalParams_size
 
struct sockaddr_in server_controller_addr
 
struct sockaddr_in server_internalParams_addr
 
struct sockaddr_in client_controller_addr
 
struct sockaddr_in client_internalParams_addr
 
paramlist config_param_list
 
int anz_config_param
 
iparamkeylist internal_keylist
 
iparamvallist internal_vallist
 
iparamvallist internal_vallist_alt
 
int anz_internal_param
 
bool can_send
 
bool isFirst
 
bool isClosed
 
bool server_guilogger_isClosed
 
bool server_controller_isClosed
 
int anzahl_closed_Server
 
double * motor_values_alt
 
- Protected Attributes inherited from AbstractController
std::map< std::string, int > sensorIndexMap
 
std::map< std::string, int > motorIndexMap
 
std::map< int, SensorMotorInfosensorInfoMap
 
std::map< int, SensorMotorInfomotorInfoMap
 
- Protected Attributes inherited from Inspectable
iparamkey name
 
iparampairlist mapOfValues
 
imatrixpairlist mapOfMatrices
 
infoLinesList infoLineStringList
 

Additional Inherited Members

- Public Types inherited from AbstractController
typedef double sensor
 
typedef double motor
 
- Public Types inherited from Configurable
typedef std::string paramkey
 
typedef std::string paramdescr
 
typedef double paramval
 
typedef std::list< std::pair
< paramkey, paramval > > 
paramlist
 
typedef std::map< paramkey,
paramval * > 
parammap
 
typedef bool parambool
 
typedef std::list< std::pair
< paramkey, parambool > > 
paramboollist
 
typedef std::map< paramkey,
parambool * > 
paramboolmap
 
typedef int paramint
 
typedef std::list< std::pair
< paramkey, paramint > > 
paramintlist
 
typedef std::map< paramkey,
paramint * > 
paramintmap
 
typedef std::map< paramkey,
paramdescr
paramdescrmap
 
typedef std::pair< paramval,
paramval
paramvalBounds
 
typedef std::map< paramkey,
paramvalBounds
paramvalBoundsMap
 
typedef std::pair< paramint,
paramint
paramintBounds
 
typedef std::map< paramkey,
paramintBounds
paramintBoundsMap
 
typedef std::pair< paramkey,
paramval * > 
paramvalpair
 
typedef std::pair< paramkey,
parambool * > 
paramboolpair
 
typedef std::pair< paramkey,
paramint * > 
paramintpair
 
typedef std::vector
< Configurable * > 
configurableList
 
- Public Types inherited from BackCaller
typedef unsigned long CallbackableType
 
- Public Types inherited from Inspectable
typedef std::string iparamkey
 
typedef double iparamval
 
typedef std::pair< iparamkey,
iparamval const * > 
iparampair
 
typedef std::pair< iparamkey,
std::pair< const
matrix::Matrix *, bool > > 
imatrixpair
 
typedef std::list< iparamkeyiparamkeylist
 
typedef std::list< std::string > infoLinesList
 
typedef std::list< iparamvaliparamvallist
 
typedef std::list< iparamval
const * > 
iparamvalptrlist
 
typedef std::list< iparampairiparampairlist
 
typedef std::list< imatrixpairimatrixpairlist
 
typedef struct Inspectable::ILayer ILayer
 
typedef struct
Inspectable::IConnection 
IConnection
 
typedef std::list< ILayerilayerlist
 
typedef std::list< IConnectioniconnectionlist
 
typedef std::list< const
Inspectable * > 
inspectableList
 
- Protected Member Functions inherited from Configurable
void copyParameters (const Configurable &, bool traverseChildren=true)
 copies the internal params of the given configurable More...
 
void printdescr (FILE *f, const char *prefix, const paramkey &key, int columns, int indent) const
 

Detailed Description

class for robot control with sine and cosine

Constructor & Destructor Documentation

use_java_controller ( const char *  port_controller = "4444",
const char *  port_internalParams = NULL,
const char *  name = "defaultRobot" 
)

Konstruktor: Initialisiert die Serververbindungen zu Java.

Parameters
port_controllerPortnummer für die Kommunikation des Controllers
port_internalParamsPortnummer für die Kommunikation des Guiloggers
~use_java_controller ( )
virtual

Member Function Documentation

static void addController ( )
inlinestatic
void closeJavaController ( )

Methode verschickt Protokolle nach Java.

list< Inspectable::iparamkey > getInternalParamNames ( ) const
virtual

executed once when guilogger or neuronvis or file logger is started to get the names of the inspectable parameters (names should be sent from java-controller and returned)

Reimplemented from Inspectable.

list< Inspectable::iparamval > getInternalParams ( ) const
virtual

executed every step when guilogger or neuronvis or file logger is active to get the values of the inspectable parameters (values should be sent from java-controller and returned)

Reimplemented from Inspectable.

virtual int getMotorNumber ( ) const
inlinevirtual
Returns
Number of motors the controller was initialised with or 0 if not initialised

Implements AbstractController.

Configurable::paramval getParam ( const paramkey key) const
virtual

executed when a parameter is asked from the console (value should be sent from java-controller and returned)

Configurable::paramlist getParamList ( ) const
virtual

executed once from simulation for asking the parameter names (parameter names should be sent from java-controller and returned)

Reimplemented from Configurable.

virtual int getSensorNumber ( ) const
inlinevirtual
Returns
Number of sensors the controller was initialised with or 0 if not initialised

Implements AbstractController.

void init ( int  sensornumber,
int  motornumber,
RandGen randgen = 0 
)
virtual

initialisation of the controller with the given sensor/ motornumber Must be called before use.

Implements AbstractController.

virtual bool restore ( FILE *  f)
inlinevirtual

loads the object from the given file stream (ASCII preferred).

Implements Storeable.

void sendToJava ( const char *  message,
bool  abbruch,
const char *  meldung = "Fehler beim Senden der Daten zum Java-Controller\n" 
)

Methode verschickt message an Java-controller.

Methode verschickt Protokolle nach Java.

bool setParam ( const paramkey key,
paramval  val 
)
virtual

executed when a parameter is set on the console (new value should be sent to java-controller)

void step ( const sensor sensors,
int  sensornumber,
motor motors,
int  motornumber 
)
virtual

performs one step (includes learning).

Calculates motor commands from sensor inputs.

Parameters
sensorssensors inputs scaled to [-1,1]
sensornumberlength of the sensor array
motorsmotors outputs. MUST have enough space for motor values!
motornumberlength of the provided motor array

Calculates motor commands from sensor inputs.

Parameters
sensorsinputs scaled to [-1,1]
sensornumberlength of the sensor array
motorsoutputs. MUST have enough space for motor values!
motornumberlength of the provided motor array

Implements AbstractController.

void stepNoLearning ( const sensor sensors,
int  number_sensors,
motor motors,
int  number_motors 
)
virtual

performs one step without learning.

See Also
step

Implements AbstractController.

virtual bool store ( FILE *  f) const
inlinevirtual

stores the object to the given file stream (ASCII preferred).

Implements Storeable.

Member Data Documentation

int anz_config_param
protected
int anz_internal_param
protected
int anzahl_closed_Server
protected
int anzahl_Java_controller =0
static
bool can_send
protected
int client_controller
protected
struct sockaddr_in client_controller_addr
protected
socklen_t client_controller_size
protected
int client_internalParams
protected
struct sockaddr_in client_internalParams_addr
protected
socklen_t client_internalParams_size
protected
paramlist config_param_list
protected
iparamkeylist internal_keylist
protected
iparamvallist internal_vallist
protected
iparamvallist internal_vallist_alt
protected
bool isClosed
protected
bool isFirst
protected
double* motor_values_alt
protected
const char* name
protected
int number_controlled
protected
int number_motors
protected
int number_sensors
protected
int server_controller
protected
struct sockaddr_in server_controller_addr
protected
bool server_controller_isClosed
protected
bool server_guilogger_isClosed
protected
int server_internalParams
protected
struct sockaddr_in server_internalParams_addr
protected
bool serverOK
protected
int t
protected

The documentation for this class was generated from the following files: