Skip to content

Commit dd05774

Browse files
committed
bullet-featherstone: Reset joint motor constraint's velocity target after each step (#699)
Signed-off-by: Ian Chen <ichen@openrobotics.org>
1 parent 70a72cd commit dd05774

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

bullet-featherstone/src/SimulationFeatures.cc

+10
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ void SimulationFeatures::WorldForwardStep(
5151
worldInfo->world->stepSimulation(static_cast<btScalar>(stepSize), 1,
5252
static_cast<btScalar>(stepSize));
5353

54+
// Reset joint velocity target after each step to be consistent with dart's
55+
// joint velocity command behavior
56+
for (auto & joint : this->joints)
57+
{
58+
if (joint.second->motor)
59+
{
60+
joint.second->motor->setVelocityTarget(btScalar(0));
61+
}
62+
}
63+
5464
this->WriteRequiredData(_h);
5565
this->Write(_h.Get<ChangedWorldPoses>());
5666
}

test/common_test/joint_features.cc

+4-7
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,11 @@ TYPED_TEST(JointFeaturesTest, JointSetCommand)
174174
EXPECT_NEAR(1.0, joint->GetVelocity(0), 1e-2);
175175
}
176176

177-
if(this->PhysicsEngineName(name) == "dartsim")
177+
for (std::size_t i = 0; i < numSteps; ++i)
178178
{
179-
for (std::size_t i = 0; i < numSteps; ++i)
180-
{
181-
// expect joint to freeze in subsequent steps without SetVelocityCommand
182-
world->Step(output, state, input);
183-
EXPECT_NEAR(0.0, joint->GetVelocity(0), 1e-1);
184-
}
179+
// expect joint to freeze in subsequent steps without SetVelocityCommand
180+
world->Step(output, state, input);
181+
EXPECT_NEAR(0.0, joint->GetVelocity(0), 1e-1);
185182
}
186183

187184
// Check that invalid velocity commands don't cause collisions to fail

0 commit comments

Comments
 (0)