Skip to content

Commit 39b7a7d

Browse files
committed
Merge remote-tracking branch 'origin/main' into issue/465_closed_kinematic_changes
2 parents 3c359c7 + 9b39285 commit 39b7a7d

File tree

306 files changed

+11361
-34551
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

306 files changed

+11361
-34551
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ docs/doxygen/html/
5959
docs/readthedocs/site
6060
docs/readthedocs/_build/
6161
docs/readthedocs/_generated/
62+
docs/readthedocs/_generated_stubs/
6263
docs/python_api/_build/
6364

6465
# Data files

Brewfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,3 @@ brew 'urdfdom'
3737

3838
# dartpy dependencies
3939
brew 'python3'
40-
brew 'pybind11'

CMakeLists.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ dart_option(DART_USE_SYSTEM_IMGUI
247247
"Use system-installed ImGui instead of fetching from GitHub (recommended for package distributions)" OFF CATEGORY system)
248248
dart_option(DART_USE_SYSTEM_GOOGLEBENCHMARK "Use system GoogleBenchmark" OFF CATEGORY system)
249249
dart_option(DART_USE_SYSTEM_GOOGLETEST "Use system GoogleTest" OFF CATEGORY system)
250-
dart_option(DART_USE_SYSTEM_PYBIND11 "Use system pybind11" OFF CATEGORY system)
250+
dart_option(DART_USE_SYSTEM_NANOBIND "Use system nanobind" OFF CATEGORY system)
251251
dart_option(DART_USE_SYSTEM_TRACY "Use system Tracy" OFF CATEGORY system)
252252
dart_option(DART_VERBOSE "Whether print detailed information in CMake process" OFF CATEGORY diagnostics)
253253
dart_option(DART_BUILD_DART8 "Build experimental DART8 library" OFF CATEGORY build)
@@ -674,7 +674,10 @@ endif()
674674
add_subdirectory(python)
675675

676676
# Add 'ALL' target that builds everything
677-
set(all_target_candidates dartpy)
677+
set(all_target_candidates)
678+
if(DART_BUILD_DARTPY)
679+
list(APPEND all_target_candidates dartpy)
680+
endif()
678681
if(DART_BUILD_TESTS AND BUILD_TESTING)
679682
list(APPEND all_target_candidates tests_and_run pytest)
680683
endif()
@@ -1003,8 +1006,7 @@ message(STATUS "Run '${DART_CMAKE_BUILD_CMD} --target tutorials' to build all th
10031006
message(STATUS "Run '${DART_CMAKE_BUILD_CMD} --target view_docs' to see the API documentation")
10041007
message(STATUS "Run '${DART_CMAKE_BUILD_CMD} --target install' to install all the C++ components")
10051008
if(TARGET dartpy)
1006-
message(STATUS "Run '${DART_CMAKE_BUILD_CMD} --target dartpy' to build dartpy")
1007-
message(STATUS "Run '${DART_CMAKE_BUILD_CMD} --target install' to install dartpy")
1009+
message(STATUS "Run '${DART_CMAKE_BUILD_CMD} --target dartpy' to build the python bindings")
10081010
endif()
10091011
if(TARGET coverage)
10101012
message(STATUS "- 'coverage' : generate coverage report")

dart/constraint/CouplerConstraint.cpp

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,21 @@
3838
#include "dart/dynamics/Joint.hpp"
3939
#include "dart/dynamics/Skeleton.hpp"
4040

41-
#define DART_CFM 1e-9
41+
#include <cmath>
42+
43+
namespace {
44+
45+
constexpr inline double kConstraintForceMixing = 1e-6;
46+
constexpr inline double kDefaultForceLimit = 800.0;
47+
constexpr inline double kDefaultVelocityLimit = 50.0;
48+
constexpr inline double kDefaultErp = 0.4;
49+
50+
} // namespace
4251

4352
namespace dart {
4453
namespace constraint {
4554

46-
double CouplerConstraint::mConstraintForceMixing = DART_CFM;
55+
double CouplerConstraint::mConstraintForceMixing = kConstraintForceMixing;
4756

4857
//==============================================================================
4958
CouplerConstraint::CouplerConstraint(
@@ -114,20 +123,32 @@ void CouplerConstraint::update()
114123
const auto& mimicProp = mMimicProps[i];
115124

116125
double timeStep = mJoint->getSkeleton()->getTimeStep();
126+
double velLower = mJoint->getVelocityLowerLimit(i);
127+
double velUpper = mJoint->getVelocityUpperLimit(i);
128+
if (!std::isfinite(velLower))
129+
velLower = -kDefaultVelocityLimit;
130+
if (!std::isfinite(velUpper))
131+
velUpper = kDefaultVelocityLimit;
117132
double qError
118133
= mimicProp.mReferenceJoint->getPosition(mimicProp.mReferenceDofIndex)
119134
* mimicProp.mMultiplier
120135
+ mimicProp.mOffset - mJoint->getPosition(i);
121-
double desiredVelocity = math::clip(
122-
qError / timeStep,
123-
mJoint->getVelocityLowerLimit(i),
124-
mJoint->getVelocityUpperLimit(i));
136+
const double erp = kDefaultErp;
137+
double desiredVelocity
138+
= math::clip((erp * qError) / timeStep, velLower, velUpper);
125139

126140
mNegativeVelocityError[i] = desiredVelocity - mJoint->getVelocity(i);
127141

128142
if (mNegativeVelocityError[i] != 0.0) {
129-
mUpperBound[i] = mJoint->getForceUpperLimit(i) * timeStep;
130-
mLowerBound[i] = mJoint->getForceLowerLimit(i) * timeStep;
143+
double upper = mJoint->getForceUpperLimit(i);
144+
double lower = mJoint->getForceLowerLimit(i);
145+
if (!std::isfinite(upper))
146+
upper = kDefaultForceLimit;
147+
if (!std::isfinite(lower))
148+
lower = -kDefaultForceLimit;
149+
150+
mUpperBound[i] = upper * timeStep;
151+
mLowerBound[i] = lower * timeStep;
131152

132153
if (mActive[i]) {
133154
++(mLifeTime[i]);

dart/constraint/CouplerConstraint.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
#include <dart/constraint/ConstraintBase.hpp>
3737

38+
#include <dart/dynamics/Fwd.hpp>
3839
#include <dart/dynamics/MimicDofProperties.hpp>
3940

4041
#include <dart/Export.hpp>
@@ -144,7 +145,7 @@ class DART_API CouplerConstraint : public ConstraintBase
144145
double mLowerBound[6];
145146

146147
/// Global constraint force mixing parameter in the range of [1e-9, 1]. The
147-
/// default is 1e-5
148+
/// default is 1e-6
148149
/// @sa http://www.ode.org/ode-latest-userguide.html#sec_3_8_0
149150
static double mConstraintForceMixing;
150151
};

dart/constraint/MimicMotorConstraint.cpp

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,22 @@
4141

4242
#include <iostream>
4343

44-
#define DART_CFM 1e-9
44+
#include <cmath>
45+
46+
namespace {
47+
48+
constexpr inline double kConstraintForceMixing = 1e-6;
49+
constexpr inline double kDefaultForceLimit = 800.0;
50+
constexpr inline double kDefaultVelocityLimit = 50.0;
51+
constexpr inline double kDefaultErp = 0.4;
52+
53+
} // namespace
4554

4655
namespace dart {
4756
namespace constraint {
4857

49-
double MimicMotorConstraint::mConstraintForceMixing = DART_CFM;
58+
double MimicMotorConstraint::mConstraintForceMixing = kConstraintForceMixing;
59+
double MimicMotorConstraint::mErrorReductionParameter = kDefaultErp;
5060

5161
//==============================================================================
5262
MimicMotorConstraint::MimicMotorConstraint(
@@ -117,6 +127,31 @@ double MimicMotorConstraint::getConstraintForceMixing()
117127
return mConstraintForceMixing;
118128
}
119129

130+
//==============================================================================
131+
void MimicMotorConstraint::setErrorReductionParameter(double erp)
132+
{
133+
double clamped = erp;
134+
if (clamped < 0.0) {
135+
DART_WARN(
136+
"Error reduction parameter [{}] is lower than 0.0. It is set to 0.0.",
137+
erp);
138+
clamped = 0.0;
139+
} else if (clamped > 1.0) {
140+
DART_WARN(
141+
"Error reduction parameter [{}] is greater than 1.0. It is set to 1.0.",
142+
erp);
143+
clamped = 1.0;
144+
}
145+
146+
mErrorReductionParameter = clamped;
147+
}
148+
149+
//==============================================================================
150+
double MimicMotorConstraint::getErrorReductionParameter()
151+
{
152+
return mErrorReductionParameter;
153+
}
154+
120155
//==============================================================================
121156
void MimicMotorConstraint::update()
122157
{
@@ -128,21 +163,33 @@ void MimicMotorConstraint::update()
128163
const auto& mimicProp = mMimicProps[i];
129164

130165
double timeStep = mJoint->getSkeleton()->getTimeStep();
166+
double velLower = mJoint->getVelocityLowerLimit(i);
167+
double velUpper = mJoint->getVelocityUpperLimit(i);
168+
if (!std::isfinite(velLower))
169+
velLower = -kDefaultVelocityLimit;
170+
if (!std::isfinite(velUpper))
171+
velUpper = kDefaultVelocityLimit;
131172
double qError
132173
= mimicProp.mReferenceJoint->getPosition(mimicProp.mReferenceDofIndex)
133174
* mimicProp.mMultiplier
134175
+ mimicProp.mOffset - mJoint->getPosition(i);
135-
double desiredVelocity = math::clip(
136-
qError / timeStep,
137-
mJoint->getVelocityLowerLimit(i),
138-
mJoint->getVelocityUpperLimit(i));
176+
const double erp = mErrorReductionParameter;
177+
double desiredVelocity
178+
= math::clip((erp * qError) / timeStep, velLower, velUpper);
139179

140180
mNegativeVelocityError[i] = desiredVelocity - mJoint->getVelocity(i);
141181

142182
if (mNegativeVelocityError[i] != 0.0) {
143183
// Note that we are computing impulse not force
144-
mUpperBound[i] = mJoint->getForceUpperLimit(i) * timeStep;
145-
mLowerBound[i] = mJoint->getForceLowerLimit(i) * timeStep;
184+
double upper = mJoint->getForceUpperLimit(i);
185+
double lower = mJoint->getForceLowerLimit(i);
186+
if (!std::isfinite(upper))
187+
upper = kDefaultForceLimit;
188+
if (!std::isfinite(lower))
189+
lower = -kDefaultForceLimit;
190+
191+
mUpperBound[i] = upper * timeStep;
192+
mLowerBound[i] = lower * timeStep;
146193

147194
if (mActive[i]) {
148195
++(mLifeTime[i]);

dart/constraint/MimicMotorConstraint.hpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,12 @@
3535

3636
#include <dart/constraint/ConstraintBase.hpp>
3737

38+
#include <dart/dynamics/Fwd.hpp>
3839
#include <dart/dynamics/MimicDofProperties.hpp>
3940

4041
#include <vector>
4142

4243
namespace dart {
43-
44-
namespace dynamics {
45-
class BodyNode;
46-
class Joint;
47-
} // namespace dynamics
48-
4944
namespace constraint {
5045

5146
/// MimicMotorConstraint behaves like a servo motor: it drives only the
@@ -84,6 +79,12 @@ class MimicMotorConstraint : public ConstraintBase
8479
/// Get global constraint force mixing parameter
8580
static double getConstraintForceMixing();
8681

82+
/// Set global error reduction parameter applied to mimic motors.
83+
static void setErrorReductionParameter(double erp);
84+
85+
/// Get global error reduction parameter applied to mimic motors.
86+
static double getErrorReductionParameter();
87+
8788
//----------------------------------------------------------------------------
8889
// Friendship
8990
//----------------------------------------------------------------------------
@@ -157,9 +158,12 @@ class MimicMotorConstraint : public ConstraintBase
157158
double mLowerBound[6];
158159

159160
/// Global constraint force mixing parameter in the range of [1e-9, 1]. The
160-
/// default is 1e-5
161+
/// default is 1e-6
161162
/// @sa http://www.ode.org/ode-latest-userguide.html#sec_3_8_0
162163
static double mConstraintForceMixing;
164+
165+
/// Global error reduction parameter that scales mimic motor position error.
166+
static double mErrorReductionParameter;
163167
};
164168

165169
} // namespace constraint

0 commit comments

Comments
 (0)