I'm modifying ifm3d-ros to load JSON configuration files on node startup to allow for greater visibility and control of sensor settings (such as AutoExposure) across our robot fleet. To this end, I've added the following method to the ifm3d_ros::CameraNodelet class -
bool
ifm3d_ros::CameraNodelet::ConfigureCamera(){
std::lock_guard<std::mutex> lock(this->mutex_);
// Load appropriate JSON config file, if present
std::string robot_name;
if (!np_.getParam("/device_name", robot_name)) {
ROS_ERROR_STREAM("'" << robot_name << "' param is not retrieved cannot be retrieved from the param server");
return false;
}
std::string cfg_path = ros::package::getPath(CONFIG_DIR)+ "/" + robot_name + "/ifm_settings";
std::string cfg_filename = "/" + frame_id_base_ + ".json";
std::string cfg_file_path = cfg_path + cfg_filename;
std::ifstream config_file(cfg_file_path);
if (config_file) {
NODELET_INFO_STREAM("Loading configuration from file: " << cfg_path);
json config_struct;
try {
config_struct = json::parse(config_file);
ROS_WARN_STREAM("Loaded " << frame_id_base_ << " settings from " << cfg_file_path);
} catch (const std::exception& std_ex) {
ROS_ERROR_STREAM("Unable to load JSON");
return false;
}
int status = 0;
try {
this->cam_->FromJSON(config_struct);
} catch (const ifm3d::error_t& ex) {
status = ex.code();
NODELET_ERROR_STREAM("Config error: " << ex.what());
} catch (const std::exception& std_ex) {
status = -1;
NODELET_ERROR_STREAM("Config error: " << std_ex.what());
} catch (...) {
status = -2;
NODELET_ERROR_STREAM("Config error: Unknown error in Config");
}
if (status != 0) {
return false;
}
} else {
NODELET_INFO_STREAM("Config file missing. Current settings will be dumped in " << cfg_file_path);
//If RSC directory doesn't exist, create it before creating the IFM settings directory
std::string rsc_dir_path = ros::package::getPath(CONFIG_DIR)+ "/" + robot_name;
if (!createDirectory(rsc_dir_path)) {
NODELET_INFO_STREAM("Error creating ifm settings directory: " << rsc_dir_path);
return false;
}
if (!createDirectory(cfg_path)) {
NODELET_INFO_STREAM("Error creating ifm settings directory: " << cfg_path);
return false;
}
std::string curr_config = this->cam_->ToJSONStr();
json cfg_json = json::parse(curr_config);
std::ofstream of_str(cfg_path + cfg_filename);
of_str << std::setw(4) << cfg_json << std::endl;
}
return true;
}
The critical part of this method is its usage of the following function
ifm3d::Camera::FromJSON(const json& j)
I call this function right after InitStructures() in the main Run() method of the ifm3d_ros::CameraNodelet class
I am now able to configure different values for params such as ContinuousAutoExposure, SymmetryThreshold etc. However, when I try to adjust the values for "OutputXYZImage", they do not change on the sensor. Here's a diff snippet -
If I pass the same JSON to the command line tool ifm3d dump, the values for those items do indeed change. Should I be doing something different in my method to set these values via the camera nodelet?
Please let me know if you need additional information. Thanks!
I'm modifying ifm3d-ros to load JSON configuration files on node startup to allow for greater visibility and control of sensor settings (such as AutoExposure) across our robot fleet. To this end, I've added the following method to the
ifm3d_ros::CameraNodelet
class -The critical part of this method is its usage of the following function
ifm3d::Camera::FromJSON(const json& j)
I call this function right after
InitStructures()
in the mainRun()
method of theifm3d_ros::CameraNodelet
classConsider the following JSON config -
I am now able to configure different values for params such as ContinuousAutoExposure, SymmetryThreshold etc. However, when I try to adjust the values for "OutputXYZImage", they do not change on the sensor. Here's a diff snippet -
If I pass the same JSON to the command line tool
ifm3d dump
, the values for those items do indeed change. Should I be doing something different in my method to set these values via the camera nodelet?Please let me know if you need additional information. Thanks!