From 95bff1b0f366cd3cfdce88a2ee071155bae36d37 Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Fri, 9 Jul 2021 19:06:48 -0700 Subject: [PATCH 1/8] Add API for enabling / disabling IMU orientation (#142) Signed-off-by: Ian Chen --- include/ignition/sensors/ImuSensor.hh | 16 +++++- src/ImuSensor.cc | 32 ++++++++--- src/ImuSensor_TEST.cc | 78 +++++++++++++++++++++++++++ 3 files changed, 118 insertions(+), 8 deletions(-) diff --git a/include/ignition/sensors/ImuSensor.hh b/include/ignition/sensors/ImuSensor.hh index 51e9f77f..966977d0 100644 --- a/include/ignition/sensors/ImuSensor.hh +++ b/include/ignition/sensors/ImuSensor.hh @@ -118,13 +118,27 @@ namespace ignition public: math::Quaterniond OrientationReference() const; /// \brief Get the orienation of the imu with respect to reference frame - /// \return Orientation in reference frame + /// \return Orientation in reference frame. If orientation is not + /// enabled, this will return the last computed orientation before + /// orientation is disabled or identity Quaternion if orientation has + /// never been enabled. public: math::Quaterniond Orientation() const; /// \brief Set the gravity vector /// \param[in] _gravity gravity vector in meters per second squared. public: void SetGravity(const math::Vector3d &_gravity); + /// \brief Set whether to output orientation. Not all imu's generate + /// orientation values as they use filters to produce orientation + /// estimates. + /// \param[in] _enabled True to publish orientation data, false to leave + /// the message field empty. + public: void SetOrientationEnabled(bool _enabled); + + /// \brief Get whether or not orientation is enabled. + /// \return True if orientation is enabled, false otherwise. + public: bool OrientationEnabled() const; + /// \brief Get the gravity vector /// \return Gravity vectory in meters per second squared. public: math::Vector3d Gravity() const; diff --git a/src/ImuSensor.cc b/src/ImuSensor.cc index ff31c3e6..35595d31 100644 --- a/src/ImuSensor.cc +++ b/src/ImuSensor.cc @@ -59,6 +59,9 @@ class ignition::sensors::ImuSensorPrivate /// \brief transform to Imu frame from Imu reference frame. public: ignition::math::Quaterniond orientation; + /// \brief True to publish orientation data. + public: bool orientationEnabled = true; + /// \brief store gravity vector to be added to the IMU output. public: ignition::math::Vector3d gravity; @@ -211,12 +214,6 @@ bool ImuSensor::Update(const std::chrono::steady_clock::duration &_now) applyNoise(GYROSCOPE_Y_NOISE_RAD_S, this->dataPtr->angularVel.Y()); applyNoise(GYROSCOPE_Z_NOISE_RAD_S, this->dataPtr->angularVel.Z()); - // Set the IMU orientation - // imu orientation with respect to reference frame - this->dataPtr->orientation = - this->dataPtr->orientationReference.Inverse() * - this->dataPtr->worldPose.Rot(); - msgs::IMU msg; *msg.mutable_header()->mutable_stamp() = msgs::Convert(_now); msg.set_entity_name(this->Name()); @@ -224,7 +221,16 @@ bool ImuSensor::Update(const std::chrono::steady_clock::duration &_now) frame->set_key("frame_id"); frame->add_value(this->Name()); - msgs::Set(msg.mutable_orientation(), this->dataPtr->orientation); + if (this->dataPtr->orientationEnabled) + { + // Set the IMU orientation + // imu orientation with respect to reference frame + this->dataPtr->orientation = + this->dataPtr->orientationReference.Inverse() * + this->dataPtr->worldPose.Rot(); + + msgs::Set(msg.mutable_orientation(), this->dataPtr->orientation); + } msgs::Set(msg.mutable_angular_velocity(), this->dataPtr->angularVel); msgs::Set(msg.mutable_linear_acceleration(), this->dataPtr->linearAcc); @@ -284,6 +290,18 @@ math::Quaterniond ImuSensor::OrientationReference() const return this->dataPtr->orientationReference; } +////////////////////////////////////////////////// +void ImuSensor::SetOrientationEnabled(bool _enabled) +{ + this->dataPtr->orientationEnabled = _enabled; +} + +////////////////////////////////////////////////// +bool ImuSensor::OrientationEnabled() const +{ + return this->dataPtr->orientationEnabled; +} + ////////////////////////////////////////////////// void ImuSensor::SetGravity(const math::Vector3d &_gravity) { diff --git a/src/ImuSensor_TEST.cc b/src/ImuSensor_TEST.cc index d690f460..d6b4f7c8 100644 --- a/src/ImuSensor_TEST.cc +++ b/src/ImuSensor_TEST.cc @@ -311,6 +311,84 @@ TEST(ImuSensor_TEST, ComputeNoise) EXPECT_GT(sensor->LinearAcceleration().SquaredLength(), 0.0); } +////////////////////////////////////////////////// +TEST(ImuSensor_TEST, Orientation) +{ + // Create a sensor manager + ignition::sensors::Manager mgr; + + sdf::ElementPtr imuSDF; + + { + const std::string name = "TestImu_Truth"; + const std::string topic = "/ignition/sensors/test/imu_truth"; + const double updateRate = 100; + const auto accelNoise = noNoiseParameters(updateRate, 0.0); + const auto gyroNoise = noNoiseParameters(updateRate, 0.0); + const bool always_on = 1; + const bool visualize = 1; + + imuSDF = ImuSensorToSDF(name, updateRate, topic, + accelNoise, gyroNoise, always_on, visualize); + } + + // Create an ImuSensor + auto sensor = mgr.CreateSensor( + imuSDF); + + // Make sure the above dynamic cast worked. + ASSERT_NE(nullptr, sensor); + + math::Quaterniond orientRef; + math::Quaterniond orientValue(math::Vector3d(IGN_PI/2.0, 0, IGN_PI)); + math::Pose3d pose(math::Vector3d(0, 1, 2), orientValue); + + sensor->SetOrientationReference(orientRef); + sensor->SetWorldPose(pose); + + sensor->Update(std::chrono::steady_clock::duration( + std::chrono::nanoseconds(10000000))); + + // Check orientation + EXPECT_TRUE(sensor->OrientationEnabled()); + EXPECT_EQ(orientRef, sensor->OrientationReference()); + EXPECT_EQ(orientValue, sensor->Orientation()); + + // update pose and check orientation + math::Quaterniond newOrientValue(math::Vector3d(IGN_PI, IGN_PI/2, IGN_PI)); + math::Pose3d newPose(math::Vector3d(0, 1, 1), newOrientValue); + sensor->SetWorldPose(newPose); + + sensor->Update(std::chrono::steady_clock::duration( + std::chrono::nanoseconds(20000000))); + + EXPECT_TRUE(sensor->OrientationEnabled()); + EXPECT_EQ(orientRef, sensor->OrientationReference()); + EXPECT_EQ(newOrientValue, sensor->Orientation()); + + // disable orientation and check + sensor->SetOrientationEnabled(false); + EXPECT_FALSE(sensor->OrientationEnabled()); + EXPECT_EQ(orientRef, sensor->OrientationReference()); + // orientation remains the same after disabling orientation + EXPECT_EQ(newOrientValue, sensor->Orientation()); + + // update world pose with orientation disabled and verify that orientation + // does not change + math::Quaterniond newOrientValue2(math::Vector3d(IGN_PI/2, IGN_PI/2, IGN_PI)); + math::Pose3d newPose2(math::Vector3d(1, 1, 0), newOrientValue2); + sensor->SetWorldPose(newPose2); + sensor->Update(std::chrono::steady_clock::duration( + std::chrono::nanoseconds(20000000))); + + sensor->SetOrientationEnabled(false); + EXPECT_FALSE(sensor->OrientationEnabled()); + EXPECT_EQ(orientRef, sensor->OrientationReference()); + // orientation should still be the previous value because it is not being + // updated. + EXPECT_EQ(newOrientValue, sensor->Orientation()); + +} ////////////////////////////////////////////////// int main(int argc, char **argv) From f8b09dcbd0f4f7f5cdc305300e1aeaae8c2607ea Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Tue, 13 Jul 2021 11:00:18 -0700 Subject: [PATCH 2/8] =?UTF-8?q?=F0=9F=8E=88=204.2.0=20(#143)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Louise Poubel --- CMakeLists.txt | 2 +- Changelog.md | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1894a1ff..0f67eab9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) #============================================================================ # Initialize the project #============================================================================ -project(ignition-sensors4 VERSION 4.1.0) +project(ignition-sensors4 VERSION 4.2.0) #============================================================================ # Find ignition-cmake diff --git a/Changelog.md b/Changelog.md index 3b93ff1b..d489bd31 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,41 @@ ### Ignition Sensors 4.X.X +### Ignition Sensors 4.2.0 (2021-07-12) + +1. Add API for enabling / disabling IMU orientation + * [Pull request #142](https://github.com/ignitionrobotics/ign-sensors/pull/142) + +1. Init will now set the nextUpdateTime to zero + * [Pull request #137](https://github.com/ignitionrobotics/ign-sensors/pull/137) + +1. Remove clamping from lidar noise + * [Pull request #132](https://github.com/ignitionrobotics/ign-sensors/pull/132) + +1. Remove tools/code_check and update codecov + * [Pull request #130](https://github.com/ignitionrobotics/ign-sensors/pull/130) + +1. Disable macOS workflow + * [Pull request #124](https://github.com/ignitionrobotics/ign-sensors/pull/124) + +1. 👩‍🌾 Disable tests that consistently fail on macOS + * [Pull request #121](https://github.com/ignitionrobotics/ign-sensors/pull/121) + +1. Master branch updates + * [Pull request #106](https://github.com/ignitionrobotics/ign-sensors/pull/106) + +1. 👩‍🌾 Clear Windows warnings (backport #58) + * [Pull request #102](https://github.com/ignitionrobotics/ign-sensors/pull/102) + +1. Update thermal camera tutorial - include varying temp. objects + * [Pull request #79](https://github.com/ignitionrobotics/ign-sensors/pull/79) + +1. Fix macOS/windows tests that failed to load library + * [Pull request #60](https://github.com/ignitionrobotics/ign-sensors/pull/60) + +1. Removed issue & PR templates + * [Pull request #99](https://github.com/ignitionrobotics/ign-sensors/pull/99) + ### Ignition Sensors 4.1.0 (2021-02-10) 1. Added issue and PR templates. @@ -56,7 +91,7 @@ 1. Added thermal camera tutorial. * [Pull request 61](https://github.com/ignitionrobotics/ign-sensors/pull/61) -1. Prevent segfaults on test failures, make tests verbose. +1. Prevent segfaults on test failures, make tests verbose. * [Pull request 56](https://github.com/ignitionrobotics/ign-sensors/pull/56) 1. Resolve updated codecheck issues. From e181d3e28e107ad7f2c539914469443593f9df23 Mon Sep 17 00:00:00 2001 From: Franco Cipollone <53065142+francocipollone@users.noreply.github.com> Date: Thu, 19 Aug 2021 19:23:06 -0300 Subject: [PATCH 3/8] Publish performance sensor metrics. (#146) Signed-off-by: Franco Cipollone Co-authored-by: Louise Poubel --- include/ignition/sensors/Sensor.hh | 15 ++++ src/Sensor.cc | 107 ++++++++++++++++++++++++++++- src/Sensor_TEST.cc | 88 +++++++++++++++++++++++- 3 files changed, 206 insertions(+), 4 deletions(-) diff --git a/include/ignition/sensors/Sensor.hh b/include/ignition/sensors/Sensor.hh index 3fa15c06..fa8fe4ab 100644 --- a/include/ignition/sensors/Sensor.hh +++ b/include/ignition/sensors/Sensor.hh @@ -27,6 +27,7 @@ #pragma warning(pop) #endif +#include #include #include @@ -146,6 +147,14 @@ namespace ignition /// \return True if a valid topic was set. public: bool SetTopic(const std::string &_topic); + /// \brief Get flag state for enabling performance metrics publication. + /// \return True if performance metrics are enabled, false otherwise. + public: bool EnableMetrics() const; + + /// \brief Set flag to enable publishing performance metrics + /// \param[in] _enableMetrics True to enable. + public: void SetEnableMetrics(bool _enableMetrics); + /// \brief Get parent link of the sensor. /// \return Parent link of sensor. public: std::string Parent() const; @@ -180,6 +189,12 @@ namespace ignition public: void AddSequence(ignition::msgs::Header *_msg, const std::string &_seqKey = "default"); + /// \brief Publishes information about the performance of the sensor. + /// This method is called by Update(). + /// \param[in] _now Current time. + public: void PublishMetrics( + const std::chrono::duration &_now); + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING /// \internal /// \brief Data pointer for private data diff --git a/src/Sensor.cc b/src/Sensor.cc index c4486116..14df12fb 100644 --- a/src/Sensor.cc +++ b/src/Sensor.cc @@ -16,17 +16,18 @@ */ #include "ignition/sensors/Sensor.hh" + +#include #include #include + #include #include +#include #include -#include - using namespace ignition::sensors; - class ignition::sensors::SensorPrivate { /// \brief Populates fields from a DOM @@ -37,6 +38,10 @@ class ignition::sensors::SensorPrivate /// \return True if a valid topic was set. public: bool SetTopic(const std::string &_topic); + /// \brief Publishes information about the performance of the sensor. + /// \param[in] _now Current simulation time. + public: void PublishMetrics(const std::chrono::duration &_now); + /// \brief id given to sensor when constructed public: SensorId id; @@ -55,12 +60,27 @@ class ignition::sensors::SensorPrivate /// \brief Pose of the sensor public: ignition::math::Pose3d pose; + /// \brief Flag to enable publishing performance metrics. + public: bool enableMetrics{false}; + /// \brief How many times the sensor will generate data per second public: double updateRate = 0.0; /// \brief What sim time should this sensor update at public: ignition::common::Time nextUpdateTime; + /// \brief Last steady clock time reading from last Update call. + public: std::chrono::time_point lastRealTime; + + /// \brief Last sim time at Update call. + public: std::chrono::duration lastUpdateTime{0}; + + /// \brief Transport node. + public: ignition::transport::Node node; + + /// \brief Publishes the PerformanceSensorMetrics message. + public: ignition::transport::Node::Publisher performanceSensorMetricsPub; + /// \brief SDF element with sensor information. public: sdf::ElementPtr sdf = nullptr; @@ -110,6 +130,8 @@ bool SensorPrivate::PopulateFromSDF(const sdf::Sensor &_sdf) } this->updateRate = _sdf.UpdateRate(); + + this->enableMetrics = _sdf.EnableMetrics(); return true; } @@ -196,6 +218,79 @@ bool SensorPrivate::SetTopic(const std::string &_topic) return true; } +////////////////////////////////////////////////// +bool Sensor::EnableMetrics() const +{ + return this->dataPtr->enableMetrics; +} + + +////////////////////////////////////////////////// +void Sensor::SetEnableMetrics(bool _enableMetrics) +{ + this->dataPtr->enableMetrics = _enableMetrics; +} + +////////////////////////////////////////////////// +void Sensor::PublishMetrics(const std::chrono::duration &_now) +{ + return this->dataPtr->PublishMetrics(_now); +} + +////////////////////////////////////////////////// +void SensorPrivate::PublishMetrics(const std::chrono::duration &_now) +{ + if(!this->performanceSensorMetricsPub) + { + const auto validTopic = transport::TopicUtils::AsValidTopic( + this->topic + "/performance_metrics"); + if (validTopic.empty()) + { + ignerr << "Failed to set metrics sensor topic [" << topic << "]" << + std::endl; + return; + } + this->performanceSensorMetricsPub = + node.Advertise(validTopic); + } + if (!performanceSensorMetricsPub || + !performanceSensorMetricsPub.HasConnections()) + { + return; + } + + // Computes simulation update rate and real update rate. + double simUpdateRate; + double realUpdateRate; + const auto clockNow = std::chrono::steady_clock::now(); + // If lastUpdateTime == 0 means it wasn't initialized yet. + if(this->lastUpdateTime.count() > 0) + { + const double diffSimUpdate = _now.count() - + this->lastUpdateTime.count(); + simUpdateRate = 1.0 / diffSimUpdate; + const double diffRealUpdate = + std::chrono::duration_cast>( + clockNow - this->lastRealTime).count(); + realUpdateRate = diffRealUpdate < std::numeric_limits::epsilon() ? + std::numeric_limits::infinity() : 1.0 / diffRealUpdate; + } + + // Update last time values. + this->lastUpdateTime = _now; + this->lastRealTime = clockNow; + + // Fill performance sensor metrics message. + msgs::PerformanceSensorMetrics performanceSensorMetricsMsg; + performanceSensorMetricsMsg.set_name(this->name); + performanceSensorMetricsMsg.set_real_update_rate(realUpdateRate); + performanceSensorMetricsMsg.set_sim_update_rate(simUpdateRate); + performanceSensorMetricsMsg.set_nominal_update_rate(this->updateRate); + + // Publish data + performanceSensorMetricsPub.Publish(performanceSensorMetricsMsg); +} + ////////////////////////////////////////////////// ignition::math::Pose3d Sensor::Pose() const { @@ -256,6 +351,12 @@ bool Sensor::Update(const ignition::common::Time &_now, // Make the update happen result = this->Update(_now); + // Publish metrics + if (this->EnableMetrics()) + { + this->PublishMetrics(std::chrono::duration(_now.Double())); + } + if (!_force && this->dataPtr->updateRate > 0.0) { // Update the time the plugin should be loaded diff --git a/src/Sensor_TEST.cc b/src/Sensor_TEST.cc index 9b4e7581..d9157ec8 100644 --- a/src/Sensor_TEST.cc +++ b/src/Sensor_TEST.cc @@ -14,11 +14,27 @@ * limitations under the License. * */ +#include + +#include +#include + #include +#ifdef _WIN32 +#pragma warning(push) +#pragma warning(disable: 4005) +#pragma warning(disable: 4251) +#endif +#include +#ifdef _WIN32 +#pragma warning(pop) +#endif + #include +#include #include -#include +#include using namespace ignition; using namespace sensors; @@ -124,6 +140,76 @@ TEST(Sensor_TEST, Topic) EXPECT_FALSE(sensor.SetTopic("")); } +class SensorUpdate : public ::testing::Test +{ + // Documentation inherited + protected: void SetUp() override + { + ignition::common::Console::SetVerbosity(4); + node.Subscribe(kPerformanceMetricTopic, + &SensorUpdate::OnPerformanceMetric, this); + } + + // Callback function for the performance metric topic. + protected: void OnPerformanceMetric( + const ignition::msgs::PerformanceSensorMetrics &_msg) + { + EXPECT_EQ(kSensorName, _msg.name()); + performanceMetricsMsgsCount++; + } + + // Sensor name. + protected: const std::string kSensorName{"sensor_test"}; + // Sensor topic. + protected: const std::string kSensorTopic{"/sensor_test"}; + // Enable metrics flag. + protected: const bool kEnableMetrics{true}; + // Topic where performance metrics are published. + protected: const std::string kPerformanceMetricTopic{ + kSensorTopic + "/performance_metrics"}; + // Number of messages to be published. + protected: const unsigned int kNumberOfMessages{10}; + // Counter for performance metrics messages published. + protected: std::atomic performanceMetricsMsgsCount{0}; + // Transport node. + protected: transport::Node node; +}; + +////////////////////////////////////////////////// +TEST_F(SensorUpdate, Update) +{ + // Create sensor. + sdf::Sensor sdfSensor; + sdfSensor.SetName(kSensorName); + sdfSensor.SetTopic(kSensorTopic); + sdfSensor.SetEnableMetrics(kEnableMetrics); + std::unique_ptr sensor = std::make_unique(); + sensor->Load(sdfSensor); + ASSERT_EQ(kSensorTopic, sensor->Topic()); + ASSERT_EQ(kEnableMetrics, sensor->EnableMetrics()); + + // Call Update() method kNumberOfMessages times. + // For each call there is also a call to Sensor::PublishMetrics() that + // publishes metrics in the correspondant topic. + for (int sec = 0 ; sec < static_cast(kNumberOfMessages) ; ++sec) + { + common::Time now{sec, 0 /*nsec*/}; + sensor->Update(now, true); + } + + int sleep = 0; + const int maxSleep = 30; + while (performanceMetricsMsgsCount < kNumberOfMessages && sleep < maxSleep) + { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + sleep++; + } + ASSERT_EQ(kNumberOfMessages, performanceMetricsMsgsCount); + + auto testSensor = dynamic_cast(sensor.get()); + EXPECT_EQ(testSensor->updateCount, performanceMetricsMsgsCount); +} + ////////////////////////////////////////////////// int main(int argc, char **argv) { From a9ce6f9e82b7534caa8f67b1e2d987679185e544 Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Tue, 24 Aug 2021 10:34:30 -0700 Subject: [PATCH 4/8] =?UTF-8?q?=F0=9F=91=A9=E2=80=8D=F0=9F=8C=BE=20Remove?= =?UTF-8?q?=20bitbucket-pipelines.yml=20(#150)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Louise Poubel --- bitbucket-pipelines.yml | 89 ----------------------------------------- 1 file changed, 89 deletions(-) delete mode 100644 bitbucket-pipelines.yml diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml deleted file mode 100644 index ff825df1..00000000 --- a/bitbucket-pipelines.yml +++ /dev/null @@ -1,89 +0,0 @@ -image: ubuntu:bionic - -pipelines: - default: - - step: - script: # Modify the commands below to build your repository. - - apt update - - apt -y install wget lsb-release gnupg - - sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list' - - wget http://packages.osrfoundation.org/gazebo.key -O - | apt-key add - - - apt-get update - - apt-get -y install - cmake pkg-config cppcheck doxygen ruby-ronn curl git g++-8 - - update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8 --slave /usr/bin/gcov gcov /usr/bin/gcov-8 - # lcov - - git clone https://github.com/linux-test-project/lcov.git -b v1.14 - - cd lcov - - make install - - cd .. - # Dependency: Ignition packages and sdformat - - apt-get -y install - libignition-cmake2-dev - libignition-common3-dev - libignition-math6-dev - libignition-tools-dev - libignition-plugin-dev - libignition-msgs5-dev - libignition-transport8-dev - libsdformat9-dev - # libignition-rendering3-dev - # SDFormat (uncomment if a specific branch is needed) - # - apt install -y - # libxml2-utils - # libtinyxml-dev - # - git clone http://github.com/osrf/sdformat - # - cd sdformat - # - mkdir build - # - cd build - # - cmake .. -DBUILD_TESTING=false - # - make -j4 install - # - cd ../.. - # Ignition msgs (uncomment if a specific branch is needed) - # - apt install -y - # libprotobuf-dev protobuf-compiler libprotoc-dev - # - git clone http://github.com/ignitionrobotics/ign-msgs - # - cd ign-msgs - # - mkdir build - # - cd build - # - cmake .. - # - make -j4 install - # - cd ../.. - # Ignition transport (uncomment if a specific branch is needed) - # - apt install -y - # libzmq3-dev uuid-dev libsqlite3-dev - # - git clone http://github.com/ignitionrobotics/ign-transport - # - cd ign-transport - # - mkdir build - # - cd build - # - cmake .. - # - make -j4 install - # - cd ../.. - # Install ign-rendering dependencies - - apt-get -y install - libogre-1.9-dev libogre-2.1-dev libglew-dev libfreeimage-dev freeglut3-dev libxmu-dev libxi-dev uuid-dev - - git clone http://github.com/ignitionrobotics/ign-rendering -b ign-rendering3 - - cd ign-rendering - - mkdir build - - cd build - - cmake .. - - make -j4 install - - cd ../.. - # Ignition sensors - - mkdir build - - cd build - - cmake .. -DCMAKE_BUILD_TYPE=coverage -DDRI_TESTS=FALSE - - make -j4 install - - make test - - make coverage - # Use a special version of codecov for handling gcc8 output. - - bash <(curl -s https://raw.githubusercontent.com/codecov/codecov-bash/4678d212cce2078bbaaf5027af0c0dafaad6a095/codecov) -X gcovout - - make codecheck - # Examples - - apt-get -y install libfreeimage-dev - - cd .. - - cd examples/save_image - - mkdir build - - cd build - - cmake .. - - make From b475f297c5123925f178b1319b4bcf9004bdf4ec Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Thu, 26 Aug 2021 14:48:08 -0700 Subject: [PATCH 5/8] =?UTF-8?q?=F0=9F=91=A9=E2=80=8D=F0=9F=8C=BE=20Print?= =?UTF-8?q?=20debug=20messages=20when=20sensors=20advertise=20topics=20(#1?= =?UTF-8?q?51)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Louise Poubel --- src/AirPressureSensor.cc | 3 +++ src/AltimeterSensor.cc | 3 +++ src/CameraSensor.cc | 21 ++++++++++----------- src/DepthCameraSensor.cc | 6 ++++++ src/GpuLidarSensor.cc | 3 +++ src/ImuSensor.cc | 3 +++ src/Lidar.cc | 4 +++- src/LogicalCameraSensor.cc | 3 +++ src/MagnetometerSensor.cc | 3 +++ src/RgbdCameraSensor.cc | 9 +++++++++ src/ThermalCameraSensor.cc | 3 +++ 11 files changed, 49 insertions(+), 12 deletions(-) diff --git a/src/AirPressureSensor.cc b/src/AirPressureSensor.cc index 7a0e733a..f56362d3 100644 --- a/src/AirPressureSensor.cc +++ b/src/AirPressureSensor.cc @@ -122,6 +122,9 @@ bool AirPressureSensor::Load(const sdf::Sensor &_sdf) return false; } + igndbg << "Air pressure for [" << this->Name() << "] advertised on [" + << this->Topic() << "]" << std::endl; + // Load the noise parameters if (_sdf.AirPressureSensor()->PressureNoise().Type() != sdf::NoiseType::NONE) { diff --git a/src/AltimeterSensor.cc b/src/AltimeterSensor.cc index c5d75890..0689c83c 100644 --- a/src/AltimeterSensor.cc +++ b/src/AltimeterSensor.cc @@ -100,6 +100,9 @@ bool AltimeterSensor::Load(const sdf::Sensor &_sdf) return false; } + igndbg << "Altimeter data for [" << this->Name() << "] advertised on [" + << this->Topic() << "]" << std::endl; + // Load the noise parameters if (_sdf.AltimeterSensor()->VerticalPositionNoise().Type() != sdf::NoiseType::NONE) diff --git a/src/CameraSensor.cc b/src/CameraSensor.cc index c8f8a3f4..80968b0e 100644 --- a/src/CameraSensor.cc +++ b/src/CameraSensor.cc @@ -267,6 +267,9 @@ bool CameraSensor::Load(const sdf::Sensor &_sdf) return false; } + igndbg << "Camera images for [" << this->Name() << "] advertised on [" + << this->Topic() << "]" << std::endl; + if (!this->AdvertiseInfo()) return false; @@ -500,16 +503,7 @@ bool CameraSensor::AdvertiseInfo() } this->dataPtr->infoTopic += "/camera_info"; - this->dataPtr->infoPub = - this->dataPtr->node.Advertise( - this->dataPtr->infoTopic); - if (!this->dataPtr->infoPub) - { - ignerr << "Unable to create publisher on topic[" - << this->dataPtr->infoTopic << "].\n"; - } - - return this->dataPtr->infoPub; + return this->AdvertiseInfo(this->dataPtr->infoTopic); } ////////////////////////////////////////////////// @@ -522,9 +516,14 @@ bool CameraSensor::AdvertiseInfo(const std::string &_topic) this->dataPtr->infoTopic); if (!this->dataPtr->infoPub) { - ignerr << "Unable to create publisher on topic[" + ignerr << "Unable to create publisher on topic [" << this->dataPtr->infoTopic << "].\n"; } + else + { + igndbg << "Camera info for [" << this->Name() << "] advertised on [" + << this->dataPtr->infoTopic << "]" << std::endl; + } return this->dataPtr->infoPub; } diff --git a/src/DepthCameraSensor.cc b/src/DepthCameraSensor.cc index 2f3a9c5b..06dadb8e 100644 --- a/src/DepthCameraSensor.cc +++ b/src/DepthCameraSensor.cc @@ -284,6 +284,9 @@ bool DepthCameraSensor::Load(const sdf::Sensor &_sdf) return false; } + igndbg << "Depth images for [" << this->Name() << "] advertised on [" + << this->Topic() << "]" << std::endl; + if (!this->AdvertiseInfo()) return false; @@ -298,6 +301,9 @@ bool DepthCameraSensor::Load(const sdf::Sensor &_sdf) return false; } + igndbg << "Points for [" << this->Name() << "] advertised on [" + << this->Topic() << "/points]" << std::endl; + // Initialize the point message. // \todo(anyone) The true value in the following function call forces // the xyz and rgb fields to be aligned to memory boundaries. This is need diff --git a/src/GpuLidarSensor.cc b/src/GpuLidarSensor.cc index dfcceb40..e1c2bedb 100644 --- a/src/GpuLidarSensor.cc +++ b/src/GpuLidarSensor.cc @@ -146,6 +146,9 @@ bool GpuLidarSensor::Load(const sdf::Sensor &_sdf) return false; } + igndbg << "Lidar points for [" << this->Name() << "] advertised on [" + << this->Topic() << "]" << std::endl; + this->initialized = true; return true; diff --git a/src/ImuSensor.cc b/src/ImuSensor.cc index 638ed22d..8427f717 100644 --- a/src/ImuSensor.cc +++ b/src/ImuSensor.cc @@ -124,6 +124,9 @@ bool ImuSensor::Load(const sdf::Sensor &_sdf) return false; } + igndbg << "IMU data for [" << this->Name() << "] advertised on [" + << this->Topic() << "]" << std::endl; + const std::map noises = { {ACCELEROMETER_X_NOISE_M_S_S, _sdf.ImuSensor()->LinearAccelerationXNoise()}, {ACCELEROMETER_Y_NOISE_M_S_S, _sdf.ImuSensor()->LinearAccelerationYNoise()}, diff --git a/src/Lidar.cc b/src/Lidar.cc index 84a49771..b34e649b 100644 --- a/src/Lidar.cc +++ b/src/Lidar.cc @@ -118,7 +118,9 @@ bool Lidar::Load(const sdf::Sensor &_sdf) << this->Topic() << "].\n"; return false; } - ignmsg << "Publishing laser scans on [" << this->Topic() << "]" << std::endl; + + igndbg << "Laser scans for [" << this->Name() << "] advertised on [" + << this->Topic() << "]" << std::endl; // Load ray atributes this->dataPtr->sdfLidar = *_sdf.LidarSensor(); diff --git a/src/LogicalCameraSensor.cc b/src/LogicalCameraSensor.cc index 82579baf..ad647f91 100644 --- a/src/LogicalCameraSensor.cc +++ b/src/LogicalCameraSensor.cc @@ -117,6 +117,9 @@ bool LogicalCameraSensor::Load(sdf::ElementPtr _sdf) return false; } + igndbg << "Logical images for [" << this->Name() << "] advertised on [" + << this->Topic() << "]" << std::endl; + this->dataPtr->initialized = true; return true; } diff --git a/src/MagnetometerSensor.cc b/src/MagnetometerSensor.cc index c227f1ad..5bc375b9 100644 --- a/src/MagnetometerSensor.cc +++ b/src/MagnetometerSensor.cc @@ -114,6 +114,9 @@ bool MagnetometerSensor::Load(const sdf::Sensor &_sdf) return false; } + igndbg << "Magnetometer data for [" << this->Name() << "] advertised on [" + << this->Topic() << "]" << std::endl; + // Load the noise parameters if (_sdf.MagnetometerSensor()->XNoise().Type() != sdf::NoiseType::NONE) { diff --git a/src/RgbdCameraSensor.cc b/src/RgbdCameraSensor.cc index c2a766f9..3a04045f 100644 --- a/src/RgbdCameraSensor.cc +++ b/src/RgbdCameraSensor.cc @@ -211,6 +211,9 @@ bool RgbdCameraSensor::Load(const sdf::Sensor &_sdf) return false; } + igndbg << "RGB images for [" << this->Name() << "] advertised on [" + << this->Topic() << "/image]" << std::endl; + // Create the depth image publisher this->dataPtr->depthPub = this->dataPtr->node.Advertise( @@ -222,6 +225,9 @@ bool RgbdCameraSensor::Load(const sdf::Sensor &_sdf) return false; } + igndbg << "Depth images for [" << this->Name() << "] advertised on [" + << this->Topic() << "/depth_image]" << std::endl; + // Create the point cloud publisher this->dataPtr->pointPub = this->dataPtr->node.Advertise( @@ -233,6 +239,9 @@ bool RgbdCameraSensor::Load(const sdf::Sensor &_sdf) return false; } + igndbg << "Points for [" << this->Name() << "] advertised on [" + << this->Topic() << "/points]" << std::endl; + if (!this->AdvertiseInfo(this->Topic() + "/camera_info")) return false; diff --git a/src/ThermalCameraSensor.cc b/src/ThermalCameraSensor.cc index 744b5d9b..a25da365 100644 --- a/src/ThermalCameraSensor.cc +++ b/src/ThermalCameraSensor.cc @@ -214,6 +214,9 @@ bool ThermalCameraSensor::Load(const sdf::Sensor &_sdf) return false; } + igndbg << "Thermal images for [" << this->Name() << "] advertised on [" + << this->Topic() << "]" << std::endl; + if (!this->AdvertiseInfo()) return false; From 739a10cdfbb20370e1164e549b8742086521bc78 Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Mon, 30 Aug 2021 14:40:11 -0700 Subject: [PATCH 6/8] =?UTF-8?q?=F0=9F=8E=88=203.3.0=20(#152)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Louise Poubel --- CMakeLists.txt | 2 +- Changelog.md | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c5cc4937..0491f008 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) #============================================================================ # Initialize the project #============================================================================ -project(ignition-sensors3 VERSION 3.2.0) +project(ignition-sensors3 VERSION 3.3.0) #============================================================================ # Find ignition-cmake diff --git a/Changelog.md b/Changelog.md index 88184785..5279e2f2 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,29 @@ ## Ignition Sensors 3 +### Ignition Sensors 3.X.X (202X-XX-XX) + +### Ignition Sensors 3.3.0 (2021-08-26) + +1. 👩‍🌾 Print debug messages when sensors advertise topics + * [Pull request #151](https://github.com/ignitionrobotics/ign-sensors/pull/151) + +1. Publish performance sensor metrics. + * [Pull request #146](https://github.com/ignitionrobotics/ign-sensors/pull/146) + +1. CI and infrastructure + * [Pull request #130](https://github.com/ignitionrobotics/ign-sensors/pull/130) + * [Pull request #150](https://github.com/ignitionrobotics/ign-sensors/pull/150) + * [Pull request #106](https://github.com/ignitionrobotics/ign-sensors/pull/106) + +1. 👩‍🌾 Disable tests that consistently fail on macOS + * [Pull request #121](https://github.com/ignitionrobotics/ign-sensors/pull/121) + +1. 👩‍🌾 Clear Windows warnings (backport #58) + * [Pull request #58](https://github.com/ignitionrobotics/ign-sensors/pull/58) + +1. Fix macOS/windows tests that failed to load library (backport #60) + * [Pull request #60](https://github.com/ignitionrobotics/ign-sensors/pull/60) + ### Ignition Sensors 3.2.0 (2021-02-08) 1. Apply noise to lidar point cloud. @@ -11,7 +35,7 @@ 1. Added thermal camera tutorial. * [Pull request 61](https://github.com/ignitionrobotics/ign-sensors/pull/61) -1. Prevent segfaults on test failures, make tests verbose. +1. Prevent segfaults on test failures, make tests verbose. * [Pull request 56](https://github.com/ignitionrobotics/ign-sensors/pull/56) 1. Resolve updated codecheck issues. From c0f9ecf20d016c06e3a9c18391421912111561b4 Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Thu, 9 Sep 2021 13:49:37 -0700 Subject: [PATCH 7/8] Bump required SDF version to 10.6 (#153) Also fix deprecation warning. Signed-off-by: Louise Poubel --- CMakeLists.txt | 2 +- src/Sensor_TEST.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 52398e70..3f0edcf5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,7 +85,7 @@ set(IGN_PLUGIN_VER ${ignition-plugin1_VERSION_MAJOR}) #-------------------------------------- # Find SDFormat -ign_find_package(sdformat10 REQUIRED) +ign_find_package(sdformat10 REQUIRED VERSION 10.6) set(SDF_VER ${sdformat10_VERSION_MAJOR}) set(IGN_SENSORS_PLUGIN_PATH ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) diff --git a/src/Sensor_TEST.cc b/src/Sensor_TEST.cc index fd77d726..6ff81cf3 100644 --- a/src/Sensor_TEST.cc +++ b/src/Sensor_TEST.cc @@ -198,7 +198,7 @@ TEST_F(SensorUpdate, Update) // publishes metrics in the correspondant topic. for (int sec = 0 ; sec < static_cast(kNumberOfMessages) ; ++sec) { - common::Time now{sec, 0 /*nsec*/}; + std::chrono::steady_clock::duration now = std::chrono::seconds(sec); sensor->Update(now, true); } From f9633329f35b7b8214e9070d54a24a616ea29441 Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Mon, 13 Sep 2021 12:11:28 -0700 Subject: [PATCH 8/8] Depend on ign-msgs 7.2 and libSDFormat 11.3 (#154) Signed-off-by: Louise Poubel --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b15d3505..b3c37e81 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,7 +75,7 @@ endif() #-------------------------------------- # Find ignition-msgs -ign_find_package(ignition-msgs7 REQUIRED) +ign_find_package(ignition-msgs7 REQUIRED VERSION 7.2) set(IGN_MSGS_VER ${ignition-msgs7_VERSION_MAJOR}) #-------------------------------------- @@ -85,7 +85,7 @@ set(IGN_PLUGIN_VER ${ignition-plugin1_VERSION_MAJOR}) #-------------------------------------- # Find SDFormat -ign_find_package(sdformat11 REQUIRED) +ign_find_package(sdformat11 REQUIRED VERSION 11.3) set(SDF_VER ${sdformat11_VERSION_MAJOR}) set(IGN_SENSORS_PLUGIN_PATH ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})