From 41dc846c38638d2df73fff6458ede31a8b5246ec Mon Sep 17 00:00:00 2001 From: Nate Koenig Date: Tue, 8 Sep 2020 15:17:46 -0700 Subject: [PATCH 1/5] Modify path tracer to use an RTF value Signed-off-by: Nate Koenig --- subt_ign/src/path_tracer.cc | 32 +++++++++++++++++++++++--------- subt_ign/src/path_tracer.hh | 7 ++++--- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/subt_ign/src/path_tracer.cc b/subt_ign/src/path_tracer.cc index 34ed7767..9189bf7b 100644 --- a/subt_ign/src/path_tracer.cc +++ b/subt_ign/src/path_tracer.cc @@ -17,8 +17,8 @@ #include "path_tracer.hh" ////////////////////////////////////////////////// -Processor::Processor(const std::string &_path, int _stepSleepMs) - : stepSleepMs(_stepSleepMs) +Processor::Processor(const std::string &_path, double _rtf) + : rtf(_rtf) { // Create the transport node with the partition used by simulation // world. @@ -200,13 +200,21 @@ void Processor::ArtifactCb(const ignition::msgs::Pose_V &_msg) ////////////////////////////////////////////////// void Processor::DisplayPoses() { - for (auto &stepData : this->logData) + for (std::map>>::iterator iter = + this->logData.begin(); iter != this->logData.end(); ++iter) { - for (std::unique_ptr &data : stepData.second) + for (std::unique_ptr &data : iter->second) { data->Render(this); } - std::this_thread::sleep_for(std::chrono::milliseconds(this->stepSleepMs)); + + // Get the next time stamp, and sleep the correct amount of time. + auto next = std::next(iter, 1); + if (next != this->logData.end()) + { + int sleepTime = ((next->first - iter->first) / this->rtf)*1000; + std::this_thread::sleep_for(std::chrono::milliseconds(sleepTime)); + } } } @@ -337,20 +345,26 @@ void ReportData::Render(Processor *_p) ///////////////////////////////////////////////// int main(int _argc, char **_argv) { - int sleep = 20; + double rtf = 1; if (_argc > 2) { try { - sleep = std::stoi(_argv[2]); + rtf = std::stod(_argv[2]); } catch(...) { - std::cerr << "Invalid sleep time. Defaulting to 20ms\n"; + std::cerr << "Invalid RTF. Defaulting to 1.0\n"; } } + if (rtf <= 0) + { + std::cerr << "Invalid RTF of [" << rtf << "]. Defaulting to 1.0\n"; + rtf = 1.0; + } + // Create and run the processor. - Processor p(_argv[1], sleep); + Processor p(_argv[1], rtf); return 0; } diff --git a/subt_ign/src/path_tracer.hh b/subt_ign/src/path_tracer.hh index c6a9e2bc..c8ddc312 100644 --- a/subt_ign/src/path_tracer.hh +++ b/subt_ign/src/path_tracer.hh @@ -90,7 +90,8 @@ class Processor /// \brief Constructor, which also kicks off all of the data /// visualization. /// \param[in] _path Path to the directory containing the log files. - public: Processor(const std::string &_path, int _stepSleepMs); + /// \param[in] _rtf Real time factor for playback. + public: Processor(const std::string &_path, double _rtf); /// \brief Destructor public: ~Processor(); @@ -174,6 +175,6 @@ class Processor /// \brief All of the pose data. private: std::map>> logData; - /// \brief Number of milliseconds to sleep between log steps. - private: int stepSleepMs = 20; + /// \brief Realtime factor for playback. + private: double rtf = 1.0; }; From adb1f2907bf65d84146e0a03a0d8c0af007a9a49 Mon Sep 17 00:00:00 2001 From: Nate Koenig Date: Wed, 9 Sep 2020 09:08:01 -0700 Subject: [PATCH 2/5] Start of path tracer color yaml configuration Signed-off-by: Nate Koenig --- subt_ign/src/path_tracer.yml | 81 ++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 subt_ign/src/path_tracer.yml diff --git a/subt_ign/src/path_tracer.yml b/subt_ign/src/path_tracer.yml new file mode 100644 index 00000000..110baae3 --- /dev/null +++ b/subt_ign/src/path_tracer.yml @@ -0,0 +1,81 @@ +incorrect_report_color: + ambient: + r: 1.0 + g: 0.0 + b: 0.0 + a: 0.5 + diffuse: + r: 1.0 + g: 0.0 + b: 0.0 + a: 0.5 + emissive: + r: 0.2 + g: 0.0 + b: 0.0 + a: 0.1 +correct_report_color: + ambient: + r: 0.0 + g: 1.0 + b: 0.0 + a: 1.0 + diffuse: + r: 0.0 + g: 1.0 + b: 0.0 + a: 1.0 + emissive: + r: 0.0 + g: 1.0 + b: 0.0 + a: 1.0 +artficat_location_color: + ambient: + r: 0.0 + g: 1.0 + b: 1.0 + a: 0.5 + diffuse: + r: 0.0 + g: 1.0 + b: 1.0 + a: 0.5 + emissive: + r: 0.0 + g: 1.0 + b: 1.0 + a: 0.5 +robot_colors: + 1: + ambient: + r: 0.0 + g: 1.0 + b: 1.0 + a: 0.5 + diffuse: + r: 0.0 + g: 1.0 + b: 1.0 + a: 0.5 + emissive: + r: 0.0 + g: 1.0 + b: 1.0 + a: 0.5 + 2: + ambient: + r: 0.0 + g: 1.0 + b: 1.0 + a: 0.5 + diffuse: + r: 0.0 + g: 1.0 + b: 1.0 + a: 0.5 + emissive: + r: 0.0 + g: 1.0 + b: 1.0 + a: 0.5 From b2804cdaedb8ae685a12f8191a7c208c0119a515 Mon Sep 17 00:00:00 2001 From: Nate Koenig Date: Wed, 9 Sep 2020 13:02:52 -0700 Subject: [PATCH 3/5] Support yaml configuration for colors and rtf Signed-off-by: Nate Koenig --- subt_ign/src/path_tracer.cc | 256 ++++++++++++++++++++++++++++++------ subt_ign/src/path_tracer.hh | 158 ++++++++++++++++++---- 2 files changed, 348 insertions(+), 66 deletions(-) diff --git a/subt_ign/src/path_tracer.cc b/subt_ign/src/path_tracer.cc index 9189bf7b..849f1a14 100644 --- a/subt_ign/src/path_tracer.cc +++ b/subt_ign/src/path_tracer.cc @@ -17,9 +17,202 @@ #include "path_tracer.hh" ////////////////////////////////////////////////// -Processor::Processor(const std::string &_path, double _rtf) - : rtf(_rtf) +MarkerColor::MarkerColor(const YAML::Node &_node) { + if (_node["ambient"]) + { + if (_node["ambient"]["r"]) + this->ambient.R(_node["ambient"]["r"].as()); + else + this->ambient.R(1.0); + + if (_node["ambient"]["g"]) + this->ambient.G(_node["ambient"]["g"].as()); + else + this->ambient.G(1.0); + + if (_node["ambient"]["b"]) + this->ambient.B(_node["ambient"]["b"].as()); + else + this->ambient.B(1.0); + + if (_node["ambient"]["a"]) + this->ambient.A(_node["ambient"]["a"].as()); + else + this->ambient.A(1.0); + } + + if (_node["diffuse"]) + { + if (_node["diffuse"]["r"]) + this->diffuse.R(_node["diffuse"]["r"].as()); + else + this->diffuse.R(1.0); + + if (_node["diffuse"]["g"]) + this->diffuse.G(_node["diffuse"]["g"].as()); + else + this->diffuse.G(1.0); + + if (_node["diffuse"]["b"]) + this->diffuse.B(_node["diffuse"]["b"].as()); + else + this->diffuse.B(1.0); + + if (_node["diffuse"]["a"]) + this->diffuse.A(_node["diffuse"]["a"].as()); + else + this->diffuse.A(1.0); + } + + if (_node["emissive"]) + { + if (_node["emissive"]["r"]) + this->emissive.R(_node["emissive"]["r"].as()); + else + this->emissive.R(1.0); + + if (_node["emissive"]["g"]) + this->emissive.G(_node["emissive"]["g"].as()); + else + this->emissive.G(1.0); + + if (_node["emissive"]["b"]) + this->emissive.B(_node["emissive"]["b"].as()); + else + this->emissive.B(1.0); + + if (_node["emissive"]["a"]) + this->emissive.A(_node["emissive"]["a"].as()); + else + this->emissive.A(1.0); + } +} + +////////////////////////////////////////////////// +MarkerColor::MarkerColor(const MarkerColor &_clr) + :ambient(_clr.ambient), diffuse(_clr.diffuse), emissive(_clr.emissive) +{ +} + +////////////////////////////////////////////////// +MarkerColor::MarkerColor(const ignition::math::Color &_ambient, + const ignition::math::Color &_diffuse, + const ignition::math::Color &_emissive) + : ambient(_ambient), diffuse(_diffuse), emissive(_emissive) +{ +} + +////////////////////////////////////////////////// +Processor::Processor(const std::string &_path, const std::string &_configPath) +{ + YAML::Node cfg; + if (!_configPath.empty()) + { + if (ignition::common::exists(_configPath)) + { + try + { + cfg = YAML::LoadFile(_configPath); + } + catch (...) + { + std::cerr << "Unable to load configuration file[" + << _configPath << "]\n"; + } + } + else + { + std::cerr << "Configuration file[" << _configPath << "] doesn't exist\n"; + } + } + + // Set the RTF value + if (cfg && cfg["rtf"]) + this->rtf = cfg["rtf"].as(); + + // Color of incorrect reports. + if (cfg && cfg["incorrect_report_color"]) + { + this->artifactColors["incorrect_report_color"] = + MarkerColor(cfg["incorrect_report_color"]); + } + else + { + this->artifactColors["incorrect_report_color"] = + MarkerColor({1.0, 0.0, 0.0, 0.5}, + {1.0, 0.0, 0.0, 0.5}, + {0.2, 0.0, 0.0, 0.1}); + } + + // Color of correct reports. + if (cfg && cfg["correct_report_color"]) + { + this->artifactColors["correct_report_color"] = + MarkerColor(cfg["correct_report_color"]); + } + else + { + this->artifactColors["correct_report_color"] = + MarkerColor({0.0, 1.0, 0.0, 1.0}, + {0.0, 1.0, 0.0, 1.0}, + {0.0, 1.0, 0.0, 1.0}); + } + + // Color of artifact locations + if (cfg && cfg["artifact_location_color"]) + { + this->artifactColors["artifact_location_color"] = + MarkerColor(cfg["artifact_location_color"]); + } + else + { + this->artifactColors["artifact_location_color"] = + MarkerColor({0.0, 1.0, 1.0, 0.5}, + {0.0, 1.0, 1.0, 0.5}, + {0.0, 0.2, 0.2, 0.5}); + } + + // Color of robot paths + if (cfg && cfg["robot_colors"]) + { + for (std::size_t i = 0; i < cfg["robot_colors"].size(); ++i) + { + this->robotColors.push_back(MarkerColor(cfg["robot_colors"][i])); + } + } + else + { + this->robotColors.push_back( + MarkerColor({0.6, 0.0, 1.0, 1.0}, + {0.6, 0.0, 1.0, 1.0}, + {0.6, 0.0, 1.0, 1.0})); + this->robotColors.push_back( + MarkerColor({0.678, 0.2, 1.0, 1.0}, + {0.678, 0.2, 1.0, 1.0}, + {0.678, 0.2, 1.0, 1.0})); + this->robotColors.push_back( + MarkerColor({0.761, 0.4, 1.0, 1.0}, + {0.761, 0.4, 1.0, 1.0}, + {0.761, 0.4, 1.0, 1.0})); + this->robotColors.push_back( + MarkerColor({0.839, 0.6, 1.0, 1.0}, + {0.839, 0.6, 1.0, 1.0}, + {0.839, 0.6, 1.0, 1.0})); + this->robotColors.push_back( + MarkerColor({1.0, 0.6, 0.0, 1.0}, + {1.0, 0.6, 0.0, 1.0}, + {1.0, 0.6, 0.0, 1.0})); + this->robotColors.push_back( + MarkerColor({1.0, 0.678, 0.2, 1.0}, + {1.0, 0.678, 0.2, 1.0}, + {1.0, 0.678, 0.2, 1.0})); + this->robotColors.push_back( + MarkerColor({1.0, 0.761, 0.4, 1.0}, + {1.0, 0.761, 0.4, 1.0}, + {1.0, 0.761, 0.4, 1.0})); + } + // Create the transport node with the partition used by simulation // world. ignition::transport::NodeOptions opts; @@ -223,14 +416,15 @@ void Processor::DisplayArtifacts() { for (const auto &artifact : this->artifacts) { - this->SpawnMarker(this->colors[2], artifact.second.Pos(), + this->SpawnMarker(this->artifactColors["artifact_location_color"], + artifact.second.Pos(), ignition::msgs::Marker::SPHERE, ignition::math::Vector3d(8, 8, 8)); } } ////////////////////////////////////////////////// -void Processor::SpawnMarker(ignition::math::Color &_color, +void Processor::SpawnMarker(MarkerColor &_color, const ignition::math::Vector3d &_pos, ignition::msgs::Marker::Type _type, const ignition::math::Vector3d &_scale) @@ -245,18 +439,18 @@ void Processor::SpawnMarker(ignition::math::Color &_color, markerMsg.set_visibility(ignition::msgs::Marker::GUI); // Set color - markerMsg.mutable_material()->mutable_ambient()->set_r(_color.R()); - markerMsg.mutable_material()->mutable_ambient()->set_g(_color.G()); - markerMsg.mutable_material()->mutable_ambient()->set_b(_color.B()); - markerMsg.mutable_material()->mutable_ambient()->set_a(_color.A()); - markerMsg.mutable_material()->mutable_diffuse()->set_r(_color.R()); - markerMsg.mutable_material()->mutable_diffuse()->set_g(_color.G()); - markerMsg.mutable_material()->mutable_diffuse()->set_b(_color.B()); - markerMsg.mutable_material()->mutable_diffuse()->set_a(_color.A()); - markerMsg.mutable_material()->mutable_emissive()->set_r(_color.R()); - markerMsg.mutable_material()->mutable_emissive()->set_g(_color.G()); - markerMsg.mutable_material()->mutable_emissive()->set_b(_color.B()); - markerMsg.mutable_material()->mutable_emissive()->set_a(_color.A()); + markerMsg.mutable_material()->mutable_ambient()->set_r(_color.ambient.R()); + markerMsg.mutable_material()->mutable_ambient()->set_g(_color.ambient.G()); + markerMsg.mutable_material()->mutable_ambient()->set_b(_color.ambient.B()); + markerMsg.mutable_material()->mutable_ambient()->set_a(_color.ambient.A()); + markerMsg.mutable_material()->mutable_diffuse()->set_r(_color.diffuse.R()); + markerMsg.mutable_material()->mutable_diffuse()->set_g(_color.diffuse.G()); + markerMsg.mutable_material()->mutable_diffuse()->set_b(_color.diffuse.B()); + markerMsg.mutable_material()->mutable_diffuse()->set_a(_color.diffuse.A()); + markerMsg.mutable_material()->mutable_emissive()->set_r(_color.emissive.R()); + markerMsg.mutable_material()->mutable_emissive()->set_g(_color.emissive.G()); + markerMsg.mutable_material()->mutable_emissive()->set_b(_color.emissive.B()); + markerMsg.mutable_material()->mutable_emissive()->set_a(_color.emissive.A()); ignition::msgs::Set(markerMsg.mutable_scale(), _scale); @@ -287,7 +481,8 @@ void Processor::Cb(const ignition::msgs::Pose_V &_msg) if (this->robots.find(name) == this->robots.end()) { - this->robots[name] = this->colors[this->robots.size()+3]; + this->robots[name] = this->robotColors[ + this->robots.size() % this->robotColors.size()]; this->prevPose[name] = pose; } @@ -330,13 +525,13 @@ void ReportData::Render(Processor *_p) // Otherwise render a red box. if (this->score > 0) { - _p->SpawnMarker(_p->colors[1], this->pos, + _p->SpawnMarker(_p->artifactColors["correct_report_color"], this->pos, ignition::msgs::Marker::SPHERE, ignition::math::Vector3d(4, 4, 4)); } else { - _p->SpawnMarker(_p->colors[0], this->pos, + _p->SpawnMarker(_p->artifactColors["incorrect_report_color"], this->pos, ignition::msgs::Marker::BOX, ignition::math::Vector3d(4, 4, 4)); } @@ -345,26 +540,11 @@ void ReportData::Render(Processor *_p) ///////////////////////////////////////////////// int main(int _argc, char **_argv) { - double rtf = 1; + // Create and run the processor. if (_argc > 2) - { - try - { - rtf = std::stod(_argv[2]); - } - catch(...) - { - std::cerr << "Invalid RTF. Defaulting to 1.0\n"; - } - } - - if (rtf <= 0) - { - std::cerr << "Invalid RTF of [" << rtf << "]. Defaulting to 1.0\n"; - rtf = 1.0; - } + Processor p(_argv[1], _argv[2]); + else + Processor p(_argv[1]); - // Create and run the processor. - Processor p(_argv[1], rtf); return 0; } diff --git a/subt_ign/src/path_tracer.hh b/subt_ign/src/path_tracer.hh index c8ddc312..1fbf57a9 100644 --- a/subt_ign/src/path_tracer.hh +++ b/subt_ign/src/path_tracer.hh @@ -27,16 +27,102 @@ #include #include -// Usage: +// # Usage: // // 1. Run the SubT world using the `path_tracer.ign` launch file along with // an IGN_PARTITION name of PATH_TRACER. For example // // $ IGN_PARTITION=PATH_TRACER ign launch -v 4 path_tracer.ign worldName:=cave_qual // -// 2. Run this program by passing in the directory that contains the simulation log files. Optionally specify the number of milliseconds to sleep between time step playback. If not specified a value of 20ms will be used. For example: +// 2. Run this program by passing in the directory that contains the simulation log files. Optionally specify a configuration file. For example: // -// $ ./path_tracer /data/logs/ 100 +// $ ./path_tracer /data/logs/ /home/developer/path_tracer.yml +// +// +// # Sample YAML configuration file: +// +// rtf: 4.0 +// incorrect_report_color: +// ambient: +// r: 1.0 +// g: 0.0 +// b: 0.0 +// a: 0.5 +// diffuse: +// r: 1.0 +// g: 0.0 +// b: 0.0 +// a: 0.5 +// emissive: +// r: 0.2 +// g: 0.0 +// b: 0.0 +// a: 0.1 +// correct_report_color: +// ambient: +// r: 0.0 +// g: 1.0 +// b: 0.0 +// a: 1.0 +// diffuse: +// r: 0.0 +// g: 1.0 +// b: 0.0 +// a: 1.0 +// emissive: +// r: 0.0 +// g: 1.0 +// b: 0.0 +// a: 1.0 +// artficat_location_color: +// ambient: +// r: 0.0 +// g: 1.0 +// b: 1.0 +// a: 0.5 +// diffuse: +// r: 0.0 +// g: 1.0 +// b: 1.0 +// a: 0.5 +// emissive: +// r: 0.0 +// g: 0.2 +// b: 0.2 +// a: 0.5 +// robot_colors: +// - color: +// ambient: +// r: 0.6 +// g: 0.0 +// b: 1.0 +// a: 1.0 +// diffuse: +// r: 0.6 +// g: 0.0 +// b: 1.0 +// a: 1.0 +// emissive: +// r: 0.6 +// g: 0.0 +// b: 1.0 +// a: 1.0 +// - color: +// ambient: +// r: 0.678 +// g: 0.2 +// b: 1.0 +// a: 1.0 +// diffuse: +// r: 0.678 +// g: 0.2 +// b: 1.0 +// a: 1.0 +// emissive: +// r: 0.678 +// g: 0.2 +// b: 1.0 +// a: 1.0 // Forward declaration. class Processor; @@ -49,6 +135,38 @@ enum DataType REPORT = 1 }; +/// \brief Color properties for a marker. +class MarkerColor +{ + /// \brief Default constructor. + public: MarkerColor() = default; + + /// \brief Create from YAML. + /// \param[in] _node YAML node. + public: MarkerColor(const YAML::Node &_node); + + /// \brief Copy constructor + /// \param[in] _clr MarkerColor to copy. + public: MarkerColor(const MarkerColor &_clr); + + /// \brief Constructor + /// \param[in] _ambient Ambient color + /// \param[in] _diffuse Diffuse color + /// \param[in] _emissive Emissive color + public: MarkerColor(const ignition::math::Color &_ambient, + const ignition::math::Color &_diffuse, + const ignition::math::Color &_emissive); + + /// \brief The ambient value + public: ignition::math::Color ambient; + + /// \brief The diffuse value + public: ignition::math::Color diffuse; + + /// \brief The emissive value + public: ignition::math::Color emissive; +}; + /// \brief Base class for data visualization class Data { @@ -90,8 +208,9 @@ class Processor /// \brief Constructor, which also kicks off all of the data /// visualization. /// \param[in] _path Path to the directory containing the log files. - /// \param[in] _rtf Real time factor for playback. - public: Processor(const std::string &_path, double _rtf); + /// \param[in] _configPath Path to the configuration file, or empty string. + public: Processor(const std::string &_path, + const std::string &_configPath = ""); /// \brief Destructor public: ~Processor(); @@ -120,7 +239,7 @@ class Processor /// \param[in] _pos Position of the visual marker. /// \param[in] _type Type of the visual marker. /// \param[in] _scale scale of the visual marker. - public: void SpawnMarker(ignition::math::Color &_color, + public: void SpawnMarker(MarkerColor &_color, const ignition::math::Vector3d &_pos, ignition::msgs::Marker::Type _type, const ignition::math::Vector3d &_scale); @@ -129,30 +248,13 @@ class Processor public: void Cb(const ignition::msgs::Pose_V &_msg); /// \brief Mapping of robot name to color - public: std::map robots; + public: std::map robots; + + /// \brief The colors used to represent artifacts and reports. + public: std::map artifactColors; /// \brief The colors used to represent each robot. - public: std::vector colors = - { - // Bad Report locations - {1.0, 0.0, 0.0, 0.1}, - - // Good Artifact locations - {0.0, 1.0, 0.0, 0.1}, - - // Artifact locations. - {0.0, 1.0, 1.0, 0.1}, - - // Robot colors - {153/255.0, 0, 1}, - {173/255.0, 51/255.0, 1}, - {194/255.0, 102/255.0, 1}, - {214/255.0, 153/255.0, 1}, - - {1, 153/255.0, 0}, - {1, 173/255.0, 51/255.0}, - {1, 194/255.0, 102/255.0}, - }; + public: std::vector robotColors; /// \brief Last pose of a robot. This is used to reduce the number of markers. private: std::map prevPose; From 46a648933c73f3f6c430158cbd80c87282c65c70 Mon Sep 17 00:00:00 2001 From: Nate Koenig Date: Mon, 21 Sep 2020 09:31:53 -0700 Subject: [PATCH 4/5] Update to use DRY suggestion Signed-off-by: Nate Koenig --- subt_ign/src/path_tracer.cc | 84 +++++++++++-------------------------- 1 file changed, 24 insertions(+), 60 deletions(-) diff --git a/subt_ign/src/path_tracer.cc b/subt_ign/src/path_tracer.cc index 849f1a14..16208df0 100644 --- a/subt_ign/src/path_tracer.cc +++ b/subt_ign/src/path_tracer.cc @@ -17,76 +17,40 @@ #include "path_tracer.hh" ////////////////////////////////////////////////// -MarkerColor::MarkerColor(const YAML::Node &_node) +// Load a color from YAML helper function. +// \param[in] _node YAML node that contains color information +// \param[in] _def Default color value that is used if a color property is +// missing. +ignition::math::Color loadColor(const YAML::Node &_node, double _def = 1.0) { - if (_node["ambient"]) - { - if (_node["ambient"]["r"]) - this->ambient.R(_node["ambient"]["r"].as()); - else - this->ambient.R(1.0); + ignition::math::Color clr(_def, _def, _def, _def); - if (_node["ambient"]["g"]) - this->ambient.G(_node["ambient"]["g"].as()); - else - this->ambient.G(1.0); + if (_node["r"]) + clr.R(_node["r"].as()); - if (_node["ambient"]["b"]) - this->ambient.B(_node["ambient"]["b"].as()); - else - this->ambient.B(1.0); + if (_node["g"]) + clr.G(_node["g"].as()); - if (_node["ambient"]["a"]) - this->ambient.A(_node["ambient"]["a"].as()); - else - this->ambient.A(1.0); - } + if (_node["b"]) + clr.B(_node["b"].as()); - if (_node["diffuse"]) - { - if (_node["diffuse"]["r"]) - this->diffuse.R(_node["diffuse"]["r"].as()); - else - this->diffuse.R(1.0); + if (_node["a"]) + clr.A(_node["a"].as()); - if (_node["diffuse"]["g"]) - this->diffuse.G(_node["diffuse"]["g"].as()); - else - this->diffuse.G(1.0); + return clr; +} - if (_node["diffuse"]["b"]) - this->diffuse.B(_node["diffuse"]["b"].as()); - else - this->diffuse.B(1.0); +////////////////////////////////////////////////// +MarkerColor::MarkerColor(const YAML::Node &_node) +{ + if (_node["ambient"]) + this->ambient = loadColor(_node["ambient"]); - if (_node["diffuse"]["a"]) - this->diffuse.A(_node["diffuse"]["a"].as()); - else - this->diffuse.A(1.0); - } + if (_node["diffuse"]) + this->diffuse = loadColor(_node["diffuse"]); if (_node["emissive"]) - { - if (_node["emissive"]["r"]) - this->emissive.R(_node["emissive"]["r"].as()); - else - this->emissive.R(1.0); - - if (_node["emissive"]["g"]) - this->emissive.G(_node["emissive"]["g"].as()); - else - this->emissive.G(1.0); - - if (_node["emissive"]["b"]) - this->emissive.B(_node["emissive"]["b"].as()); - else - this->emissive.B(1.0); - - if (_node["emissive"]["a"]) - this->emissive.A(_node["emissive"]["a"].as()); - else - this->emissive.A(1.0); - } + this->emissive = loadColor(_node["emissive"]); } ////////////////////////////////////////////////// From d79dccc2d854cbd17b808d1b4e13e3da88daa3bd Mon Sep 17 00:00:00 2001 From: Nate Koenig Date: Mon, 21 Sep 2020 12:32:51 -0700 Subject: [PATCH 5/5] Update subt_ign/src/path_tracer.cc Co-authored-by: Michael Carroll --- subt_ign/src/path_tracer.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/subt_ign/src/path_tracer.cc b/subt_ign/src/path_tracer.cc index a22b3d51..01235509 100644 --- a/subt_ign/src/path_tracer.cc +++ b/subt_ign/src/path_tracer.cc @@ -79,10 +79,12 @@ Processor::Processor(const std::string &_path, const std::string &_configPath) { cfg = YAML::LoadFile(_configPath); } - catch (...) + catch (YAML::Exception &ex) { std::cerr << "Unable to load configuration file[" - << _configPath << "]\n"; + << _configPath << "]: " + << "error at line " << ex.mark.line + 1 << ", column " + << ex.mark.column + 1 << ": " << ex.msg << "\n"; } } else