Skip to content

Commit

Permalink
bullet-featurestore: Enable auto deactivation (#630)
Browse files Browse the repository at this point in the history

Signed-off-by: Ian Chen <[email protected]>
  • Loading branch information
iche033 authored Apr 24, 2024
1 parent c96ce6e commit 62ee52c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 20 deletions.
3 changes: 3 additions & 0 deletions bullet-featherstone/src/FreeGroupFeatures.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ void FreeGroupFeatures::SetFreeGroupWorldAngularVelocity(
if (model)
{
model->body->setBaseOmega(convertVec(_angularVelocity));
model->body->wakeUp();
}
}

Expand All @@ -82,6 +83,7 @@ void FreeGroupFeatures::SetFreeGroupWorldLinearVelocity(
if (model)
{
model->body->setBaseVel(convertVec(_linearVelocity));
model->body->wakeUp();
}
}

Expand All @@ -95,6 +97,7 @@ void FreeGroupFeatures::SetFreeGroupWorldPose(
{
model->body->setBaseWorldTransform(
convertTf(_pose * model->baseInertiaToLinkFrame.inverse()));
model->body->wakeUp();
}
}

Expand Down
6 changes: 5 additions & 1 deletion bullet-featherstone/src/JointFeatures.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ void JointFeatures::SetJointPosition(
const auto *model = this->ReferenceInterface<ModelInfo>(joint->model);
model->body->getJointPosMultiDof(identifier->indexInBtModel)[_dof] =
static_cast<btScalar>(_value);
model->body->wakeUp();
}

/////////////////////////////////////////////////
Expand All @@ -126,6 +127,7 @@ void JointFeatures::SetJointVelocity(
const auto *model = this->ReferenceInterface<ModelInfo>(joint->model);
model->body->getJointVelMultiDof(identifier->indexInBtModel)[_dof] =
static_cast<btScalar>(_value);
model->body->wakeUp();
}

/////////////////////////////////////////////////
Expand Down Expand Up @@ -156,6 +158,7 @@ void JointFeatures::SetJointForce(
const auto *model = this->ReferenceInterface<ModelInfo>(joint->model);
model->body->getJointTorqueMultiDof(
identifier->indexInBtModel)[_dof] = static_cast<btScalar>(_value);
model->body->wakeUp();
}

/////////////////////////////////////////////////
Expand Down Expand Up @@ -282,9 +285,9 @@ void JointFeatures::SetJointVelocityCommand(
return;
}

auto modelInfo = this->ReferenceInterface<ModelInfo>(jointInfo->model);
if (!jointInfo->motor)
{
auto modelInfo = this->ReferenceInterface<ModelInfo>(jointInfo->model);
jointInfo->motor = std::make_shared<btMultiBodyJointMotor>(
modelInfo->body.get(),
std::get<InternalJoint>(jointInfo->identifier).indexInBtModel,
Expand All @@ -296,6 +299,7 @@ void JointFeatures::SetJointVelocityCommand(
}

jointInfo->motor->setVelocityTarget(static_cast<btScalar>(_value));
modelInfo->body->wakeUp();
}

/////////////////////////////////////////////////
Expand Down
2 changes: 2 additions & 0 deletions bullet-featherstone/src/LinkFeatures.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ void LinkFeatures::AddLinkExternalForceInWorld(
model->body->addBaseForce(F);
model->body->addBaseTorque(relPosWorld.cross(F));
}
model->body->wakeUp();
}

/////////////////////////////////////////////////
Expand All @@ -73,6 +74,7 @@ void LinkFeatures::AddLinkExternalTorqueInWorld(
btVector3 torqueWorld = model->body->getBaseWorldTransform().getBasis() * T;
model->body->addBaseTorque(torqueWorld);
}
model->body->wakeUp();
}

}
Expand Down
19 changes: 0 additions & 19 deletions bullet-featherstone/src/SimulationFeatures.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,6 @@ void SimulationFeatures::WorldForwardStep(
worldInfo->world->stepSimulation(static_cast<btScalar>(this->stepSize), 1,
static_cast<btScalar>(this->stepSize));

for (auto & m : this->models)
{
if (m.second->body)
{
m.second->body->checkMotionAndSleepIfRequired(
static_cast<btScalar>(this->stepSize));
btMultiBodyLinkCollider* col = m.second->body->getBaseCollider();
if (col && col->getActivationState() != DISABLE_DEACTIVATION)
col->setActivationState(ACTIVE_TAG);

for (int b = 0; b < m.second->body->getNumLinks(); b++)
{
col = m.second->body->getLink(b).m_collider;
if (col && col->getActivationState() != DISABLE_DEACTIVATION)
col->setActivationState(ACTIVE_TAG);
}
}
}

this->WriteRequiredData(_h);
this->Write(_h.Get<ChangedWorldPoses>());
}
Expand Down

0 comments on commit 62ee52c

Please sign in to comment.