无法找到/读取配置文件.conf-FileIOException
Unable to find/read config file .conf - FileIOException
我试图使用libconfig::readFile((打开并读取程序中的.conf文件,但它总是给我一个FileIOException。我认为程序无法定位文件,但我不知道问题出在哪里。
这是.conf文件代码:
controlLoopPeriod = 100.0; # ms
saturationMax = [10.0];
saturationMin = [-10.0];
task = { Linear_Velocity = {
type = 0; # 0 equality, 1 inequality
gain = 1.0;
enable = true;
saturation = 10.0;
};
};
priorityLevels = ( { name = "PL_JPosition";
tasks = ["Joint_Position"];
lambda = 0.0001;
threshold = 0.01;
}
);
actions = ( { name = "jPosition";
levels = ["PL_JPosition"];
}
);
states = { State_move = {
minHeadingError = 0.05;
maxHeadingError = 0.2;
};
};
这就是我试图打开文件并阅读它的地方:
bool RobotPositionController::LoadConfiguration() {
libconfig::Config confObj;
// Inizialization
std::string confPath = "home/nimblbot/tpik_ctr_algo/ctrl_rob_nimblbot";
confPath.append("/conf/");
confPath.append(fileName_);
std::cout << "PATH TO CONF FILE : " << confPath << std::endl;
// Read the file. If there is an error, report it and exit.
try {
confObj.readFile(confPath.c_str());
} catch (const libconfig::FileIOException& fioex) {
std::cerr << "I/O error while reading file: " << fioex.what() << std::endl;
return -1;
} catch (const libconfig::ParseException& pex) {
std::cerr << "Parse error at " << pex.getFile() << ":" << pex.getLine() << " - " << pex.getError() << std::endl;
return -1;
}
conf_->ConfigureFromFile(confObj);
ConfigureTaskFromFile(tasksMap_, confObj);
ConfigurePriorityLevelsFromFile(actionManager_, tasksMap_, confObj);
// Set Saturation values for the iCAT (read from conf file)
iCat_->SetSaturation(conf_->saturationMin, conf_->saturationMax);
ConfigureActionsFromFile(actionManager_, confObj);
//insert states in the map
statesMap_.insert({ states::ID::jPos, stateJPosition_ });
ConfigureSatesFromFile(statesMap_, confObj);
//insert command in the map
commandsMap_.insert({ commands::ID::jPos, commandJPosition_ });
return true;
}
提前感谢您的任何帮助。
在我看来,您在主路径的开头缺少一个/
。
即,更改:
std::string confPath = "home/nimblbot/tpik_ctr_algo/ctrl_rob_nimblbot";
用于:
std::string confPath = "/home/nimblbot/tpik_ctr_algo/ctrl_rob_nimblbot";
我认为你已经检查了.conf文件存在于:
/home/nimblbot/tpik_ctr_algo/ctrl_rob_nimblbot/conf
相关文章:
- 无法找到/读取配置文件.conf-FileIOException
- 在WSL:configure_file上对config_file的每次调用都失败:配置文件时出现问题
- 正在读取二进制文件(is_open)
- 一种在C++中读取TXT配置文件的简单方法
- C++试图读取一个文件并输出到另一个文本文件
- FFMPEG配置文件级别id大小无效
- 为什么C++的文件 I/O 在读取文本文件时忽略初始空行?我怎样才能让它不这样做?
- 如何在c ++中读取.inp文件?
- 配置文件解析器仅返回以前的值
- 我的程序有一个保存配置文件的GUI,如何双击此配置文件以直接加载带有配置数据的GUI?
- 读取某些文件时出现分段错误,似乎与文件大小无关
- c++ 读取 xml 文件的内容
- 为什么 getline() 不读取文本文件中的所有内容?
- C++ 读取整个文件目录
- 逐字读取文本文件中的每一行并转换为 int(无限循环或崩溃?
- JPG-如何从ICC配置文件部分APP2读取/提取数据
- 在 c++ 中读取配置文件 json 并没有停止
- 尝试读取配置文件
- c++使用GetPrivateProfileString读取配置文件参数
- 正在从配置文件中读取变量