Skip to content

Commit 0006877

Browse files
IceShuttleahcorde
andauthored
IMU system: react to gravity changes (#3254)
Signed-off-by: Shivang <shivangso23@iitk.ac.in> Signed-off-by: Shivang <75626127+IceShuttle@users.noreply.github.com> Co-authored-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
1 parent 8a78e48 commit 0006877

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/systems/imu/Imu.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,17 @@ void ImuPrivate::Update(const EntityComponentManager &_ecm)
319319
const auto &imuWorldPose = _worldPose->Data();
320320
it->second->SetWorldPose(imuWorldPose);
321321

322+
// Update World Gravity
323+
auto gravity = _ecm.Component<components::Gravity>(worldEntity);
324+
if (nullptr != gravity)
325+
{
326+
it->second->SetGravity(gravity->Data());
327+
}
328+
else
329+
{
330+
gzerr << "World missing gravity." <<
331+
"Gravity used by imu sensor may be outdated" << std::endl;
332+
}
322333
// Set the IMU angular velocity (defined in imu's local frame)
323334
it->second->SetAngularVelocity(_angularVel->Data());
324335

0 commit comments

Comments
 (0)