#include <feedbackwiring.h>
Inherits AbstractWiring.
Inheritance diagram for FeedbackWiring:
Public Types | |
Motor = 1 | |
Context = 2 | |
All = 3 | |
enum | Mode { Motor = 1, Context = 2, All = 3 } |
Public Member Functions | |
FeedbackWiring (NoiseGenerator *noise, Mode mode=Context, double feedbackratio=0.9) | |
constructor | |
virtual | ~FeedbackWiring () |
virtual bool | init (int robotsensornumber, int robotmotornumber, RandGen *randGen=0) |
Initializes the number of sensors and motors from robot (to be precise the internal parameters rsensornumber and rmotornumber!), calculates the number of sensors and motors on controller side. | |
virtual bool | wireSensors (const sensor *rsensors, int rsensornumber, sensor *csensors, int csensornumber, double noise) |
Realizes wiring from robot sensors to controller sensors. | |
virtual bool | wireMotors (motor *rmotors, int rmotornumber, const motor *cmotors, int cmotornumber) |
Realizes wiring from controller motor outputs to robot motors. | |
virtual std::list< iparamkey > | getInternalParamNames () const |
Returns the list of the names of all internal parameters. | |
virtual std::list< iparamval > | getInternalParams () const |
Returns a list of the values of all internal parameters (in the order given by getInternalParamNames()). | |
virtual matrix::Matrix | getFeedbackRatio () const |
return the feedback ratio vector | |
virtual void | setFeedbackRatio (const matrix::Matrix &) |
sets the feedback ratio vector. | |
Protected Attributes | |
Mode | mode |
double | defaultfeedbackratio |
matrix::Matrix | feedbackratio |
motor * | motors |
array that stored the values of the motors | |
int | vmotornumber |
sensor * | noisevals |
for storing the noise values | |
bool | initialised |
The feedback connections from output to input is parameterised with a feedback strength. It is possible to generate virtual motors for context sensors.
In order to change the feedback strength use the following code after initialisation of the agent/wiredcontroller
matrix::Matrix rs = wiring->getFeedbackRatio(); double c=ratio; rs.toMapP(&c,constant); wiring->setFeedbackRatio(rs);
enum Mode |
FeedbackWiring | ( | NoiseGenerator * | noise, | |
Mode | mode = Context , |
|||
double | feedbackratio = 0.9 | |||
) |
constructor
noise | NoiseGenerator that is used for adding noise to sensor values | |
mode | Motor|Context|All: Motor: motor outputs send feedback; Context: virtual motor outputs for each context sensor with feedback | |
feedbackratio | default ratio used to feed back the output to the input, meaning
|
~FeedbackWiring | ( | ) | [virtual] |
matrix::Matrix getFeedbackRatio | ( | ) | const [virtual] |
return the feedback ratio vector
Inspectable::iparamkeylist getInternalParamNames | ( | ) | const [virtual] |
Inspectable::iparamvallist getInternalParams | ( | ) | const [virtual] |
Returns a list of the values of all internal parameters (in the order given by getInternalParamNames()).
Reimplemented from AbstractWiring.
bool init | ( | int | robotsensornumber, | |
int | robotmotornumber, | |||
RandGen * | randGen = 0 | |||
) | [virtual] |
Initializes the number of sensors and motors from robot (to be precise the internal parameters rsensornumber and rmotornumber!), calculates the number of sensors and motors on controller side.
Must be overloaded to calculate and provide the appropriate numbers controllersensornumber (csensornumber), controllermotornumber (cmotornumber), robotsensornumber (rsensornumber) and robotmotornumber (rmotornumber),
randGen | pointer to random generator, if not given then a new one is created |
Implements AbstractWiring.
void setFeedbackRatio | ( | const matrix::Matrix & | ) | [virtual] |
sets the feedback ratio vector.
The size of the vector must be at least as large as feedbackratio
bool wireMotors | ( | motor * | rmotors, | |
int | rmotornumber, | |||
const motor * | cmotors, | |||
int | cmotornumber | |||
) | [virtual] |
Realizes wiring from controller motor outputs to robot motors.
Must be overloaded in order to implement the appropriate mapping.
rmotors | pointer to array of motorvalues for robot | |
rmotornumber | number of robot motors | |
cmotors | pointer to array of motorvalues from controller | |
cmotornumber | number of motorvalues from controller |
Implements AbstractWiring.
bool wireSensors | ( | const sensor * | rsensors, | |
int | rsensornumber, | |||
sensor * | csensors, | |||
int | csensornumber, | |||
double | noise | |||
) | [virtual] |
Realizes wiring from robot sensors to controller sensors.
Must be overloaded in order to implement the appropriate mapping.
rsensors | pointer to array of sensorvalues from robot | |
rsensornumber | number of sensors from robot | |
csensors | pointer to array of sensorvalues for controller | |
csensornumber | number of sensors to controller | |
noise | size of the noise added to the sensors |
Implements AbstractWiring.
double defaultfeedbackratio [protected] |
matrix::Matrix feedbackratio [protected] |
bool initialised [protected] |
int vmotornumber [protected] |