Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revision of #531 #598

Merged
merged 9 commits into from
Jan 30, 2016
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ endif()
#===============================================================================
if(MSVC)
# Visual Studio enables c++11 support by default
if(NOT MSVC14)
if(MSVC_VERSION VERSION_LESS 1900)
message(FATAL_ERROR "${PROJECT_NAME} requires VS 2015 or greater.")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP4")
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[![Build Status](https://travis-ci.org/dartsim/dart.png?branch=master)](https://travis-ci.org/dartsim/dart)
[![Build status](https://ci.appveyor.com/api/projects/status/6rta8olo95bpu84r?svg=true)](https://ci.appveyor.com/project/jslee02/dart)
[![Build status](https://ci.appveyor.com/api/projects/status/6rta8olo95bpu84r/branch/master?svg=true)](https://ci.appveyor.com/project/jslee02/dart/branch/master)
[![Documentation Status](https://readthedocs.org/projects/dart/badge/?version=latest)](https://readthedocs.org/projects/dart/?badge=latest)
8 changes: 4 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ platform:
# specify custom environment variables
environment:
MSVC_DEFAULT_OPTIONS: ON
BOOST_ROOT: C:\Libraries\boost
BOOST_LIBRARYDIR: C:\Libraries\boost\lib32-msvc-12.0
BOOST_ROOT: C:\Libraries\boost_1_59_0
BOOST_LIBRARYDIR: C:\Libraries\boost_1_59_0\lib32-msvc-14.0
BUILD_EXAMPLES: OFF # don't build examples to not exceed allowed build time (40 min)
BUILD_TUTORIALS: OFF # don't build tutorials to not exceed allowed build time (40 min)
matrix:
Expand Down Expand Up @@ -53,8 +53,8 @@ before_build:
- cmd: md build
- cmd: cd build
# We generate project files for Visual Studio 12 because the boost binaries installed on the test server are for Visual Studio 12.
- cmd: if "%platform%"=="Win32" set CMAKE_GENERATOR_NAME=Visual Studio 12
- cmd: if "%platform%"=="x64" set CMAKE_GENERATOR_NAME=Visual Studio 12 Win64
- cmd: if "%platform%"=="Win32" set CMAKE_GENERATOR_NAME=Visual Studio 14 2015
- cmd: if "%platform%"=="x64" set CMAKE_GENERATOR_NAME=Visual Studio 14 2015 Win64
- cmd: cmake -G "%CMAKE_GENERATOR_NAME%" -DCMAKE_BUILD_TYPE=%configuration% -DBUILD_CORE_ONLY="%BUILD_CORE_ONLY%" -DDART_BUILD_EXAMPLES="%BUILD_EXAMPLES%" -DDART_BUILD_TUTORIALS="%BUILD_TUTORIALS%" -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_LIBRARYDIR="%BOOST_LIBRARYDIR%" -DBoost_USE_STATIC_LIBS="ON" -Durdfdom_DIR="%urdfdom_DIR%" -Durdfdom_headers_DIR="%urdfdom_headers_DIR%" -DDART_MSVC_DEFAULT_OPTIONS="%MSVC_DEFAULT_OPTIONS%" ..

build:
Expand Down
4 changes: 2 additions & 2 deletions ci/appveyor_install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ function InstallPrerequisites($work_dir, $install_dir)
$old_dir = $pwd
cd $work_dir

$msi = "dart-prerequisites.msi"
$uri = "https://github.com/dartsim/dart-prerequisites-windows/raw/3e34167fd29fcc870ebed50bf318f3f31f491e6a/DART%205.0-prerequisites-msvc12-md-32bit.msi"
$msi = "dart-dependencies.msi"
$uri = "https://github.com/dartsim/dart-prerequisites-windows-installers/raw/master/02/DART-dependencies-msvc14-md-32bit.msi"
Invoke-WebRequest $uri -OutFile $msi

$install_command = "msiexec.exe"
Expand Down
6 changes: 3 additions & 3 deletions dart/common/Addon.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ class Addon

/// Constructor
///
// We require the AddonManager argument in this constructor to make it clear
// to extensions that they must have an AddonManager argument in their
// constructors.
/// We require the AddonManager argument in this constructor to make it clear
/// to extensions that they must have an AddonManager argument in their
/// constructors.
Addon(AddonManager* manager);

/// This function will be triggered (1) after the Addon has been created
Expand Down
3 changes: 3 additions & 0 deletions dart/common/AddonManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ void AddonManager::duplicateAddons(const AddonManager* otherManager)
return;
}

if(this == otherManager)
return;

const AddonMap& otherMap = otherManager->mAddonMap;

AddonMap::iterator receiving = mAddonMap.begin();
Expand Down
8 changes: 3 additions & 5 deletions dart/common/AddonManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ class AddonManager
template <class T>
std::unique_ptr<T> release();

/// Check if this Manager is specialized for a specific type of Addon
/// Check if this Manager is specialized for a specific type of Addon.
///
/// By default, this simply returns false.
template <class T>
static constexpr bool isSpecializedFor();

Expand Down Expand Up @@ -171,10 +173,6 @@ class AddonManager
/// AddonManager types to call the protected Addon::setManager function.
void becomeManager(Addon* addon, bool transfer);

/// Always returns false
template <class T>
static constexpr bool _isSpecializedFor(type<T>);

/// A map that relates the type of Addon to its pointer
AddonMap mAddonMap;
};
Expand Down
7 changes: 0 additions & 7 deletions dart/common/detail/AddonManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,6 @@ std::unique_ptr<T> AddonManager::release()
//==============================================================================
template <class T>
constexpr bool AddonManager::isSpecializedFor()
{
return _isSpecializedFor(type<T>());
}

//==============================================================================
template <class T>
constexpr bool AddonManager::_isSpecializedFor(type<T>)
{
return false;
}
Expand Down
20 changes: 20 additions & 0 deletions dart/dynamics/Joint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,26 @@ Joint::Properties::Properties(const std::string& _name,
// Do nothing
}

//==============================================================================
Joint::ExtendedProperties::ExtendedProperties(
const Properties& standardProperties,
const AddonProperties& addonProperties)
: Properties(standardProperties),
mAddonProperties(addonProperties)
{
// Do nothing
}

//==============================================================================
Joint::ExtendedProperties::ExtendedProperties(
Properties&& standardProperties,
AddonProperties&& addonProperties)
: Properties(std::move(standardProperties)),
mAddonProperties(std::move(addonProperties))
{
// Do nothing
}

//==============================================================================
Joint::~Joint()
{
Expand Down
7 changes: 7 additions & 0 deletions dart/dynamics/Joint.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,17 @@ class Joint : public virtual common::Subject,

struct ExtendedProperties : Properties
{
/// Composed constructor
ExtendedProperties(
const Properties& standardProperties = Properties(),
const AddonProperties& addonProperties = AddonProperties());

/// Composed move constructor
ExtendedProperties(
Properties&& standardProperties,
AddonProperties&& addonProperties);

/// Properties of all the Addons attached to this Joint
AddonProperties mAddonProperties;
};

Expand Down
2 changes: 1 addition & 1 deletion dart/dynamics/MultiDofJoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class MultiDofJoint :
using Properties = detail::MultiDofJointProperties<DOF>;
using Addon = detail::MultiDofJointAddon<DOF>;

DART_BAKE_SPECIALIZED_ADDON_IRREGULAR( MultiDofJoint<DOF>::Addon, MultiDofJointAddon )
DART_BAKE_SPECIALIZED_ADDON_IRREGULAR( typename MultiDofJoint<DOF>::Addon, MultiDofJointAddon )

MultiDofJoint(const MultiDofJoint&) = delete;

Expand Down
112 changes: 112 additions & 0 deletions unittests/testJoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,118 @@ TEST_F(JOINTS, SERVO_MOTOR)
testServoMotor();
}

//==============================================================================
TEST_F(JOINTS, JOINT_COULOMB_FRICTION_AND_POSITION_LIMIT)
{
const double timeStep = 1e-3;
const double tol = 1e-2;

simulation::WorldPtr myWorld
= utils::SkelParser::readWorld(
DART_DATA_PATH"/skel/test/joint_friction_test.skel");
EXPECT_TRUE(myWorld != nullptr);

myWorld->setGravity(Eigen::Vector3d(0.0, 0.0, 0.0));
myWorld->setTimeStep(timeStep);

dynamics::SkeletonPtr pendulum = myWorld->getSkeleton("double_pendulum");
EXPECT_TRUE(pendulum != nullptr);
pendulum->disableSelfCollision();

dynamics::Joint* joint0 = pendulum->getJoint("joint0");
dynamics::Joint* joint1 = pendulum->getJoint("joint1");

EXPECT_TRUE(joint0 != nullptr);
EXPECT_TRUE(joint1 != nullptr);

double frictionForce = 5.0;

joint0->setPositionLimitEnforced(true);
joint1->setPositionLimitEnforced(true);

const double ll = -DART_PI/12.0; // -15 degree
const double ul = +DART_PI/12.0; // +15 degree

size_t dof0 = joint0->getNumDofs();
for (size_t i = 0; i < dof0; ++i)
{
joint0->setPosition(i, 0.0);
joint0->setPosition(i, 0.0);
joint0->setPositionLowerLimit(i, ll);
joint0->setPositionUpperLimit(i, ul);
}

size_t dof1 = joint1->getNumDofs();
for (size_t i = 0; i < dof1; ++i)
{
joint1->setPosition(i, 0.0);
joint1->setPosition(i, 0.0);
joint1->setPositionLowerLimit(i, ll);
joint1->setPositionUpperLimit(i, ul);
}

joint0->setCoulombFriction(0, frictionForce);
joint1->setCoulombFriction(0, frictionForce);

EXPECT_EQ(joint0->getCoulombFriction(0), frictionForce);
EXPECT_EQ(joint1->getCoulombFriction(0), frictionForce);

#ifndef NDEBUG // Debug mode
double simTime = 0.2;
#else
double simTime = 2.0;
#endif // ------- Debug mode
int nSteps = simTime / timeStep;

// First two seconds rotating in positive direction with higher control forces
// than the friction forces
for (int i = 0; i < nSteps; i++)
{
joint0->setForce(0, 100.0);
joint1->setForce(0, 100.0);
myWorld->step();

double jointPos0 = joint0->getPosition(0);
double jointPos1 = joint1->getPosition(0);

double jointVel0 = joint0->getVelocity(0);
double jointVel1 = joint1->getVelocity(0);

EXPECT_GE(std::abs(jointVel0), 0.0);
EXPECT_GE(std::abs(jointVel1), 0.0);

EXPECT_GE(jointPos0, ll - tol);
EXPECT_LE(jointPos0, ul + tol);

EXPECT_GE(jointPos1, ll - tol);
EXPECT_LE(jointPos1, ul + tol);
}

// Another two seconds rotating in negative direction with higher control
// forces than the friction forces
for (int i = 0; i < nSteps; i++)
{
joint0->setForce(0, -100.0);
joint1->setForce(0, -100.0);
myWorld->step();

double jointPos0 = joint0->getPosition(0);
double jointPos1 = joint1->getPosition(0);

double jointVel0 = joint0->getVelocity(0);
double jointVel1 = joint1->getVelocity(0);

EXPECT_GE(std::abs(jointVel0), 0.0);
EXPECT_GE(std::abs(jointVel1), 0.0);

EXPECT_GE(jointPos0, ll - tol);
EXPECT_LE(jointPos0, ul + tol);

EXPECT_GE(jointPos1, ll - tol);
EXPECT_LE(jointPos1, ul + tol);
}
}

//==============================================================================
template<int N>
Eigen::Matrix<double,N,1> random_vec(double limit=100)
Expand Down