ObeyGameManager::ObeyGameManager(ConfigFile & configFile, Log & _log) : INITIAL_CHEST_COLOR (configFile.getInt("rules/initialChestColor", 0x000000)), READY_CHEST_COLOR (configFile.getInt("rules/readyChestColor", 0x0000FF)), SET_CHEST_COLOR (configFile.getInt("rules/setChestColor", 0xFFFF00)), PLAYING_CHEST_COLOR (configFile.getInt("rules/playingChestColor", 0x00FF00)), FINISHED_CHEST_COLOR (configFile.getInt("rules/finishedChestColor", 0x000000)), PENALIZED_CHEST_COLOR(configFile.getInt("rules/penalisedChestColor", 0xFF0000)), BLUE_TEAM_FOOT_COLOR (configFile.getInt("rules/blueTeamFootColor", 0x0000FF)), RED_TEAM_FOOT_COLOR (configFile.getInt("rules/redTeamFootColor", 0xFF0000)), KICKOFF_FOOT_COLOR (configFile.getInt("rules/kickoffFootColor", 0xFFFFFF)), NO_KICKOFF_FOOT_COLOR(configFile.getInt("rules/noKickoffFootColor", 0x000000)), READY_SPEECH (configFile.getString("behaviors/2010/tactics/obeyGameManager/readySpeech", "I will get ready for the game.")), SET_SPEECH (configFile.getString("behaviors/2010/tactics/obeyGameManager/setSpeech", "I am all set!")), PLAYING_SPEECH (configFile.getString("behaviors/2010/tactics/obeyGameManager/playingSpeech", "It's time to play.")), PENALIZED_SPEECH (configFile.getString("behaviors/2010/tactics/obeyGameManager/penalizedSpeech", "Please don't penalize me!")), BACK_FROM_PENALTY_SPEECH(configFile.getString("behaviors/2010/tactics/obeyGameManager/backFromPenaltySpeech", "The taste of freedom is sweet.")), BLUE_TEAM_SPEECH (configFile.getString("behaviors/2010/tactics/obeyGameManager/blueTeamSpeech", "I am now on the blue team.")), RED_TEAM_SPEECH (configFile.getString("behaviors/2010/tactics/obeyGameManager/redTeamSpeech", "I am now on the red team.")), KICKOFF_SPEECH (configFile.getString("behaviors/2010/tactics/obeyGameManager/kickoffSpeech", "We have kickoff.")), NO_KICKOFF_SPEECH (configFile.getString("behaviors/2010/tactics/obeyGameManager/noKickoffSpeech", "We don't have kickoff.")), PLAYER_NUMBER(configFile.getInt("team/playerNumber", 2)), HEAD_SPEED(configFile.getFloat("motion/defaultHeadSpeed", 0.8f)), log(_log), fsm(_log), previousState(Uninitialized), currentState(Uninitialized), wasIBlue(false), wasOurKickoff(false), wasIPenalized(false) { init(_log.getTimestamp()); }
GameState::GameState(ConfigFile & configFile, Log & _log) : teamNumber(configFile.getInt("team/teamNumber", 0)), playerNumber(configFile.getInt("team/playerNumber", 2)), numberOfPlayersPerTeam(configFile.getInt("rules/numberOfPlayersPerTeam", 3)), log(_log), stateOfGame(initial), firstHalf(true), ourKickoff(true), ourColorBlue(true), numSecondsRemaining(0), ourScore(0), opponentScore(0), numOurPlayersPenalized(0), numOpponentPlayersPenalized(0), thisPlayerPenalized(false), penalized(new bool[numberOfPlayersPerTeam]), numSecondsTillUnpenalized(0), penaltyShoot(false) { for (int i = 0; i < numberOfPlayersPerTeam; i++) { penalized[i] = false; } }
CommRemote::CommRemote(ConfigFile & configFile, Log & _log) : listenPort (configFile.getInt ("comm/remoteListenPort", 10000)), maxClientQueue (configFile.getInt ("comm/remoteMaxClientQueue", 1)), maxPacketSize (configFile.getInt ("comm/maxPacketSize", 1024)), socketTimeout (configFile.getFloat("comm/socketTimeout", 1)), robotMessageHeaderSize(configFile.getInt ("comm/robotMessageHeaderSize", 5)), sendBufferSize (configFile.getInt ("comm/sendBufferSize", 1024 * 1024)), log(_log), serverSocket(-1), clientSocket(-1), threadRunning(false), thread(), dataMutex(), messagesToRobot(), messagesFromRobot(), wasConnectedToClient(false), sendBuffer(NULL), sendBufferOffset(0) { // Create the send buffer if (sendBufferSize > 0) { sendBuffer = new unsigned char[sendBufferSize]; } // Create the TCP socket and bind to the right port createTCPSocket(); // Create the data mutex if (pthread_mutex_init(&dataMutex, NULL) < 0) { LOG_ERROR("Error creating data mutex."); return; } // Start the thread to read/send packets if (pthread_create(&thread, NULL, startThread, this) < 0) { LOG_ERROR("Error creating thread."); return; } }
bool Annotation::initSection(const std::string &entry, const std::string &cfgname) { AnnotationCfgEntry e, *ne; ConfigFile *cfg = s2e()->getConfig(); llvm::raw_ostream &os = s2e()->getWarningsStream(); std::vector<std::string> cfgkeys = s2e()->getConfig()->getListKeys(entry); e.cfgname = cfgname; bool ok; e.isActive = cfg->getBool(entry + ".active", false, &ok); if (!ok) { os << "You must specify whether the entry is active in " << entry << ".active!" << '\n'; return false; } e.module = cfg->getString(entry + ".module", "", &ok); if (!ok) { os << "You must specify a valid module for " << entry << ".module!" << '\n'; return false; }else { if (!m_moduleExecutionDetector->isModuleConfigured(e.module)) { os << "The module " << e.module << " is not configured in ModuleExecutionDetector!" << '\n'; return false; } } e.address = cfg->getInt(entry + ".address", 0, &ok); if (!ok) { os << "You must specify a valid address for " << entry << ".address!" << '\n'; return false; } if (!m_functionMonitor || !m_moduleExecutionDetector || !m_osMonitor) { os << "You must enable FunctionMonitor, ModuleExecutionDetector, and an OS monitor plugin\n"; return false; } // Check if this is a call or an instruction annotation e.annotation = ""; if (std::find(cfgkeys.begin(), cfgkeys.end(), "callAnnotation") != cfgkeys.end()) { e.annotation = cfg->getString(entry + ".callAnnotation", e.annotation, &ok); e.isCallAnnotation = true; } else if (std::find(cfgkeys.begin(), cfgkeys.end(), "instructionAnnotation") != cfgkeys.end()) { e.annotation = cfg->getString(entry + ".instructionAnnotation", e.annotation, &ok); e.isCallAnnotation = false; } // Assert that this is a properly attached annotation if (!ok || e.annotation=="") { os << "You must specify either " << entry << ".callAnnotation or .instructionAnnotation!" << '\n'; return false; } // Get additional annotation-specific options e.paramCount = 0; e.beforeInstruction = false; e.switchInstructionToSymbolic = false; if (e.isCallAnnotation) { // Get the number of arguments of the annotated subroutine e.paramCount = cfg->getInt(entry + ".paramcount", e.paramCount, &ok); if (!ok) { os << "You must specify a valid number of function parameters for " << entry << ".paramcount!" << '\n'; return false; } } else { // Whether to call the annotation before or after the instruction e.beforeInstruction = cfg->getBool(entry + ".beforeInstruction", e.beforeInstruction, &ok); e.switchInstructionToSymbolic = cfg->getBool(entry + ".switchInstructionToSymbolic", e.switchInstructionToSymbolic, &ok); } ne = new AnnotationCfgEntry(e); m_entries.insert(ne); return true; }
NaoCamera::NaoCamera(ConfigFile & configFile, Log & _log) : V4L2_CID_AUTO_EXPOSURE(10094849), NUM_FRAME_BUFFERS(configFile.getInt("camera/numFrameBuffers", 4)), IMAGE_WIDTH(configFile.getInt("camera/imageWidth", 320)), IMAGE_HEIGHT(configFile.getInt("camera/imageHeight", 240)), FRAMES_PER_SECOND(configFile.getInt("camera/framesPerSecond", 0)), IMAGE_SIZE(IMAGE_WIDTH * IMAGE_HEIGHT * 2), BRIGHTNESS_TOP (configFile.getInt("camera/top/brightness", 55)), CONTRAST_TOP (configFile.getInt("camera/top/contrast", 32)), SATURATION_TOP (configFile.getInt("camera/top/saturation", 128)), HUE_TOP (configFile.getInt("camera/top/hue", 0)), AUTO_WHITE_BALANCE_TOP (configFile.getInt("camera/top/autoWhiteBalance", 0)), WHITE_BALANCE_TOP (configFile.getInt("camera/top/whiteBalance", 0)), AUTO_EXPOSURE_TOP (configFile.getInt("camera/top/autoExposure", 0)), EXPOSURE_TOP (configFile.getInt("camera/top/exposure", 0)), GAIN_TOP (configFile.getInt("camera/top/gain", 32)), HORIZONTAL_FLIP_TOP (configFile.getInt("camera/top/horizontalFlip", 0)), VERTICAL_FLIP_TOP (configFile.getInt("camera/top/verticalFlip", 0)), SHARPNESS_TOP (configFile.getInt("camera/top/sharpness", 0)), BACKLIGHT_COMPENSATION_TOP(configFile.getInt("camera/top/backlightCompensation", 1)), BRIGHTNESS_BOTTOM (configFile.getInt("camera/bottom/brightness", BRIGHTNESS_TOP)), CONTRAST_BOTTOM (configFile.getInt("camera/bottom/contrast", CONTRAST_TOP)), SATURATION_BOTTOM (configFile.getInt("camera/bottom/saturation", SATURATION_TOP)), HUE_BOTTOM (configFile.getInt("camera/bottom/hue", HUE_TOP)), AUTO_WHITE_BALANCE_BOTTOM (configFile.getInt("camera/bottom/autoWhiteBalance", AUTO_WHITE_BALANCE_TOP)), WHITE_BALANCE_BOTTOM (configFile.getInt("camera/bottom/whiteBalance", WHITE_BALANCE_TOP)), AUTO_EXPOSURE_BOTTOM (configFile.getInt("camera/bottom/autoExposure", AUTO_EXPOSURE_TOP)), EXPOSURE_BOTTOM (configFile.getInt("camera/bottom/exposure", EXPOSURE_TOP)), GAIN_BOTTOM (configFile.getInt("camera/bottom/gain", GAIN_TOP)), HORIZONTAL_FLIP_BOTTOM (configFile.getInt("camera/bottom/horizontalFlip", HORIZONTAL_FLIP_TOP)), VERTICAL_FLIP_BOTTOM (configFile.getInt("camera/bottom/verticalFlip", VERTICAL_FLIP_TOP)), SHARPNESS_BOTTOM (configFile.getInt("camera/bottom/sharpness", SHARPNESS_TOP)), BACKLIGHT_COMPENSATION_BOTTOM(configFile.getInt("camera/bottom/backlightCompensation", BACKLIGHT_COMPENSATION_TOP)), log(_log), topCameraFd(-1), bottomCameraFd(-1), buffersTop(NULL), buffersBottom(NULL), numBuffersTop(0), numBuffersBottom(0), currentBufferTop(0), currentBufferBottom(0), v4l2BuffersTop(), v4l2BuffersBottom(), currentV4l2BufferTop(&v4l2BuffersTop[0]), currentV4l2BufferBottom(&v4l2BuffersBottom[0]), nextV4l2BufferTop(&v4l2BuffersTop[1]), nextV4l2BufferBottom(&v4l2BuffersBottom[1]), topCameraThread(), bottomCameraThread(), topThreadRunning(false), bottomThreadRunning(false), freshImage(), freshImageMutex(), freshImageTop(false), freshImageBottom(false), usingBottomCamera(true), enqueuedTop(false), enqueuedBottom(false) { // Create the condition variable and its mutex if (pthread_cond_init(&freshImage, NULL) < 0) { return; } if (pthread_mutex_init(&freshImageMutex, NULL) < 0) { return; } }
PlayerMessage::PlayerMessage(ConfigFile & configFile) : teamNumber (configFile.getInt("team/teamNumber", -1)), playerNumber(configFile.getInt("team/playerNumber", -1)), ballSeen(false) { }