From 40a4658bb7933f76bd90544401693acba1c19f6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Hern=C3=A1ndez=20Cordero?= Date: Fri, 11 Sep 2020 17:55:05 +0200 Subject: [PATCH] Using std::chrono instead of common::Time (#116) Signed-off-by: ahcorde Signed-off-by: Louise Poubel Co-authored-by: Louise Poubel --- .github/ci-bionic/after_make.sh | 11 ----------- .github/ci-bionic/dependencies.yaml | 5 ----- CMakeLists.txt | 2 +- Migration.md | 7 +++++++ include/ignition/gui/Conversions.hh | 6 ++++++ src/Conversions_TEST.cc | 15 ++++++++++++++- src/plugins/world_stats/WorldStats.cc | 21 +++++++++++---------- 7 files changed, 39 insertions(+), 28 deletions(-) delete mode 100644 .github/ci-bionic/after_make.sh delete mode 100644 .github/ci-bionic/dependencies.yaml diff --git a/.github/ci-bionic/after_make.sh b/.github/ci-bionic/after_make.sh deleted file mode 100644 index 12726c879..000000000 --- a/.github/ci-bionic/after_make.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -l - -set -x - -# Install (needed for some tests) -make install - -Xvfb :1 -screen 0 1280x1024x24 & -export DISPLAY=:1.0 -export RENDER_ENGINE_VALUES=ogre2 -export MESA_GL_VERSION_OVERRIDE=3.3 diff --git a/.github/ci-bionic/dependencies.yaml b/.github/ci-bionic/dependencies.yaml deleted file mode 100644 index 4231e9b6c..000000000 --- a/.github/ci-bionic/dependencies.yaml +++ /dev/null @@ -1,5 +0,0 @@ -repositories: - ign-rendering: - type: git - url: https://github.com/ignitionrobotics/ign-rendering - version: master diff --git a/CMakeLists.txt b/CMakeLists.txt index dc2a31643..1355bd3cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,7 @@ ign_find_package(TINYXML2 REQUIRED PRIVATE PRETTY tinyxml2) #-------------------------------------- # Find ignition-math -ign_find_package(ignition-math6 REQUIRED) +ign_find_package(ignition-math6 REQUIRED VERSION 6.5) set(IGN_MATH_VER ${ignition-math6_VERSION_MAJOR}) #-------------------------------------- diff --git a/Migration.md b/Migration.md index 930d78efe..0ecb06924 100644 --- a/Migration.md +++ b/Migration.md @@ -5,6 +5,13 @@ Deprecated code produces compile-time warnings. These warning serve as notification to users that their code should be upgraded. The next major release will remove the deprecated code. +## Ignition GUI 3.x to 4.x + +* Use rendering4, transport9 and msgs6. +* Deprecated `ignition::gui::convert` to `ignition::common::Time`. + Use `ignition::msgs::Convert` to `std::chrono::steady_clock::time_point` + instead. + ## Ignition GUI 2.x to 3.x * Use rendering3, transport8 and msgs5. diff --git a/include/ignition/gui/Conversions.hh b/include/ignition/gui/Conversions.hh index 2730f9fbd..91c11999e 100644 --- a/include/ignition/gui/Conversions.hh +++ b/include/ignition/gui/Conversions.hh @@ -90,13 +90,19 @@ namespace ignition /// \brief Convert an ignition::msgs::Time to an ignition::common::Time /// \param[in] _t The time to convert /// \return An ignition::common::Time object + /// \deprecated Use ignition::msgs:Convert to + /// std::chrono::steady_clock::time_point IGNITION_GUI_VISIBLE + IGN_DEPRECATED(4) common::Time convert(const msgs::Time &_t); /// \brief Convert an ignition::common::Time to an ignition::msgs::Time /// \param[in] _t The time to convert /// \return An ignition::msgs::Time object + /// \deprecated Use ignition::msgs:Convert to + /// std::chrono::steady_clock::time_point IGNITION_GUI_VISIBLE + IGN_DEPRECATED(4) msgs::Time convert(const common::Time &_t); } } diff --git a/src/Conversions_TEST.cc b/src/Conversions_TEST.cc index 0960ddf99..23d1a026e 100644 --- a/src/Conversions_TEST.cc +++ b/src/Conversions_TEST.cc @@ -159,8 +159,14 @@ TEST(ConversionsTest, Time) ignition::msgs::Time t; t.set_sec(s); t.set_nsec(ns); - +#ifndef _WIN32 +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif auto nt = convert(convert(t)); +#ifndef _WIN32 +# pragma GCC diagnostic pop +#endif EXPECT_DOUBLE_EQ(nt.sec(), t.sec()); EXPECT_DOUBLE_EQ(nt.nsec(), t.nsec()); } @@ -168,7 +174,14 @@ TEST(ConversionsTest, Time) // Common to msgs to common { common::Time t(s, ns); +#ifndef _WIN32 +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif EXPECT_EQ(convert(convert(t)), t); +#ifndef _WIN32 +# pragma GCC diagnostic pop +#endif } } diff --git a/src/plugins/world_stats/WorldStats.cc b/src/plugins/world_stats/WorldStats.cc index f5a800bb1..d7afb486e 100644 --- a/src/plugins/world_stats/WorldStats.cc +++ b/src/plugins/world_stats/WorldStats.cc @@ -17,7 +17,6 @@ #include #include -#include #include #include "ignition/gui/Helpers.hh" @@ -183,22 +182,24 @@ void WorldStats::ProcessMsg() { std::lock_guard lock(this->dataPtr->mutex); - ignition::common::Time time; + std::chrono::steady_clock::time_point timePoint; if (this->dataPtr->msg.has_sim_time()) { - time.sec = this->dataPtr->msg.sim_time().sec(); - time.nsec = this->dataPtr->msg.sim_time().nsec(); - - this->SetSimTime(QString::fromStdString(time.FormattedString())); + timePoint = math::secNsecToTimePoint( + this->dataPtr->msg.sim_time().sec(), + this->dataPtr->msg.sim_time().nsec()); + this->SetSimTime(QString::fromStdString( + math::timePointToString(timePoint))); } if (this->dataPtr->msg.has_real_time()) { - time.sec = this->dataPtr->msg.real_time().sec(); - time.nsec = this->dataPtr->msg.real_time().nsec(); - - this->SetRealTime(QString::fromStdString(time.FormattedString())); + timePoint = math::secNsecToTimePoint( + this->dataPtr->msg.real_time().sec(), + this->dataPtr->msg.real_time().nsec()); + this->SetRealTime(QString::fromStdString( + math::timePointToString(timePoint))); } {