-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added TestableOutcomeClass. * Added NonCollidingOutcome.hpp * Include TestableOutcome in Testable. Fix TestableOutcome to make it work. * Updated Testable isSatisfied signature and changed *bunch* of signatures in derived classes. [TODO]: Figure out the unused param warnings. * Changed NonCollidingOutcome name to reflect CollisionFree name change. Included it in CollisionFree. * Started CollisionFreeOutcome.cpp. Small changed to make it build once it was added as a source file. * Wrote toString for CollisionFreeOutcome. * Made CollisionFree fill _outcome on a collision (if not nullptr). * Fixed test files to make tests build. Will run make format in just a sec! * Added testing for CollisionFreeOutcome. * Use move semantics in CollisionFreeOutcome toString method. * Ran make format. * Adressed nits from @jslee02. Moving to squish those unused param warnings next. * Silence unused param warning, ran make format again. * Used dynamic_cast in CollisionFree when populating outcome fields. Barf if type mismatch. * Modify CollisionFreeOutcome to take Contact references as inputs as per feedback from @brianhou. Added a method to get the name from a CollisionObject. * Move include of sstream into .cpp file instead of header. * Made tests take advantage of programatic acess to data. Required adding a getter for Contact vectors in CollisionFreeOutcome and making getCollisionObjectName public. * Made getter methods for Contact vectors const because they can be. * Address nits from @jslee02. * Two small nits I missed in the last commit. * Aaaaaand, one more! * Implemented createOutcome functionality in Testable base class. * Use auto collisionOutcome as per request of @brianhou. * Moved dynamic cast for outcome in CollisionFree. * Added method to clear CollisionFreeOutcome. Use this method in CollisionFree so outcome objects can be reused. Also added stuff to test to make sure outcomes can actually be reused. * Fixed directory placement of outcome classes. Renamed DummyOutcome ---> DefaultOutcome. * Added simple functionality to DefaultOutcome. * Responded to most recent review comments by making every Testable derivative class implement createOutcome (createOutcome in Testable is now a pure virtual function). Also made each implementation of isSatisfied in any Testable derivative class populate the isSatisfied field of DefaultOutcome. * Run make format. * [WIP] Refactor castic logic into helper, and use this in CollisionFree. Will stamp this into every other class now. * [WIP] Replace redundant casting login in different Testables with helper. * [WIP] Mop up some extra casts that were missed prior. * Added documentation. * Make CollisionFree a friend class of CollisionFreeOutcome, use Eigen alocator. * Modify FrameTestable to "pass through" outcome object to mPoseConstraint. * Rename DefaultOutcome ---> DefaultTestableOutcome. Final clean up as well. * Address @mkoval's comments. * Update nits: comment and renamed dynamic_cast_if_present to dynamic_cast_or_throw. * Undo the use of the Eigen allocator in CollisionFreeOutcome. * Update CHANGELOG.md
- Loading branch information
1 parent
9667844
commit 7c59428
Showing
29 changed files
with
618 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#ifndef AIKIDO_CONSTRAINT_COLLISIONFREEOUTCOME_HPP_ | ||
#define AIKIDO_CONSTRAINT_COLLISIONFREEOUTCOME_HPP_ | ||
|
||
#include <vector> | ||
#include "TestableOutcome.hpp" | ||
#include "dart/collision/CollisionObject.hpp" | ||
#include "dart/collision/Contact.hpp" | ||
#include "dart/dynamics/BodyNode.hpp" | ||
#include "dart/dynamics/ShapeFrame.hpp" | ||
#include "dart/dynamics/ShapeNode.hpp" | ||
|
||
namespace aikido { | ||
namespace constraint { | ||
|
||
/// TestableOutcome derivative class intended as (optional) input to isSatisfied | ||
/// method in CollisionFree class. | ||
class CollisionFreeOutcome : public TestableOutcome | ||
{ | ||
friend class CollisionFree; | ||
|
||
public: | ||
/// Documentation inherited. | ||
bool isSatisfied() const override; | ||
|
||
/// Returns a string with each pair of CollisionObject names on a separate | ||
/// line. Each pair is also marked as being a normal collision or self | ||
/// collision. | ||
std::string toString() const override; | ||
|
||
/// Clears this outcome object. Useful in the event that a CollisionFree | ||
/// object is passed to the isSatisfied() method of more than one constraint | ||
/// object. | ||
void clear(); | ||
|
||
/// Return a copy of the vector storing the Contact objects from pairwise | ||
/// collisions. | ||
std::vector<dart::collision::Contact> getPairwiseContacts() const; | ||
|
||
/// Return a copy of the vector storing the Contact objects from self | ||
/// collisions. | ||
std::vector<dart::collision::Contact> getSelfContacts() const; | ||
|
||
/// Gets the name of a CollisionObject. The name returned is that of the | ||
/// corresponding BodyNode (if possible). If not, the name of the ShapeFrame | ||
/// is returned instead. This is a helper for toString(). | ||
/// \param[in] object object pointer to CollisionObject we want the name of. | ||
std::string getCollisionObjectName( | ||
const dart::collision::CollisionObject* object) const; | ||
|
||
protected: | ||
/// Holds Contact objects from pairwise collisions. | ||
std::vector<dart::collision::Contact> mPairwiseContacts; | ||
|
||
/// Holds Contact objects from self collisions. | ||
std::vector<dart::collision::Contact> mSelfContacts; | ||
}; | ||
|
||
} // namespace constraint | ||
} // namespace aikido | ||
|
||
#endif // AIKIDO_CONSTRAINT_COLLISIONFREEOUTCOME_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#ifndef AIKIDO_CONSTRAINT_DEFAULTTESTABLEOUTCOME_HPP_ | ||
#define AIKIDO_CONSTRAINT_DEFAULTTESTABLEOUTCOME_HPP_ | ||
|
||
#include "TestableOutcome.hpp" | ||
|
||
namespace aikido { | ||
namespace constraint { | ||
|
||
/// Simple default TestableOutcome derivative class. An instance of this class | ||
/// is returned when createOutcome() is called on an instance of a class that | ||
/// inherits Testable, but has no corresponding TestableOutcome derivative | ||
/// implemented. | ||
class DefaultTestableOutcome : public TestableOutcome | ||
{ | ||
public: | ||
/// Returns whether the isSatisfied method this object was passed to | ||
/// returned true or false. | ||
bool isSatisfied() const override; | ||
|
||
/// String representation of isSatisfied return value. | ||
std::string toString() const override; | ||
|
||
/// Used by the isSatisfied this outcome object is passed to set whether the | ||
/// constraint was satisifed or not. | ||
/// \param[in] satisfiedFlag whether the constraint was satisfied or not. | ||
void setSatisfiedFlag(bool satisfiedFlag); | ||
|
||
protected: | ||
bool mSatisfiedFlag; | ||
}; | ||
|
||
} // namespace constraint | ||
} // namespace aikido | ||
|
||
#endif // AIKIDO_CONSTRAINT_DEFAULTTESTABLEOUTCOME_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#ifndef AIKIDO_CONSTRAINT_TESTABLEOUTCOME_HPP_ | ||
#define AIKIDO_CONSTRAINT_TESTABLEOUTCOME_HPP_ | ||
|
||
#include <string> | ||
|
||
namespace aikido { | ||
namespace constraint { | ||
|
||
/// Base class for constraint outcomes. At a high level, each constraint can | ||
/// have a corresponding derivative of TestableOutcome that is passed as an | ||
/// optional parameter to its isSatisfied method. This allow programmatic access | ||
/// to data on why the constraint was (or was not) satisfied. | ||
class TestableOutcome | ||
{ | ||
public: | ||
/// Returns true if isSatisfied call this outcome object was passed to | ||
/// returned true. False otherwise. | ||
virtual bool isSatisfied() const = 0; | ||
|
||
/// String representation of the outcome. Provides useful, programmatic | ||
/// access to debug information. | ||
virtual std::string toString() const = 0; | ||
}; | ||
|
||
/// Helper function. Avoids repeating logic for casting TestableOutcome | ||
/// pointers down to pointers for a derivative class. Mostly used in the | ||
/// isSatisfied methods of classes that inherit Testable. | ||
template <class Child> | ||
Child* dynamic_cast_or_throw(TestableOutcome* outcome); | ||
|
||
} // namespace constraint | ||
} // namespace aikido | ||
|
||
#include "detail/TestableOutcome-impl.hpp" | ||
|
||
#endif // AIKIDO_CONSTRAINT_TESTABLEOUTCOME_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include <sstream> | ||
#include <stdexcept> | ||
#include <typeinfo> | ||
|
||
namespace aikido { | ||
namespace constraint { | ||
|
||
//============================================================================== | ||
template <class Child> | ||
Child* dynamic_cast_or_throw(TestableOutcome* outcome) | ||
{ | ||
if (!outcome) | ||
return nullptr; | ||
|
||
auto childPtr = dynamic_cast<Child*>(outcome); | ||
if (!childPtr) | ||
{ | ||
std::stringstream message; | ||
message << "TestableOutcome pointer is not of type " << typeid(Child).name() | ||
<< "."; | ||
throw std::invalid_argument(message.str()); | ||
} | ||
|
||
return childPtr; | ||
} | ||
|
||
} // namespace constraint | ||
} // namespace aikido |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.