#include <ConsoleRoboCupCtrl.h>
Inheritance diagram for ConsoleRoboCupCtrl:
Public Member Functions | |
ConsoleRoboCupCtrl () | |
~ConsoleRoboCupCtrl () | |
void | execute () |
void | onSelected (SimObject *obj) |
void | onConsoleCommand (const std::string &command) |
virtual void | onConsoleCompletion (std::string &command, bool forward) |
void | print (const std::string &text) |
void | printLn (const std::string &text) |
void | setXabsl2Info (int index, const Xabsl2Info &xabsl2Info) |
void | updateCommandCompletion () |
Static Public Member Functions | |
static const std::string & | getLogFile () |
Protected Member Functions | |
virtual void | onLineReceived (const char *line) |
Private Member Functions | |
bool | selectRobot (const char *name) |
void | executeFile (std::string name, bool printError=true) |
void | echo (InConfigMemory &stream) |
void | joystickButtonCommand (InConfigMemory &stream) |
void | joystickHeadControl (InConfigMemory &stream) |
void | help () |
bool | startConnection (InConfigMemory &stream) |
bool | startLogFile (InConfigMemory &stream) |
void | createCompletion () |
void | handleJoystick () |
std::string | calcButtonCommand (unsigned buttons) const |
std::string | calcWalk (unsigned x, unsigned y, unsigned r) const |
std::string | calcHead (unsigned acc, unsigned coolie) |
double | convert (unsigned value, double threshold) const |
Private Attributes | |
DECLARE_SYNC | |
List< List< Robot >::Pos > | simulated |
List< List< PhysicalRobot >::Pos > | physical |
List< PhysicalRobot > | physicalRobots |
List< std::string > | textMessages |
bool | newLine |
int | nesting |
std::string | buttonCommand [32] |
std::string | lastCommand [3] |
unsigned | lastTime |
int | tilt |
int | pan |
int | roll |
int | tiltId |
int | panId |
int | rollId |
std::map< std::string, int > | completion |
const Xabsl2Info * | xabsl2Infos [2] |
Static Private Attributes | |
static std::string | logFile |
Definition at line 19 of file ConsoleRoboCupCtrl.h.
ConsoleRoboCupCtrl::ConsoleRoboCupCtrl | ( | ) |
Constructor.
Definition at line 18 of file ConsoleRoboCupCtrl.cpp.
References createCompletion(), executeFile(), List< T >::getFirst(), Controller::getSimulationFileName(), List< T >::insert(), lastTime, nesting, newLine, pan, panId, RoboCupCtrl::robots, roll, rollId, simulated, tilt, tiltId, and xabsl2Infos.
ConsoleRoboCupCtrl::~ConsoleRoboCupCtrl | ( | ) |
Destructor.
Definition at line 40 of file ConsoleRoboCupCtrl.cpp.
References List< T >::getFirst(), and physicalRobots.
std::string ConsoleRoboCupCtrl::calcButtonCommand | ( | unsigned | buttons | ) | const [private] |
Definition at line 464 of file ConsoleRoboCupCtrl.cpp.
References buttonCommand.
Referenced by handleJoystick().
std::string ConsoleRoboCupCtrl::calcHead | ( | unsigned | acc, | |
unsigned | coolie | |||
) | [private] |
std::string ConsoleRoboCupCtrl::calcWalk | ( | unsigned | x, | |
unsigned | y, | |||
unsigned | r | |||
) | const [private] |
Definition at line 472 of file ConsoleRoboCupCtrl.cpp.
References convert(), int(), and toDegrees().
Referenced by handleJoystick().
double ConsoleRoboCupCtrl::convert | ( | unsigned | value, | |
double | threshold | |||
) | const [private] |
void ConsoleRoboCupCtrl::createCompletion | ( | ) | [private] |
The function creates the map for command completion.
Definition at line 541 of file ConsoleRoboCupCtrl.cpp.
References completion, DebugKeyTable::getDebugKeyName(), List< T >::getFirst(), GenericDebugData::getGenericDebugDateName(), HeadControlMode::getHeadControlModeName(), SolutionRequest::getModuleName(), SolutionRequest::getModuleSolutionName(), SolutionRequest::getNumOfSolutions(), SpecialActionRequest::getSpecialActionIDName(), TailRequest::getTailRequestIDName(), WalkRequest::getWalkTypeName(), SolutionRequest::getXabsl2EngineFileID(), DebugKeyTable::numOfDebugKeys, GenericDebugData::numOfGenericDebugDataIDs, HeadControlMode::numOfHeadControlModes, SolutionRequest::numOfModules, SpecialActionRequest::numOfSpecialAction, TailRequest::numOfTailRequests, WalkRequest::numOfWalkType, SolutionRequest::numOfXabslBehaviors, physicalRobots, RoboCupCtrl::robots, SolutionRequest::undefined, and xabsl2Infos.
Referenced by ConsoleRoboCupCtrl(), and onConsoleCommand().
void ConsoleRoboCupCtrl::echo | ( | InConfigMemory & | stream | ) | [private] |
The function read text from the stream and prints it to the console.
stream | The text stream. |
Definition at line 282 of file ConsoleRoboCupCtrl.cpp.
References InStream< S, R >::eof(), print(), printLn(), and text.
Referenced by onConsoleCommand().
void ConsoleRoboCupCtrl::execute | ( | ) | [virtual] |
The function is called in each simulation step.
Reimplemented from RoboCupCtrl.
Definition at line 46 of file ConsoleRoboCupCtrl.cpp.
References List< T >::clear(), RoboCupCtrl::execute(), List< T >::getFirst(), List< T >::getLast(), handleJoystick(), newLine, Controller::print(), Controller::printLn(), SYNC, and textMessages.
void ConsoleRoboCupCtrl::executeFile | ( | std::string | name, | |
bool | printError = true | |||
) | [private] |
The function executes the specified file.
name | The file to execute. |
Definition at line 61 of file ConsoleRoboCupCtrl.cpp.
References nesting, onConsoleCommand(), and printLn().
Referenced by ConsoleRoboCupCtrl(), and onConsoleCommand().
static const std::string& ConsoleRoboCupCtrl::getLogFile | ( | ) | [inline, static] |
The function returns whether the current robot constructed shall play back a log file.
Definition at line 156 of file ConsoleRoboCupCtrl.h.
References logFile.
void ConsoleRoboCupCtrl::handleJoystick | ( | ) | [private] |
Definition at line 423 of file ConsoleRoboCupCtrl.cpp.
References calcButtonCommand(), calcHead(), calcWalk(), RoboCupCtrl::getTime(), lastCommand, lastTime, and onConsoleCommand().
Referenced by execute().
void ConsoleRoboCupCtrl::help | ( | ) | [private] |
The function prints a help text.
Definition at line 244 of file ConsoleRoboCupCtrl.cpp.
References printLn().
Referenced by onConsoleCommand().
void ConsoleRoboCupCtrl::joystickButtonCommand | ( | InConfigMemory & | stream | ) | [private] |
The function defines the command to be executed if a certain joystick button is pressed.
stream | The text stream. |
Definition at line 298 of file ConsoleRoboCupCtrl.cpp.
References buttonCommand, InStream< S, R >::eof(), printLn(), and text.
Referenced by onConsoleCommand().
void ConsoleRoboCupCtrl::joystickHeadControl | ( | InConfigMemory & | stream | ) | [private] |
The function sets the assignment of joystick controls to control the head.
stream | The text stream. |
Definition at line 321 of file ConsoleRoboCupCtrl.cpp.
References panId, printLn(), rollId, and tiltId.
Referenced by onConsoleCommand().
void ConsoleRoboCupCtrl::onConsoleCommand | ( | const std::string & | command | ) | [virtual] |
The function is called when a console command has been entered.
command | The command. |
Reimplemented from Controller.
Definition at line 111 of file ConsoleRoboCupCtrl.cpp.
References buffer, List< T >::clear(), Controller::clear(), completion, createCompletion(), echo(), executeFile(), RoboCupCtrl::getCurrentSystemTime(), List< T >::getFirst(), List< T >::getSize(), RoboCupCtrl::getTime(), help(), List< T >::insert(), joystickButtonCommand(), joystickHeadControl(), physical, physicalRobots, print(), printLn(), RoboCupCtrl::robots, selectRobot(), RoboCupCtrl::simTime, simulated, startConnection(), startLogFile(), and RoboCupCtrl::time.
Referenced by executeFile(), and handleJoystick().
void ConsoleRoboCupCtrl::onConsoleCompletion | ( | std::string & | command, | |
bool | forward | |||
) | [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 from Controller.
Definition at line 716 of file ConsoleRoboCupCtrl.cpp.
References completion.
virtual void ConsoleRoboCupCtrl::onLineReceived | ( | const char * | line | ) | [inline, protected, virtual] |
The function is called for each line received from the router. As it is called from a different thread, it must take synchronisation into account.
line | The line of text that has been received. |
Definition at line 176 of file ConsoleRoboCupCtrl.h.
References printLn().
void ConsoleRoboCupCtrl::onSelected | ( | SimObject * | obj | ) | [virtual] |
The function is called when a movable object has been selected.
obj | The object. |
Reimplemented from Controller.
Definition at line 98 of file ConsoleRoboCupCtrl.cpp.
References List< T >::clear(), List< T >::getFirst(), RoboCupCtrl::getSimRobotObject(), List< T >::insert(), RoboCupCtrl::obj, physical, printLn(), RoboCupCtrl::robots, and simulated.
void ConsoleRoboCupCtrl::print | ( | const std::string & | text | ) |
The function prints a string into the console window.
text | The text to be printed. |
Reimplemented from Controller.
Definition at line 403 of file ConsoleRoboCupCtrl.cpp.
References List< T >::getLast(), List< T >::insert(), newLine, SYNC, and textMessages.
Referenced by echo(), RobotConsole::list(), and onConsoleCommand().
void ConsoleRoboCupCtrl::printLn | ( | const std::string & | text | ) |
The function prints a string into the console window. Future text will be printed on the next line.
text | The text to be printed. |
Reimplemented from Controller.
Definition at line 413 of file ConsoleRoboCupCtrl.cpp.
References List< T >::getLast(), List< T >::insert(), newLine, SYNC, and textMessages.
Referenced by RobotConsole::debugKey(), echo(), executeFile(), RobotConsole::handleConsole(), RobotConsole::handleMessage(), RobotConsole::headControlMode(), help(), joystickButtonCommand(), joystickHeadControl(), onConsoleCommand(), onLineReceived(), onSelected(), RobotConsole::sendGeneric(), RobotConsole::sendMotionRequest(), RobotConsole::sendTailRequest(), RobotConsole::solutionRequest(), startConnection(), RobotConsole::xabslBasicBehavior(), RobotConsole::xabslInputSymbol(), RobotConsole::xabslLoadBehavior(), RobotConsole::xabslOption(), and RobotConsole::xabslOutputSymbol().
bool ConsoleRoboCupCtrl::selectRobot | ( | const char * | name | ) | [private] |
The function adds a robot with a certain name to the set of selected robots.
name | The name of the robot. |
Definition at line 227 of file ConsoleRoboCupCtrl.cpp.
References List< T >::getFirst(), List< T >::insert(), physical, physicalRobots, RoboCupCtrl::robots, and simulated.
Referenced by onConsoleCommand().
void ConsoleRoboCupCtrl::setXabsl2Info | ( | int | index, | |
const Xabsl2Info & | xabsl2Info | |||
) | [inline] |
The function sets the Xabsl2 info used by the command completion.
xabsl2Info | The new Xabsl2 info. |
Definition at line 162 of file ConsoleRoboCupCtrl.h.
References xabsl2Infos.
bool ConsoleRoboCupCtrl::startConnection | ( | InConfigMemory & | stream | ) | [private] |
The function handles the console input for the "sc" command.
stream | The stream containing the parameters of "sc". |
Definition at line 347 of file ConsoleRoboCupCtrl.cpp.
References RobotConsole::addViews(), List< T >::clear(), RoboCupCtrl::currentDesign, RobotDesign::ERS210, RobotDesign::ERS7, List< T >::getLast(), List< T >::insert(), TcpConnection::isClient(), physical, physicalRobots, printLn(), RoboCupCtrl::robotName, simulated, and PhysicalRobot::start().
Referenced by onConsoleCommand().
bool ConsoleRoboCupCtrl::startLogFile | ( | InConfigMemory & | stream | ) | [private] |
The function handles the console input for the "sl" command.
stream | The stream containing the parameters of "sl". |
Definition at line 374 of file ConsoleRoboCupCtrl.cpp.
References List< T >::clear(), RoboCupCtrl::connect(), RoboCupCtrl::currentDesign, RobotDesign::ERS210, RobotDesign::ERS7, List< T >::getLast(), List< T >::insert(), logFile, physical, RoboCupCtrl::robotName, RoboCupCtrl::robots, and simulated.
Referenced by onConsoleCommand().
void ConsoleRoboCupCtrl::updateCommandCompletion | ( | ) | [inline] |
The function forces an update of the command completion table.
Definition at line 167 of file ConsoleRoboCupCtrl.h.
References completion.
Referenced by RobotConsole::xabslLoadBehavior().
std::string ConsoleRoboCupCtrl::buttonCommand[32] [private] |
Commands activated when a certain button is pressed.
Definition at line 29 of file ConsoleRoboCupCtrl.h.
Referenced by calcButtonCommand(), and joystickButtonCommand().
std::map<std::string,int> ConsoleRoboCupCtrl::completion [private] |
A list for command completion.
Definition at line 39 of file ConsoleRoboCupCtrl.h.
Referenced by createCompletion(), onConsoleCommand(), onConsoleCompletion(), and updateCommandCompletion().
ConsoleRoboCupCtrl::DECLARE_SYNC [private] |
std::string ConsoleRoboCupCtrl::lastCommand[3] [private] |
The last joystick commands calculated.
Definition at line 29 of file ConsoleRoboCupCtrl.h.
Referenced by handleJoystick().
unsigned ConsoleRoboCupCtrl::lastTime [private] |
The last time when joystick commands were handled.
Reimplemented from RoboCupCtrl.
Definition at line 31 of file ConsoleRoboCupCtrl.h.
Referenced by ConsoleRoboCupCtrl(), and handleJoystick().
std::string ConsoleRoboCupCtrl::logFile [static, private] |
States whether the current robot constructed shall play back a log file.
Definition at line 38 of file ConsoleRoboCupCtrl.h.
Referenced by getLogFile(), and startLogFile().
int ConsoleRoboCupCtrl::nesting [private] |
The number of recursion level during the execution of console files.
Definition at line 28 of file ConsoleRoboCupCtrl.h.
Referenced by ConsoleRoboCupCtrl(), and executeFile().
bool ConsoleRoboCupCtrl::newLine [private] |
States whether the last line of text was finished by a new line.
Definition at line 27 of file ConsoleRoboCupCtrl.h.
Referenced by ConsoleRoboCupCtrl(), execute(), print(), and printLn().
int ConsoleRoboCupCtrl::pan [private] |
The roll of the head (for joystick control).
Definition at line 32 of file ConsoleRoboCupCtrl.h.
Referenced by calcHead(), and ConsoleRoboCupCtrl().
int ConsoleRoboCupCtrl::panId [private] |
The button assignment to control the pan of the head.
Definition at line 32 of file ConsoleRoboCupCtrl.h.
Referenced by calcHead(), ConsoleRoboCupCtrl(), and joystickHeadControl().
List<List<PhysicalRobot>::Pos> ConsoleRoboCupCtrl::physical [private] |
The currently selected physical robot.
Definition at line 24 of file ConsoleRoboCupCtrl.h.
Referenced by onConsoleCommand(), onSelected(), selectRobot(), startConnection(), and startLogFile().
List<PhysicalRobot> ConsoleRoboCupCtrl::physicalRobots [private] |
Definition at line 25 of file ConsoleRoboCupCtrl.h.
Referenced by createCompletion(), onConsoleCommand(), selectRobot(), startConnection(), and ~ConsoleRoboCupCtrl().
int ConsoleRoboCupCtrl::roll [private] |
The roll of the head (for joystick control).
Definition at line 32 of file ConsoleRoboCupCtrl.h.
Referenced by calcHead(), and ConsoleRoboCupCtrl().
int ConsoleRoboCupCtrl::rollId [private] |
The button assignment to control the roll of the head.
Definition at line 32 of file ConsoleRoboCupCtrl.h.
Referenced by calcHead(), ConsoleRoboCupCtrl(), and joystickHeadControl().
List<List<Robot>::Pos> ConsoleRoboCupCtrl::simulated [private] |
The currently selected simulated robot.
Definition at line 23 of file ConsoleRoboCupCtrl.h.
Referenced by ConsoleRoboCupCtrl(), onConsoleCommand(), onSelected(), selectRobot(), startConnection(), and startLogFile().
List<std::string> ConsoleRoboCupCtrl::textMessages [private] |
A list of all text messages received in the current frame.
Definition at line 26 of file ConsoleRoboCupCtrl.h.
int ConsoleRoboCupCtrl::tilt [private] |
The tilt of the head (for joystick control).
Definition at line 32 of file ConsoleRoboCupCtrl.h.
Referenced by calcHead(), and ConsoleRoboCupCtrl().
int ConsoleRoboCupCtrl::tiltId [private] |
The button assignment to control the tilt of the head.
Definition at line 32 of file ConsoleRoboCupCtrl.h.
Referenced by calcHead(), ConsoleRoboCupCtrl(), and joystickHeadControl().
const Xabsl2Info* ConsoleRoboCupCtrl::xabsl2Infos[2] [private] |
Pointers to the current Xabsl2 infos.
Definition at line 40 of file ConsoleRoboCupCtrl.h.
Referenced by ConsoleRoboCupCtrl(), createCompletion(), and setXabsl2Info().