#include <Controller.h>
Inheritance diagram for Controller:
Public Member Functions | |
Controller () | |
virtual | ~Controller () |
std::string | getSimulationFileName () const |
unsigned int | getSimulationStep () const |
SimObject * | getObjectReference (const std::string &objectName) |
Surface * | getSurface (const std::string &name) const |
void | setBackgroundColor (const Vector3d &color) |
void | setAmbientColor (const Vector3d &color) |
int | getActuatorportId (std::string portName) const |
double | getActuatorportMinValue (int id) const |
double | getActuatorportMaxValue (int id) const |
void | setActuatorport (int id, double value) |
int | getSensorportId (std::string portName) const |
const std::vector< int > & | getSensorDimensions (int id) const |
void | getSensorValue (int id, bool &value) |
void | getSensorValue (int id, double &value) |
void | getSensorValue (int id, int &value) |
void | getSensorValue (int id, double *&value) |
void | getSensorValue (int id, unsigned char *&value) |
void | addView (View *view, const std::string &name) |
void | print (const std::string &text) |
void | printLn (const std::string &text) |
void | clear () |
virtual void | execute ()=0 |
virtual void | init () |
virtual void | destroy () |
virtual void | onKeyPressed (int key) |
virtual void | onSelected (SimObject *obj) |
virtual void | onConsoleCommand (const std::string &) |
virtual void | onConsoleCompletion (std::string &command, bool forward) |
Private Attributes | |
Simulation * | simulation |
Definition at line 24 of file Controller.h.
Controller::Controller | ( | ) |
Constructor.
Definition at line 10 of file Controller.cpp.
References CDoc::GetSimulation(), and simulation.
Controller::~Controller | ( | ) | [virtual] |
Destructor.
Definition at line 19 of file Controller.cpp.
void Controller::addView | ( | View * | view, | |
const std::string & | name | |||
) |
The function adds a view to the scene. The view can be found in the object tree in the group "views".
The | view. | |
name | The name of the view will have in the group "views". |
Definition at line 108 of file Controller.cpp.
References Simulation::addView(), and simulation.
Referenced by RobotConsole::addViews().
void Controller::clear | ( | ) |
The function clears the console window.
Definition at line 123 of file Controller.cpp.
Referenced by ConsoleRoboCupCtrl::onConsoleCommand().
virtual void Controller::destroy | ( | ) | [inline, virtual] |
The function is called before the controller is destructed.
Definition at line 204 of file Controller.h.
Referenced by CDoc::OnSimReset(), and CDoc::~CDoc().
virtual void Controller::execute | ( | ) | [pure virtual] |
The function is called before every simulation step. It must be implemented in a derived class.
Implemented in ConsoleRoboCupCtrl, and RoboCupCtrl.
Referenced by CDoc::OnIdle().
int Controller::getActuatorportId | ( | std::string | portName | ) | const |
The function returns the id of an actuatorport with a given name. An assertion will fail if the actuatorport does not exist.
portName | The name of the actuatorport. |
Definition at line 53 of file Controller.cpp.
References Simulation::getActuatorportId(), and simulation.
double Controller::getActuatorportMaxValue | ( | int | id | ) | const |
The function returns the maximum value to be set for a certain actuatorport.
id | The id of the port. |
Definition at line 63 of file Controller.cpp.
References Simulation::getActuatorportMaxValue(), and simulation.
double Controller::getActuatorportMinValue | ( | int | id | ) | const |
The function returns the minimum value to be set for a certain actuatorport.
id | The id of the port. |
Definition at line 58 of file Controller.cpp.
References Simulation::getActuatorportMinValue(), and simulation.
SimObject * Controller::getObjectReference | ( | const std::string & | objectName | ) |
The function returns a pointer to an object. An assertion will fail if the object does not exist.
objectName | The full name of the object. |
Definition at line 38 of file Controller.cpp.
References Simulation::getObjectReference(), and simulation.
Referenced by RoboCupCtrl::execute(), Oracle::getBallModel(), and Oracle::getPlayerPoseCollection().
const std::vector< int > & Controller::getSensorDimensions | ( | int | id | ) | const |
The function returns the dimensions of the values returned by a certain sensorport.
id | The id of the port. |
Definition at line 78 of file Controller.cpp.
References Simulation::getSensorDimensions(), and simulation.
int Controller::getSensorportId | ( | std::string | portName | ) | const |
The function returns the id of a sensorport with a given name. An assertion will fail if the sensorport does not exist.
portName | The name of the sensorport. |
Definition at line 73 of file Controller.cpp.
References Simulation::getSensorportId(), and simulation.
void Controller::getSensorValue | ( | int | id, | |
unsigned char *& | value | |||
) |
The function returns the current value of a certain sensorport. An assertion fails if the type of the sensorport is not cameraSensor.
id | The id of the port | |
value | The current value. |
Definition at line 103 of file Controller.cpp.
References Simulation::getSensorportValue(), and simulation.
void Controller::getSensorValue | ( | int | id, | |
double *& | value | |||
) |
The function returns the current value of a certain sensorport. An assertion fails if the type of the sensorport is not doubleFieldSensor.
id | The id of the port. | |
value | The current value. |
Definition at line 98 of file Controller.cpp.
References Simulation::getSensorportValue(), and simulation.
void Controller::getSensorValue | ( | int | id, | |
int & | value | |||
) |
The function returns the current value of a certain sensorport. An assertion fails if the type of the sensorport is not intSensor.
id | The id of the port. | |
value | The current value. |
Definition at line 93 of file Controller.cpp.
References Simulation::getSensorportValue(), and simulation.
void Controller::getSensorValue | ( | int | id, | |
double & | value | |||
) |
The function returns the current value of a certain sensorport. An assertion fails if the type of the sensorport is not doubleSensor.
id | The id of the port. | |
value | The current value. |
Definition at line 88 of file Controller.cpp.
References Simulation::getSensorportValue(), and simulation.
void Controller::getSensorValue | ( | int | id, | |
bool & | value | |||
) |
The function returns the current value of a certain sensorport. An assertion fails if the type of the sensorport is not booleanSensor.
id | The id of the port. | |
value | The current value as Boolean. |
Definition at line 83 of file Controller.cpp.
References Simulation::getSensorportValue(), and simulation.
Referenced by OVirtualRobotComm::getSwitch().
std::string Controller::getSimulationFileName | ( | ) | const |
The function returns the name of the simulation file.
Definition at line 23 of file Controller.cpp.
References Simulation::getSimulationFileName(), and simulation.
Referenced by ConsoleRoboCupCtrl::ConsoleRoboCupCtrl().
unsigned int Controller::getSimulationStep | ( | ) | const |
The function returns the current simulation step.
Definition at line 28 of file Controller.cpp.
References Simulation::getSimulationStep(), and simulation.
Surface * Controller::getSurface | ( | const std::string & | name | ) | const |
The function returns the surface with a given name. An assertion will fail if the surface does not exist.
name | The name of the surface searched for. |
Definition at line 33 of file Controller.cpp.
References Simulation::getSurface(), and simulation.
Referenced by RoboCupCtrl::colorizeScene(), and OVirtualRobotComm::setLedState().
virtual void Controller::init | ( | ) | [inline, virtual] |
The function is called before the first call to execute(). When this function is called the controller is already constructed.
Definition at line 199 of file Controller.h.
virtual void Controller::onConsoleCommand | ( | const std::string & | ) | [inline, virtual] |
The function is called when a console command has been entered.
command | The command. |
Reimplemented in ConsoleRoboCupCtrl.
Definition at line 222 of file Controller.h.
Referenced by CDoc::OnConsoleCommand().
virtual void Controller::onConsoleCompletion | ( | std::string & | command, | |
bool | forward | |||
) | [inline, virtual] |
The function is called when the tabulator key is pressed. It can replace the given command line by a new one.
command | The command. | |
forward | Complete in forward direction. |
Reimplemented in ConsoleRoboCupCtrl.
Definition at line 230 of file Controller.h.
Referenced by CDoc::OnConsoleCompletion().
virtual void Controller::onKeyPressed | ( | int | key | ) | [inline, virtual] |
The function is called when a key on the numerical keypad was pressed.
key | 0..9 for the keys 0..9 and 10 for the decimal point. |
Definition at line 210 of file Controller.h.
Referenced by CDoc::OnKey0(), CDoc::OnKey1(), CDoc::OnKey2(), CDoc::OnKey3(), CDoc::OnKey4(), CDoc::OnKey5(), CDoc::OnKey6(), CDoc::OnKey7(), CDoc::OnKey8(), CDoc::OnKey9(), and CDoc::OnKeyDec().
virtual void Controller::onSelected | ( | SimObject * | obj | ) | [inline, virtual] |
The function is called when a movable object has been selected.
obj | The object. |
Reimplemented in ConsoleRoboCupCtrl.
Definition at line 216 of file Controller.h.
Referenced by CDoc::OnSelected().
void Controller::print | ( | const std::string & | text | ) |
The function prints text into the console window.
text | The text to be printed . |
Reimplemented in ConsoleRoboCupCtrl.
Definition at line 113 of file Controller.cpp.
Referenced by ConsoleRoboCupCtrl::execute(), and printLn().
void Controller::printLn | ( | const std::string & | text | ) |
The function prints text followed by a line break into the console window.
text | The text to be printed. |
Reimplemented in ConsoleRoboCupCtrl.
Definition at line 118 of file Controller.cpp.
References print().
Referenced by ConsoleRoboCupCtrl::execute().
void Controller::setActuatorport | ( | int | id, | |
double | value | |||
) |
The function sets the value of an actuatorport.
id | The id of the port. | |
value | The new value. |
Definition at line 68 of file Controller.cpp.
References Simulation::setActuatorport(), and simulation.
void Controller::setAmbientColor | ( | const Vector3d & | color | ) |
The function sets the color of the ambient light. The color has to be a triple of (R,G,B) values in the range of [0..1].
color | The color |
Definition at line 48 of file Controller.cpp.
References Simulation::setAmbientColor(), and simulation.
void Controller::setBackgroundColor | ( | const Vector3d & | color | ) |
The function sets the color of the background of the scene. The color has to be a triple of (R,G,B) values in the range of [0..1].
color | The color |
Definition at line 43 of file Controller.cpp.
References Simulation::setBackgroundColor(), and simulation.
Referenced by RoboCupCtrl::colorizeScene().
Simulation* Controller::simulation [private] |
A pointer to the simulation.
Definition at line 233 of file Controller.h.
Referenced by addView(), Controller(), getActuatorportId(), getActuatorportMaxValue(), getActuatorportMinValue(), getObjectReference(), getSensorDimensions(), getSensorportId(), getSensorValue(), getSimulationFileName(), getSimulationStep(), getSurface(), setActuatorport(), setAmbientColor(), and setBackgroundColor().