Beispiel #1
0
int DogRunInit() {
  printf("%s\n", __FUNCTION__);
  if (!FoodCfg) {
    FoodCfg = new dogrun2::FoodConfigArray;
    assert(FoodCfg != NULL);
    ParseFromFile("../common/etc/food.cfg", FoodCfg);
  }
  if (!TrainCfg) {
    TrainCfg = new dogrun2::TrainConfigArray;
    assert(TrainCfg != NULL);
    ParseFromFile("../common/etc/train.cfg", TrainCfg);
  }
  if (!PlayCfg) {
    PlayCfg = new dogrun2::PlayConfigArray;
    assert(PlayCfg != NULL);
    ParseFromFile("../common/etc/play.cfg", PlayCfg);
  }

  if (!DogLevelCfg) {
    DogLevelCfg = new dogrun2::DogLevelConfigArray;
    assert(DogLevelCfg != NULL);
    ParseFromFile("../common/etc/doglevel.cfg", DogLevelCfg);
  }
  
  return 0;
}
Beispiel #2
0
void VisionConductor::Load(string pathfile)
{
  // $IT_DATA environmet variable, NULL if not set
  const char *it_data = getenv("IT_DATA");
  string std_it_data;
  if (it_data!=NULL) {
    std_it_data = ConvertPathToStandard(it_data);
  } else {
    std_it_data = "";
  }

  // substitute $IT_DATA environment variable, if requested
  string::size_type pos = pathfile.find("$IT_DATA");
  if (pos!=string::npos) {
    if (it_data==NULL) {
      throw HVEFile(pathfile, "The filename requests the environment variable "
        "$IT_DATA to be set.");
    }
    // substitute "$IT_DATA" for the value of that environment variable
    ReplaceAll(pathfile, "$IT_DATA", std_it_data);
  }

  // all paths in the VisionConductor file "filename" are relative
  // to the path of "filename".  so, let's cd to that directory, load
  // all cascades etc., and in the end restore the previous cwd.
  string old_cwd = GetCWD();
  string vc_path, fname;
  SplitPathFile(pathfile, vc_path, fname);
  VERBOSE1(5, "HandVu: loading supplemental conductor files from path %s",
    vc_path.c_str());
  if (old_cwd!=vc_path) {
    SetCWD(vc_path);
  }

  m_masks.clear();
  m_orig_areas.clear();

  try {
    // the actual parsing function
    ParseFromFile(fname);
  } catch (HVException& hve) {
    if (old_cwd!=vc_path) {
      SetCWD(old_cwd);
    }
    throw HVException(hve.GetMessage() + "\n" +
      "note: paths in VisionConductor files are relative;\n"
      "in this case to " + vc_path);
  }

  if (old_cwd!=vc_path) {
    SetCWD(old_cwd);
  }

  SanityCheckMasks();

  m_is_loaded = true;
}