Skip to content

Commit

Permalink
Reference initial orientation to world frame in IMU plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterBowman committed Feb 1, 2023
1 parent 34c08b6 commit 6e94671
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ The format of this document is based on [Keep a Changelog](https://keepachangelo

## [Unreleased]

### Fixed
### Added

- Added a new `useWorldReferenceOrientation` config option in the `gazebo_imu` plugin to take account for any initial non-zero orientation of the sensor as measured via `yarp::dev::IOrientationSensors` (https://github.com/robotology/gazebo-yarp-plugins/pull/639).

### Fixed

- Fix wrong install include for gazebo_yarp_lib_common library (https://github.com/robotology/gazebo-yarp-plugins/pull/644).

Expand Down
3 changes: 3 additions & 0 deletions plugins/imu/src/IMU.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ void GazeboYarpIMU::Load(sensors::SensorPtr _sensor, sdf::ElementPtr _sdf)
{"sensor_name", ::yarp::os::Value{_sensor->Name()}}
};

if (m_parameters.check("useWorldReferenceOrientation")) {
imu_properties.put("useWorldReferenceOrientation", yarp::os::Value::getNullValue());
}

//Open the driver
if (!m_imuDriver.open(imu_properties)) {
Expand Down
6 changes: 6 additions & 0 deletions plugins/imu/src/IMUDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <yarp/os/Log.h>
#include <yarp/os/LogStream.h>

#include <ignition/math/Quaternion.hh>

using namespace boost::placeholders;

using namespace yarp::dev;
Expand Down Expand Up @@ -88,6 +90,10 @@ bool GazeboYarpIMUDriver::open(yarp::os::Searchable& config)
return false;
}

if (config.check("useWorldReferenceOrientation")) {
m_parentSensor->SetWorldToReferenceOrientation(ignition::math::Quaterniond::Identity);
}

//Connect the driver to the gazebo simulation
using namespace boost::placeholders;
this->m_updateConnection = gazebo::event::Events::ConnectWorldUpdateBegin(boost::bind(&GazeboYarpIMUDriver::onUpdate, this, _1));
Expand Down

0 comments on commit 6e94671

Please sign in to comment.