From 5d0fd577549a12ceb8cc65d7827b94c998330d18 Mon Sep 17 00:00:00 2001 From: v4hn Date: Thu, 17 Sep 2020 22:56:19 +0200 Subject: [PATCH] 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. -.- --- core/src/stage.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/core/src/stage.cpp b/core/src/stage.cpp index 3d9c6f0e..58abd555 100644 --- a/core/src/stage.cpp +++ b/core/src/stage.cpp @@ -97,7 +97,12 @@ std::ostream& operator<<(std::ostream& os, const InitStageException& e) { } 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() } + , total_compute_time_{} + , parent_{ nullptr } + , introspection_{ nullptr } {} InterfaceFlags StagePrivate::interfaceFlags() const { InterfaceFlags f; @@ -301,10 +306,6 @@ void Stage::reset() { void Stage::init(const moveit::core::RobotModelConstPtr& /* robot_model */) { 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(); - // init properties once from parent impl->properties_.reset(); if (impl->parent()) {