The Configurable interface enables inherited objects to expose certain variables to be set externally via a key-value pair. This may be used within the code but also enables the user to change something from the Console or the Configurator.
By default all robots, controllers and wirings are configurable. There you can simply add the following lines to your constructor or init function:
addParameterDef("gamma", &gamma, .0, .0, 1.0, "harmony factor"); addParameterDef("twostep", &twostep, false, "whether two-step rule is used");
Here gamma is a double with default value 0 and a range of 0 to 1. The twostep member variable is a boolean with default value false. The variables can be of type: int, bool, or double.
You can also add a child configurable with
Finally how does the simulation knows which objects are configurable and should be visible on the console? In the GlobalData structure is a list of configurables. In you main you typically add your agent to this list with
global.configs.push_back ( agent );
The agent has the controller the robot and the wiring as a child. You can also add your own objects to this list.
A typical case is to derive the ThisSim class from configurable and add it to this list as well (