mirror of
https://github.com/moveit/moveit_task_constructor.git
synced 2025-11-04 14:49:57 +08:00
improve property debugging
This commit is contained in:
parent
cbb2cd69f7
commit
beffe27987
@ -128,7 +128,8 @@ public:
|
|||||||
/// get default value
|
/// get default value
|
||||||
const boost::any& defaultValue() const { return default_; }
|
const boost::any& defaultValue() const { return default_; }
|
||||||
/// serialize current value
|
/// serialize current value
|
||||||
std::string serialize() const;
|
std::string serialize(const boost::any& value) const;
|
||||||
|
std::string serialize() const { return serialize(value()); }
|
||||||
|
|
||||||
/// get description text
|
/// get description text
|
||||||
const std::string& description() const { return description_; }
|
const std::string& description() const { return description_; }
|
||||||
|
|||||||
@ -254,7 +254,14 @@ void ContainerBase::init(const moveit::core::RobotModelConstPtr& robot_model)
|
|||||||
// recursively init all children and accumulate errors
|
// recursively init all children and accumulate errors
|
||||||
InitStageException errors;
|
InitStageException errors;
|
||||||
for (auto& child : children) {
|
for (auto& child : children) {
|
||||||
try { child->init(robot_model); } catch (InitStageException &e) { errors.append(e); }
|
try { child->init(robot_model); }
|
||||||
|
catch (const Property::error &e) {
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << e.what();
|
||||||
|
pimpl()->composePropertyErrorMsg(e.name(), oss);
|
||||||
|
errors.push_back(*child, oss.str());
|
||||||
|
}
|
||||||
|
catch (InitStageException &e) { errors.append(e); }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (errors) throw errors;
|
if (errors) throw errors;
|
||||||
|
|||||||
@ -39,6 +39,7 @@
|
|||||||
#include <moveit/task_constructor/properties.h>
|
#include <moveit/task_constructor/properties.h>
|
||||||
#include <boost/format.hpp>
|
#include <boost/format.hpp>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <ros/console.h>
|
||||||
|
|
||||||
namespace moveit {
|
namespace moveit {
|
||||||
namespace task_constructor {
|
namespace task_constructor {
|
||||||
@ -83,9 +84,9 @@ void Property::reset()
|
|||||||
initialized_from_ = -1; // set to max value
|
initialized_from_ = -1; // set to max value
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Property::serialize() const {
|
std::string Property::serialize(const boost::any& v) const {
|
||||||
if (!serialize_) return "";
|
if (!serialize_ || v.empty()) return "";
|
||||||
return serialize_(value());
|
return serialize_(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Property::initsFrom(Property::SourceFlags source) const
|
bool Property::initsFrom(Property::SourceFlags source) const
|
||||||
@ -218,6 +219,8 @@ void PropertyMap::performInitFrom(Property::SourceFlags source, const PropertyMa
|
|||||||
} catch (const Property::undefined&) {
|
} catch (const Property::undefined&) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ROS_DEBUG_STREAM_NAMED("Properties", pair.first << ": " << p.initialized_from_ <<
|
||||||
|
" -> " << source << ": " << p.serialize(value));
|
||||||
p.setCurrentValue(value);
|
p.setCurrentValue(value);
|
||||||
p.initialized_from_ = source;
|
p.initialized_from_ = source;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -222,6 +222,7 @@ void Stage::init(const moveit::core::RobotModelConstPtr& robot_model)
|
|||||||
impl->properties_.reset();
|
impl->properties_.reset();
|
||||||
if (impl->parent()) {
|
if (impl->parent()) {
|
||||||
try {
|
try {
|
||||||
|
ROS_DEBUG_STREAM_NAMED("Properties", "init '" << name() << "'");
|
||||||
impl->properties_.performInitFrom(PARENT, impl->parent()->properties());
|
impl->properties_.performInitFrom(PARENT, impl->parent()->properties());
|
||||||
} catch (const Property::error &e) {
|
} catch (const Property::error &e) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
@ -299,7 +300,7 @@ void StagePrivate::composePropertyErrorMsg(const std::string& property_name, std
|
|||||||
os << "declared, but undefined";
|
os << "declared, but undefined";
|
||||||
|
|
||||||
if (p.initsFrom(Stage::PARENT)) os << ", inherits from parent";
|
if (p.initsFrom(Stage::PARENT)) os << ", inherits from parent";
|
||||||
else if (p.initsFrom(Stage::PARENT)) os << ", initializes from interface";
|
if (p.initsFrom(Stage::INTERFACE)) os << ", initializes from interface";
|
||||||
} catch (const Property::undeclared &e) {
|
} catch (const Property::undeclared &e) {
|
||||||
os << "undeclared";
|
os << "undeclared";
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user