@@ -207,19 +207,28 @@ void ContainerBasePrivate::liftSolution(const SolutionBasePtr& solution, const I
207207 const InterfaceState* internal_to, InterfaceState* new_from,
208208 InterfaceState* new_to) {
209209 // NOLINTNEXTLINE(readability-identifier-naming)
210- auto findExternal = [this ](const InterfaceState* internal,
211- const InterfaceState* replacement) -> const InterfaceState* {
210+ auto findExternal = [this ](const InterfaceState* internal) -> const InterfaceState* {
212211 auto it = internalToExternalMap ().find (internal);
213- if (it != internalToExternalMap ().end () && (!replacement || &*it-> second == replacement) ) {
212+ if (it != internalToExternalMap ().end ()) {
214213 return &*it->second ;
215214 }
216215
217216 return nullptr ;
218217 };
219218
220219 // external states, nullptr if they don't exist yet
221- const InterfaceState* external_from{ findExternal (internal_from, new_from) };
222- const InterfaceState* external_to{ findExternal (internal_to, new_to) };
220+ const InterfaceState* external_from{ findExternal (internal_from) };
221+ const InterfaceState* external_to{ findExternal (internal_to) };
222+
223+ // TODO(v4hn) rethink this. ComputeIK is exactly this case. Do I want to support an n:m mapping from internal to
224+ // external?
225+ if ((new_from && external_from && external_from != new_from) || (new_to && external_to && external_to != new_to)) {
226+ ROS_ERROR_STREAM_NAMED (" Container" , " Container '" << name_ << " ' tried to lift a modified solution from child '"
227+ << solution->creator ()->name ()
228+ << " ', but a different one already exists. Children's "
229+ " InterfaceStates can only ever match one " );
230+ return ;
231+ }
223232
224233 // computeCost
225234 // If there are no external states known yet, we can pass internal_{from/to} here
0 commit comments