mirror of
https://github.com/moveit/moveit_task_constructor.git
synced 2025-11-04 14:49:57 +08:00
fix computeCost interface (again)
Fixes the missing creator pointer introduced in a6a23d3775
This commit is contained in:
parent
629d266fbc
commit
f4fb8c6f71
@ -197,12 +197,12 @@ private:
|
|||||||
class CostTerm;
|
class CostTerm;
|
||||||
class StagePrivate;
|
class StagePrivate;
|
||||||
class ContainerBasePrivate;
|
class ContainerBasePrivate;
|
||||||
struct TmpInterfaceStateProvider;
|
struct TmpSolutionContext;
|
||||||
/// abstract base class for solutions (primitive and sequences)
|
/// abstract base class for solutions (primitive and sequences)
|
||||||
class SolutionBase
|
class SolutionBase
|
||||||
{
|
{
|
||||||
friend ContainerBasePrivate;
|
friend ContainerBasePrivate;
|
||||||
friend TmpInterfaceStateProvider;
|
friend TmpSolutionContext;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~SolutionBase() = default;
|
virtual ~SolutionBase() = default;
|
||||||
|
|||||||
@ -234,19 +234,21 @@ void StagePrivate::newSolution(const SolutionBasePtr& solution) {
|
|||||||
// To solve the chicken-egg problem in computeCost() and provide proper states at both ends of the solution,
|
// To solve the chicken-egg problem in computeCost() and provide proper states at both ends of the solution,
|
||||||
// this class temporarily sets the new interface states w/o registering the solution yet.
|
// this class temporarily sets the new interface states w/o registering the solution yet.
|
||||||
// On destruction the start/end states are reset again.
|
// On destruction the start/end states are reset again.
|
||||||
struct TmpInterfaceStateProvider
|
struct TmpSolutionContext
|
||||||
{
|
{
|
||||||
SolutionBase* solution_;
|
SolutionBase& solution_;
|
||||||
TmpInterfaceStateProvider(SolutionBase& solution, const InterfaceState& from, const InterfaceState& to)
|
TmpSolutionContext(SolutionBase& solution, Stage* creator, const InterfaceState& from, const InterfaceState& to)
|
||||||
: solution_(&solution) {
|
: solution_(solution) {
|
||||||
assert(solution_->start_ == nullptr);
|
assert(solution_.start_ == nullptr);
|
||||||
assert(solution_->end_ == nullptr);
|
assert(solution_.end_ == nullptr);
|
||||||
solution_->start_ = &from;
|
solution_.start_ = &from;
|
||||||
solution_->end_ = &to;
|
solution_.end_ = &to;
|
||||||
|
solution_.creator_ = creator;
|
||||||
}
|
}
|
||||||
~TmpInterfaceStateProvider() {
|
~TmpSolutionContext() {
|
||||||
solution_->start_ = nullptr;
|
solution_.start_ = nullptr;
|
||||||
solution_->end_ = nullptr;
|
solution_.end_ = nullptr;
|
||||||
|
solution_.creator_ = nullptr;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
void StagePrivate::computeCost(const InterfaceState& from, const InterfaceState& to, SolutionBase& solution) {
|
void StagePrivate::computeCost(const InterfaceState& from, const InterfaceState& to, SolutionBase& solution) {
|
||||||
@ -256,7 +258,7 @@ void StagePrivate::computeCost(const InterfaceState& from, const InterfaceState&
|
|||||||
|
|
||||||
// Temporarily set start/end states of the solution w/o actually registering the solution with them
|
// Temporarily set start/end states of the solution w/o actually registering the solution with them
|
||||||
// This allows CostTerms to compute costs based on the InterfaceState.
|
// This allows CostTerms to compute costs based on the InterfaceState.
|
||||||
TmpInterfaceStateProvider tip(solution, from, to);
|
TmpSolutionContext tip(solution, me(), from, to);
|
||||||
|
|
||||||
std::string comment;
|
std::string comment;
|
||||||
assert(cost_term_);
|
assert(cost_term_);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user