Fix error when resolving possible objects to pick while some are carried by other robots #313
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When picking objects with multiple robots in a world, it is likely, that some are currently carried and do not reside on locations anymore. Since
Robot
doesn't have aparent
attribute, an error is raised when checking each object's location.This PR fixes this issue by checking if the parent has an attribute called
parent
effectively verifying that it's not a robot. Consequently, objects can not be picked when they are carried by robots.Note
I've also tried to verify using
isinstance(obj.parent, Robot)
but this requires to importRobot
and causes a circular import error when done on top. It's also possible to import it inside theresolve_to_object
method, but I guess this solution is sufficient.