Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release-6.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
jslee02 committed Jul 26, 2016
2 parents ed7ec81 + ef41e05 commit 8c68d52
Show file tree
Hide file tree
Showing 23 changed files with 128 additions and 51 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

### DART 6.1.0 (2016-XX-XX)

* Dynamics

* Added `computeLagrangian()` to `MetaSkeleton` and `BodyNode`: [#746](https://github.com/dartsim/dart/pull/746)

* Misc improvements and bug fixes

* Added `virtual Shape::getType()` and deprecated `ShapeType Shpae::getShapeType()`: [#724](https://github.com/dartsim/dart/pull/724)
Expand All @@ -10,6 +14,7 @@

* Collision detection

* Added support of FCL 0.5.0: [#749](https://github.com/dartsim/dart/pull/749)
* Added warnings for unsupported shape pairs of DARTCollisionDetector: [#722](https://github.com/dartsim/dart/pull/722)

* Misc improvements and bug fixes
Expand Down
10 changes: 3 additions & 7 deletions dart/collision/fcl/FCLCollisionDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,6 @@ fcl::BVHModel<BV>* createEllipsoid(float _sizeX, float _sizeY, float _sizeZ)
return model;
}

#if FCL_MAJOR_MINOR_VERSION_AT_MOST(0,4)

//==============================================================================
template<class BV>
fcl::BVHModel<BV>* createCylinder(double _baseRadius, double _topRadius,
Expand Down Expand Up @@ -536,8 +534,6 @@ fcl::BVHModel<BV>* createCylinder(double _baseRadius, double _topRadius,
return model;
}

#endif

//==============================================================================
template<class BV>
fcl::BVHModel<BV>* createMesh(float _scaleX, float _scaleY, float _scaleZ,
Expand Down Expand Up @@ -782,7 +778,7 @@ std::unique_ptr<CollisionObject> FCLCollisionDetector::createCollisionObject(
}

//==============================================================================
boost::shared_ptr<fcl::CollisionGeometry>
fcl_shared_ptr<fcl::CollisionGeometry>
FCLCollisionDetector::claimFCLCollisionGeometry(
const dynamics::ConstShapePtr& shape)
{
Expand All @@ -805,7 +801,7 @@ FCLCollisionDetector::claimFCLCollisionGeometry(
}

//==============================================================================
boost::shared_ptr<fcl::CollisionGeometry>
fcl_shared_ptr<fcl::CollisionGeometry>
FCLCollisionDetector::createFCLCollisionGeometry(
const dynamics::ConstShapePtr& shape,
FCLCollisionDetector::PrimitiveShape type,
Expand Down Expand Up @@ -930,7 +926,7 @@ FCLCollisionDetector::createFCLCollisionGeometry(
geom = createEllipsoid<fcl::OBBRSS>(0.1, 0.1, 0.1);
}

return boost::shared_ptr<fcl::CollisionGeometry>(geom, deleter);
return fcl_shared_ptr<fcl::CollisionGeometry>(geom, deleter);
}

//==============================================================================
Expand Down
7 changes: 4 additions & 3 deletions dart/collision/fcl/FCLCollisionDetector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <fcl/collision_object.h>
#include <boost/weak_ptr.hpp> // This should be removed once we migrate to fcl 0.5
#include "dart/collision/CollisionDetector.hpp"
#include "dart/collision/fcl/FCLTypes.hpp"

namespace dart {
namespace collision {
Expand Down Expand Up @@ -130,7 +131,7 @@ class FCLCollisionDetector : public CollisionDetector

/// Return fcl::CollisionGeometry associated with give Shape. New
/// fcl::CollisionGeome will be created if it hasn't created yet.
boost::shared_ptr<fcl::CollisionGeometry> claimFCLCollisionGeometry(
fcl_shared_ptr<fcl::CollisionGeometry> claimFCLCollisionGeometry(
const dynamics::ConstShapePtr& shape);

protected:
Expand Down Expand Up @@ -162,15 +163,15 @@ class FCLCollisionDetector : public CollisionDetector

/// Create fcl::CollisionGeometry with the custom deleter
/// FCLCollisionGeometryDeleter
boost::shared_ptr<fcl::CollisionGeometry> createFCLCollisionGeometry(
fcl_shared_ptr<fcl::CollisionGeometry> createFCLCollisionGeometry(
const dynamics::ConstShapePtr& shape,
FCLCollisionDetector::PrimitiveShape type,
const FCLCollisionGeometryDeleter& deleter);

private:

using ShapeMap = std::map<dynamics::ConstShapePtr,
boost::weak_ptr<fcl::CollisionGeometry>>;
fcl_weak_ptr<fcl::CollisionGeometry>>;
// TODO(JS): FCL replaced all the use of boost in version 0.5. Once we migrate
// to 0.5 or greater, this also should be changed to
// std::weak_ptr<fcl::CollisionGeometry>
Expand Down
2 changes: 1 addition & 1 deletion dart/collision/fcl/FCLCollisionObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const fcl::CollisionObject* FCLCollisionObject::getFCLCollisionObject() const
FCLCollisionObject::FCLCollisionObject(
CollisionDetector* collisionDetector,
const dynamics::ShapeFrame* shapeFrame,
const boost::shared_ptr<fcl::CollisionGeometry>& fclCollGeom)
const fcl_shared_ptr<fcl::CollisionGeometry>& fclCollGeom)
: CollisionObject(collisionDetector, shapeFrame),
mFCLCollisionObjectUserData(new UserData(this)),
mFCLCollisionObject(new fcl::CollisionObject(fclCollGeom))
Expand Down
3 changes: 2 additions & 1 deletion dart/collision/fcl/FCLCollisionObject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

#include <fcl/collision_object.h>
#include "dart/collision/CollisionObject.hpp"
#include "dart/collision/fcl/FCLTypes.hpp"

namespace dart {
namespace collision {
Expand Down Expand Up @@ -64,7 +65,7 @@ class FCLCollisionObject : public CollisionObject
/// Constructor
FCLCollisionObject(CollisionDetector* collisionDetector,
const dynamics::ShapeFrame* shapeFrame,
const boost::shared_ptr<fcl::CollisionGeometry>& fclCollGeom);
const fcl_shared_ptr<fcl::CollisionGeometry>& fclCollGeom);

// Documentation inherited
void updateEngineData() override;
Expand Down
8 changes: 8 additions & 0 deletions dart/collision/fcl/FCLTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@
(FCL_MAJOR_VERSION < x || (FCL_MAJOR_VERSION <= x && \
(FCL_MINOR_VERSION < y || (FCL_MINOR_VERSION <= y))))

#if FCL_VERSION_AT_LEAST(0,5,0)
template <class T> using fcl_shared_ptr = std::shared_ptr<T>;
template <class T> using fcl_weak_ptr = std::weak_ptr<T>;
#else
template <class T> using fcl_shared_ptr = boost::shared_ptr<T>;
template <class T> using fcl_weak_ptr = boost::weak_ptr<T>;
#endif

namespace dart {
namespace collision {

Expand Down
25 changes: 22 additions & 3 deletions dart/dynamics/BodyNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1901,18 +1901,37 @@ const Eigen::Vector6d& BodyNode::getConstraintImpulse() const
return mConstraintImpulse;
}

//==============================================================================
double BodyNode::computeLagrangian(const Eigen::Vector3d& gravity) const
{
return computeKineticEnergy() - computePotentialEnergy(gravity);
}

//==============================================================================
double BodyNode::getKineticEnergy() const
{
return computeKineticEnergy();
}

//==============================================================================
double BodyNode::computeKineticEnergy() const
{
const Eigen::Vector6d& V = getSpatialVelocity();
const Eigen::Matrix6d& mI = mAspectProperties.mInertia.getSpatialTensor();
return 0.5 * V.dot(mI * V);
const Eigen::Matrix6d& G = mAspectProperties.mInertia.getSpatialTensor();

return 0.5 * V.dot(G * V);
}

//==============================================================================
double BodyNode::getPotentialEnergy(const Eigen::Vector3d& _gravity) const
{
return -getMass() * getWorldTransform().translation().dot(_gravity);
return computePotentialEnergy(_gravity);
}

//==============================================================================
double BodyNode::computePotentialEnergy(const Eigen::Vector3d& gravity) const
{
return -getMass() * getWorldTransform().translation().dot(gravity);
}

//==============================================================================
Expand Down
12 changes: 12 additions & 0 deletions dart/dynamics/BodyNode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <Eigen/StdVector>

#include "dart/config.hpp"
#include "dart/common/Deprecated.hpp"
#include "dart/common/Signal.hpp"
#include "dart/common/EmbeddedAspect.hpp"
#include "dart/math/Geometry.hpp"
Expand Down Expand Up @@ -802,12 +803,23 @@ class BodyNode :
// Energies
//----------------------------------------------------------------------------

/// Return Lagrangian of this body
double computeLagrangian(const Eigen::Vector3d& gravity) const;

/// Return kinetic energy.
DART_DEPRECATED(6.1)
virtual double getKineticEnergy() const;

/// Return kinetic energy
double computeKineticEnergy() const;

/// Return potential energy.
DART_DEPRECATED(6.1)
virtual double getPotentialEnergy(const Eigen::Vector3d& _gravity) const;

/// Return potential energy.
double computePotentialEnergy(const Eigen::Vector3d& gravity) const;

/// Return linear momentum.
Eigen::Vector3d getLinearMomentum() const;

Expand Down
6 changes: 6 additions & 0 deletions dart/dynamics/Joint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,12 @@ bool Joint::checkSanity(bool _printWarnings) const
return sane;
}

//==============================================================================
double Joint::getPotentialEnergy() const
{
return computePotentialEnergy();
}

//==============================================================================
void Joint::setTransformFromParentBodyNode(const Eigen::Isometry3d& _T)
{
Expand Down
6 changes: 5 additions & 1 deletion dart/dynamics/Joint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,11 @@ class Joint : public virtual common::Subject,
//----------------------------------------------------------------------------

/// Get potential energy
virtual double getPotentialEnergy() const = 0;
DART_DEPRECATED(6.1)
double getPotentialEnergy() const;

/// Compute and return the potential energy
virtual double computePotentialEnergy() const = 0;

//----------------------------------------------------------------------------

Expand Down
18 changes: 18 additions & 0 deletions dart/dynamics/MetaSkeleton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,24 @@ Eigen::VectorXd MetaSkeleton::getJointConstraintImpulses() const
this, "getJointConstraintImpulses");
}

//==============================================================================
double MetaSkeleton::computeLagrangian() const
{
return computeKineticEnergy() - computePotentialEnergy();
}

//==============================================================================
double MetaSkeleton::getKineticEnergy() const
{
return computeKineticEnergy();
}

//==============================================================================
double MetaSkeleton::getPotentialEnergy() const
{
return computePotentialEnergy();
}

//==============================================================================
MetaSkeleton::MetaSkeleton()
: onNameChanged(mNameChangedSignal)
Expand Down
15 changes: 13 additions & 2 deletions dart/dynamics/MetaSkeleton.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,11 +646,22 @@ class MetaSkeleton : public common::Subject
/// Clear the internal forces of the BodyNodes in this MetaSkeleton
virtual void clearInternalForces() = 0;

/// Compute and return Lagrangian of this MetaSkeleton
double computeLagrangian() const;

/// Get the kinetic energy of this MetaSkeleton
DART_DEPRECATED(6.1)
double getKineticEnergy() const;

/// Get the kinetic energy of this MetaSkeleton
virtual double getKineticEnergy() const = 0;
virtual double computeKineticEnergy() const = 0;

/// Get the potential energy of this MetaSkeleton
DART_DEPRECATED(6.1)
double getPotentialEnergy() const;

/// Get the potential energy of this MetaSkeleton
virtual double getPotentialEnergy() const = 0;
virtual double computePotentialEnergy() const = 0;

/// Clear collision flags of the BodyNodes in this MetaSkeleton
DART_DEPRECATED(6.0)
Expand Down
2 changes: 1 addition & 1 deletion dart/dynamics/MultiDofJoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ class MultiDofJoint : public detail::MultiDofJointBase< MultiDofJoint<DOF>, DOF
//----------------------------------------------------------------------------

// Documentation inherited
double getPotentialEnergy() const override;
double computePotentialEnergy() const override;

// Documentation inherited
Eigen::Vector6d getBodyConstraintWrench() const override;
Expand Down
10 changes: 5 additions & 5 deletions dart/dynamics/ReferentialSkeleton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -758,26 +758,26 @@ void ReferentialSkeleton::clearInternalForces()
}

//==============================================================================
double ReferentialSkeleton::getKineticEnergy() const
double ReferentialSkeleton::computeKineticEnergy() const
{
double KE = 0.0;

for(const BodyNode* bn : mRawBodyNodes)
KE += bn->getKineticEnergy();
KE += bn->computeKineticEnergy();

assert( KE >= 0.0 && "Kinetic Energy should always be zero or greater");
return KE;
}

//==============================================================================
double ReferentialSkeleton::getPotentialEnergy() const
double ReferentialSkeleton::computePotentialEnergy() const
{
double PE = 0.0;

for(const BodyNode* bn : mRawBodyNodes)
{
PE += bn->getPotentialEnergy(bn->getSkeleton()->getGravity());
PE += bn->getParentJoint()->getPotentialEnergy();
PE += bn->computePotentialEnergy(bn->getSkeleton()->getGravity());
PE += bn->getParentJoint()->computePotentialEnergy();
}

return PE;
Expand Down
4 changes: 2 additions & 2 deletions dart/dynamics/ReferentialSkeleton.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,10 @@ class ReferentialSkeleton : public MetaSkeleton
void clearInternalForces() override;

// Documentation inherited
double getKineticEnergy() const override;
double computeKineticEnergy() const override;

// Documentation inherited
double getPotentialEnergy() const override;
double computePotentialEnergy() const override;

// Documentation inherited
DART_DEPRECATED(6.0)
Expand Down
2 changes: 1 addition & 1 deletion dart/dynamics/SingleDofJoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,7 @@ double SingleDofJoint::getCoulombFriction(std::size_t _index) const
}

//==============================================================================
double SingleDofJoint::getPotentialEnergy() const
double SingleDofJoint::computePotentialEnergy() const
{
// Spring energy
double pe = 0.5 * mAspectProperties.mSpringStiffness
Expand Down
4 changes: 2 additions & 2 deletions dart/dynamics/SingleDofJoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,8 @@ class SingleDofJoint : public detail::SingleDofJointBase

//----------------------------------------------------------------------------

/// Get potential energy
double getPotentialEnergy() const override;
// Documentation inherited
double computePotentialEnergy() const override;

// Documentation inherited
const math::Jacobian getRelativeJacobian() const override;
Expand Down
Loading

0 comments on commit 8c68d52

Please sign in to comment.