bool Params::Load(string FileName){ int BufferSize = 4096; char* theLine = new char[BufferSize]; ifstream theFile(FileName.c_str()); if (theFile.fail()) { mstrErrorMessage = "Failed to open the description file!"; return false; } int nLineCount = 0; while (!theFile.eof()) { theFile.getline(theLine, BufferSize); nLineCount++; string theline(theLine); string Name(""), Value(""); theline = trim(theline); if (theline.length() && (theline.c_str()[0] != '#')) { int pos = 0; if ((pos = theline.find("=")) != -1) { Name = theline.substr(0, pos); Value = theline.substr(pos + 1); } if (Name == "" && Value == "") { } else if (Name == "" || Value == "") { mstrErrorMessage = "Invalid <Name = Value> pair format"; cout << theLine << endl; return false; } else { string name = ToLower(Name); string value = ToLower(Value); if (name == "numberofvariables") { mnNumberOfGenes = ToInt(value); } else if (name == "traindatafile") { mstrTrainDataFile = Value; } else if (name == "trainsamplesize") { mnTrainSampleSize = ToInt(value); } else if (name == "testdatafile") { mstrTestDataFile = Value; } else if (name == "testsamplesize") { mnTestSampleSize = ToInt(value); } else if (name == "maxregressors") { mnMaxRegressors = ToInt(value); } else if (name == "modelsfile") { mstrModelsFile = Value; } else if (name == "chainiterations") { mnChainIterations = ToInt(value); } else { mstrErrorMessage = "Unknown <Name = Value> pair!"; //to be refined later cout << theLine << endl; return false; } //cout << theLine << endl; } } } delete[] theLine; mstrErrorMessage = ""; return true; }
void local_map::laser_projection(const gns::frame& f, const laser& laser, grid< 400>& out) { out.clear(); gns::frame wXl = f * laser.rXl; change change = get_change(); pointi lasercoord = change.toCell(wXl.zero()); for (unsigned int i = 0; i < laser.count(); i++) { gns::point p = wXl * gns::point::polar(laser.range(i), laser.angle(i)); if (gns::distance(p, m_wXr.zero()) <= m_robot_size) continue; pointi gcp = change.toCell(p); my::line theline(lasercoord, gcp); for (my::line::iterator j = theline.begin(); j != theline.end(); ++j) { if (out.valid(j->x, j->y) and out(j->x, j->y) == cell::UNKNOWN) out(j->x, j->y) = cell::FREE; } if (laser.range(i) < laser.max_range and out.valid(gcp.x, gcp.y)) out(gcp.x, gcp.y) = cell::NONFREE; } for (int i = int(laser.count()) - 1; i >= 0; i--) { gns::point p = wXl * gns::point::polar(laser.range(i), laser.angle(i)); if (gns::distance(p, m_wXr.zero()) <= m_robot_size) continue; pointi gcp = change.toCell(p); my::line theline(lasercoord, gcp); for (my::line::iterator j = theline.begin(); j != theline.end(); ++j) { if (out.valid(j->x, j->y) and out(j->x, j->y) == cell::UNKNOWN) out(j->x, j->y) = cell::FREE; } if (laser.range(i) < laser.max_range and out.valid(gcp.x, gcp.y)) out(gcp.x, gcp.y) = cell::NONFREE; } }