49 std::filesystem::path sensors_3d_yaml_path = package_path /
"config/sensors_3d.yaml";
50 if (!std::filesystem::is_regular_file(sensors_3d_yaml_path))
52 sensors_3d_yaml_path =
getSharePath(
"moveit_setup_app_plugins") /
"templates" /
"config/sensors_3d.yaml";
58 catch (
const std::runtime_error& e)
60 RCLCPP_ERROR_STREAM(*
logger_, e.what());
69 std::vector<SensorParameters> config;
71 if (file_path.empty())
75 std::ifstream input_stream(file_path);
76 if (!input_stream.good())
78 throw std::runtime_error(
"Unable to open file for reading " + file_path.string());
84 const YAML::Node& doc = YAML::Load(input_stream);
86 const YAML::Node& sensors_node = doc[
"sensors"];
89 if (sensors_node && sensors_node.IsSequence())
92 for (
const YAML::Node& sensor_name_node : sensors_node)
94 std::string sensor_name = sensor_name_node.as<std::string>();
95 const YAML::Node& sensor = doc[sensor_name];
98 sensor_map[
"name"] = sensor_name;
99 for (YAML::const_iterator sensor_it = sensor.begin(); sensor_it != sensor.end(); ++sensor_it)
101 sensor_map[sensor_it->first.as<std::string>()] = sensor_it->second.as<std::string>();
104 config.push_back(sensor_map);
109 catch (YAML::ParserException& e)
111 throw std::runtime_error(std::string(
"Error parsing sensors yaml: ") + e.what());
151 emitter << YAML::BeginMap;
152 emitter << YAML::Key <<
"sensors";
153 emitter << YAML::BeginSeq;
156 emitter << YAML::Value << sensor_config[
"name"];
158 emitter << YAML::EndSeq;
161 emitter << YAML::Key << sensor_config[
"name"];
162 emitter << YAML::BeginMap;
163 for (
auto& parameter : sensor_config)
165 if (parameter.first ==
"name")
169 emitter << YAML::Key << parameter.first;
170 emitter << YAML::Value << parameter.second;
172 emitter << YAML::EndMap;
174 emitter << YAML::EndMap;
180 #include <pluginlib/class_list_macros.hpp>
PLUGINLIB_EXPORT_CLASS(cached_ik_kinematics_plugin::CachedIKKinematicsPlugin< kdl_kinematics_plugin::KDLKinematicsPlugin >, kinematics::KinematicsBase)
where all the data for each part of the configuration is stored.
std::shared_ptr< rclcpp::Logger > logger_
PerceptionConfig & parent_
bool writeYaml(YAML::Emitter &emitter) override
void setConfig(const SensorParameters ¶meters)
static std::vector< SensorParameters > load3DSensorsYAML(const std::filesystem::path &file_path)
Load perception sensor config.
std::vector< SensorParameters > sensors_plugin_config_parameter_list_
Sensor plugin configuration parameter list, each sensor plugin type is a map of string pairs.
void loadPrevious(const std::filesystem::path &package_path, const YAML::Node &node) override
Loads the configuration from an existing MoveIt configuration.
void clearSensorPluginConfig()
Clear the sensor plugin configuration parameter list.
std::map< std::string, std::string > SensorParameters
std::filesystem::path getSharePath(const std::string &package_name)
Return a path for the given package's share folder.