Skip to content
Snippets Groups Projects
Commit 9cc7cafc authored by Fabian Reister's avatar Fabian Reister
Browse files

using armarx::time

parent 80a7a279
No related branches found
No related tags found
1 merge request!22emitting UserAbortEvent instead of GoalReached on stop()
#pragma once #pragma once
// STD/STL
#include <string> #include <string>
// Navigation #include <ArmarXCore/core/time/DateTime.h>
#include <armarx/navigation/core/types.h>
#include <armarx/navigation/core/types.h>
namespace armarx::navigation::core namespace armarx::navigation::core
{ {
struct Event struct Event
{ {
core::TimestampUs timestamp; armarx::core::time::DateTime timestamp;
}; };
struct GlobalPlanningFailedEvent : public Event struct GlobalPlanningFailedEvent : public Event
......
#include "ChronoMonotonicTimeServer.h" #include "ChronoMonotonicTimeServer.h"
#include <chrono> #include <ArmarXCore/core/time/Clock.h>
#include <ArmarXCore/core/logging/Logging.h>
namespace armarx::navigation::core namespace armarx::navigation::core
{ {
TimestampUs armarx::core::time::DateTime
ChronoMonotonicTimeServer::now() const ChronoMonotonicTimeServer::now() const
{ {
const auto tsNow = std::chrono::high_resolution_clock::now(); return armarx::Clock::Now();
// const auto tsNow = std::chrono::steady_clock::now();
const auto tsSince = tsNow.time_since_epoch();
const auto dur = std::chrono::duration_cast<std::chrono::microseconds>(tsSince);
// ARMARX_INFO << "tsnow " << tsNow;
// ARMARX_INFO << "tsSince " << tsSince;
// ARMARX_INFO << "dur " << dur;
return dur;
} }
} // namespace armarx::navigation::core } // namespace armarx::navigation::core
...@@ -31,7 +31,7 @@ namespace armarx::navigation::core ...@@ -31,7 +31,7 @@ namespace armarx::navigation::core
class ChronoMonotonicTimeServer : virtual public TimeServerInterface class ChronoMonotonicTimeServer : virtual public TimeServerInterface
{ {
public: public:
TimestampUs now() const override; armarx::core::time::DateTime now() const override;
~ChronoMonotonicTimeServer() override = default; ~ChronoMonotonicTimeServer() override = default;
}; };
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#pragma once #pragma once
#include <armarx/navigation/core/types.h> #include "ArmarXCore/core/time/DateTime.h"
namespace armarx::navigation::core namespace armarx::navigation::core
{ {
...@@ -29,7 +29,7 @@ namespace armarx::navigation::core ...@@ -29,7 +29,7 @@ namespace armarx::navigation::core
class TimeServerInterface class TimeServerInterface
{ {
public: public:
virtual TimestampUs now() const = 0; virtual armarx::core::time::DateTime now() const = 0;
virtual ~TimeServerInterface() = default; virtual ~TimeServerInterface() = default;
}; };
......
...@@ -95,9 +95,6 @@ namespace armarx::navigation::core ...@@ -95,9 +95,6 @@ namespace armarx::navigation::core
TimeServerInterface* timeServer; TimeServerInterface* timeServer;
}; };
using TimestampUs = std::chrono::microseconds;
struct PIDParams struct PIDParams
{ {
float Kp{1.0}; float Kp{1.0};
......
...@@ -11,15 +11,10 @@ namespace armarx::navigation::memory::client::param ...@@ -11,15 +11,10 @@ namespace armarx::navigation::memory::client::param
bool bool
Writer::store(const std::unordered_map<core::StackLayer, aron::data::DictPtr>& stack, Writer::store(const std::unordered_map<core::StackLayer, aron::data::DictPtr>& stack,
const std::string& clientID, const std::string& clientID,
const core::TimestampUs& timestamp) const armarx::core::time::DateTime& timestamp)
{ {
ARMARX_CHECK(not stack.empty()); ARMARX_CHECK(not stack.empty());
const armem::Time ts(Duration::MicroSeconds(timestamp.count()));
ARMARX_INFO << "timestamp chrono " << timestamp;
ARMARX_INFO << "timestamp " << ts;
armem::Commit commit; armem::Commit commit;
for (const auto& [layer, data] : stack) for (const auto& [layer, data] : stack)
...@@ -32,8 +27,8 @@ namespace armarx::navigation::memory::client::param ...@@ -32,8 +27,8 @@ namespace armarx::navigation::memory::client::param
.withCoreSegmentName(properties().coreSegmentName) .withCoreSegmentName(properties().coreSegmentName)
.withProviderSegmentName(clientID) .withProviderSegmentName(clientID)
.withEntityName(layerName) .withEntityName(layerName)
.withTimestamp(ts); .withTimestamp(timestamp);
update.timeCreated = ts; update.timeCreated = timestamp;
update.instancesData = {data}; update.instancesData = {data};
commit.add(update); commit.add(update);
} }
......
...@@ -13,7 +13,7 @@ namespace armarx::navigation::server ...@@ -13,7 +13,7 @@ namespace armarx::navigation::server
bool bool
MemoryParameterizationService::store(const aron::data::DictPtr& params, MemoryParameterizationService::store(const aron::data::DictPtr& params,
const std::string& clientId, const std::string& clientId,
const core::TimestampUs& timestamp) const armarx::core::time::DateTime& timestamp)
{ {
ARMARX_CHECK_NOT_NULL(writer); ARMARX_CHECK_NOT_NULL(writer);
...@@ -63,7 +63,7 @@ namespace armarx::navigation::server ...@@ -63,7 +63,7 @@ namespace armarx::navigation::server
bool bool
MemoryParameterizationService::store(const aron::data::dto::DictPtr& params, MemoryParameterizationService::store(const aron::data::dto::DictPtr& params,
const std::string& clientId, const std::string& clientId,
const core::TimestampUs& timestamp) const armarx::core::time::DateTime& timestamp)
{ {
const auto dict = aron::data::Dict::FromAronDictDTO(params); const auto dict = aron::data::Dict::FromAronDictDTO(params);
return store(dict, clientId, timestamp); return store(dict, clientId, timestamp);
......
...@@ -41,11 +41,11 @@ namespace armarx::navigation::server ...@@ -41,11 +41,11 @@ namespace armarx::navigation::server
bool store(const aron::data::DictPtr& params, bool store(const aron::data::DictPtr& params,
const std::string& clientId, const std::string& clientId,
const core::TimestampUs& timestamp); const armarx::core::time::DateTime& timestamp);
bool store(const aron::data::dto::DictPtr& params, bool store(const aron::data::dto::DictPtr& params,
const std::string& clientId, const std::string& clientId,
const core::TimestampUs& timestamp); const armarx::core::time::DateTime& timestamp);
protected: protected:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment