initialize default CostTerm in constructor

It seems to be too fragile to rely on `init` being called.
On the other hand we should really enforce this anyway. -.-
This commit is contained in:
v4hn 2020-09-17 22:56:19 +02:00
parent 687fcb6a6d
commit 5d0fd57754

View File

@ -97,7 +97,12 @@ std::ostream& operator<<(std::ostream& os, const InitStageException& e) {
} }
StagePrivate::StagePrivate(Stage* me, const std::string& name) StagePrivate::StagePrivate(Stage* me, const std::string& name)
: me_(me), name_(name), total_compute_time_{}, parent_(nullptr), introspection_(nullptr) {} : me_{ me }
, name_{ name }
, cost_term_{ std::make_unique<CostTerm>() }
, total_compute_time_{}
, parent_{ nullptr }
, introspection_{ nullptr } {}
InterfaceFlags StagePrivate::interfaceFlags() const { InterfaceFlags StagePrivate::interfaceFlags() const {
InterfaceFlags f; InterfaceFlags f;
@ -301,10 +306,6 @@ void Stage::reset() {
void Stage::init(const moveit::core::RobotModelConstPtr& /* robot_model */) { void Stage::init(const moveit::core::RobotModelConstPtr& /* robot_model */) {
auto impl = pimpl(); auto impl = pimpl();
// add a default cost term if none was given by the user
if (!impl->cost_term_)
impl->cost_term_ = std::make_unique<CostTerm>();
// init properties once from parent // init properties once from parent
impl->properties_.reset(); impl->properties_.reset();
if (impl->parent()) { if (impl->parent()) {