Skip to content

Commit

Permalink
use enable_orientation sdf elem
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <ichen@osrfoundation.org>
  • Loading branch information
iche033 committed Aug 3, 2021
1 parent 09c8b35 commit 48e171f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 29 deletions.
28 changes: 7 additions & 21 deletions src/systems/imu/Imu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ class ignition::gazebo::systems::ImuPrivate
/// \brief Ign-sensors sensor factory for creating sensors
public: sensors::SensorFactory sensorFactory;

/// \brief True to compute and output orientation values,
/// false to leave the orientation field empty in the published msg.
public: bool outputOrientation = true;

public: Entity worldEntity = kNullEntity;

/// \brief Create IMU sensor
Expand All @@ -86,19 +82,6 @@ Imu::Imu() : System(), dataPtr(std::make_unique<ImuPrivate>())
//////////////////////////////////////////////////
Imu::~Imu() = default;

//////////////////////////////////////////////////
void Imu::Configure(const Entity & /*_entity*/,
const std::shared_ptr<const sdf::Element> &_sdf,
gazebo::EntityComponentManager & /*_ecm*/,
gazebo::EventManager & /*_eventMgr*/)
{
if (_sdf->HasElement("output_orientation"))
{
this->dataPtr->outputOrientation =
_sdf->Get<bool>("output_orientation");
}
}

//////////////////////////////////////////////////
void Imu::PreUpdate(const UpdateInfo &/*_info*/,
EntityComponentManager &_ecm)
Expand Down Expand Up @@ -203,8 +186,12 @@ void ImuPrivate::CreateImuEntities(EntityComponentManager &_ecm)
// Set topic
_ecm.CreateComponent(_entity, components::SensorTopic(sensor->Topic()));

// Set whether to output orientation
sensor->SetOrientationEnabled(this->outputOrientation);
// Set whether orientation is enabled
if (data.ImuSensor())
{
sensor->SetOrientationEnabled(
data.ImuSensor()->OrientationEnabled());
}

this->entitySensorMap.insert(
std::make_pair(_entity, std::move(sensor)));
Expand Down Expand Up @@ -274,8 +261,7 @@ void ImuPrivate::RemoveImuEntities(

IGNITION_ADD_PLUGIN(Imu, System,
Imu::ISystemPreUpdate,
Imu::ISystemPostUpdate,
Imu::ISystemConfigure
Imu::ISystemPostUpdate
)

IGNITION_ADD_PLUGIN_ALIAS(Imu, "ignition::gazebo::systems::Imu")
9 changes: 1 addition & 8 deletions src/systems/imu/Imu.hh
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,14 @@ namespace systems
class Imu:
public System,
public ISystemPreUpdate,
public ISystemPostUpdate,
public ISystemConfigure
public ISystemPostUpdate
{
/// \brief Constructor
public: explicit Imu();

/// \brief Destructor
public: ~Imu() override;

/// Documentation inherited
public: void Configure(const Entity &_entity,
const std::shared_ptr<const sdf::Element> &_sdf,
EntityComponentManager &_ecm,
gazebo::EventManager &_eventMgr) final;

/// Documentation inherited
public: void PreUpdate(const UpdateInfo &_info,
EntityComponentManager &_ecm) final;
Expand Down

0 comments on commit 48e171f

Please sign in to comment.