Reader.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @author Fabian Reister ( fabian dot reister at kit dot edu )
17  * @date 2021
18  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
19  * GNU General Public License
20  */
21 
22 #pragma once
23 
24 #include <mutex>
25 #include <optional>
26 
27 #include <VirtualRobot/VirtualRobot.h>
28 
30 
33 
34 #include "interfaces.h"
35 
36 // #include <ArmarXCore/core/application/properties/PropertyDefinitionContainer.h>
37 // #include <RobotAPI/libraries/armem/client/MemoryNameSystem.h>
38 
39 
41 {
42 
43  class Reader : virtual public ReaderInterface
44  {
45  public:
46  Reader() = default;
47  ~Reader() override = default;
48 
49  void
51  {
52  }
53 
54  void connect(armem::client::MemoryNameSystem& memoryNameSystem);
55 
56  [[nodiscard]] bool
58  const armem::Time& timestamp,
59  const std::optional<std::string>& providerName) const override;
60 
61  std::optional<ArticulatedObject>
62  get(const std::string& name,
63  const armem::Time& timestamp,
64  const std::optional<std::string>& providerName) const override;
66  const armem::Time& timestamp,
67  const std::string& instanceName,
68  const std::optional<std::string>& providerName) const override;
69 
70  std::optional<robot_state::RobotState>
71  queryState(const std::string& instanceName,
72  const armem::Time& timestamp,
73  const std::optional<std::string>& providerName) const;
74  std::optional<robot_state::description::RobotDescription>
75  queryDescription(const std::string& name,
76  const armem::Time& timestamp,
77  const std::optional<std::string>& providerName) const;
78 
79  std::vector<robot_state::description::RobotDescription>
80  queryDescriptions(const armem::Time& timestamp,
81  const std::optional<std::string>& providerName) const;
82 
83  std::string getProviderName() const;
84  void setProviderName(const std::string& providerName);
85 
86  protected:
87  std::optional<robot_state::RobotState>
89  std::optional<robot_state::description::RobotDescription>
91  std::vector<robot_state::description::RobotDescription>
93 
94  private:
95  void updateKnownObjects(const armem::MemoryID& subscriptionID,
96  const std::vector<armem::MemoryID>& snapshotIDs);
97  void updateKnownObject(const armem::MemoryID& snapshotId);
98 
99  const std::string propertyPrefix = "mem.obj.articulated.";
100 
101  armem::client::Reader memoryReader;
102  std::mutex memoryWriterMutex;
103  };
104 
105 
106 } // namespace armarx::armem::articulated_object
armarx::armem::articulated_object::Reader::getRobotDescription
std::optional< robot_state::description::RobotDescription > getRobotDescription(const armarx::armem::wm::Memory &memory) const
Definition: Reader.cpp:354
armarx::armem::articulated_object::Reader::get
std::optional< ArticulatedObject > get(const std::string &name, const armem::Time &timestamp, const std::optional< std::string > &providerName) const override
Definition: Reader.cpp:99
armarx::armem::articulated_object::Reader::queryState
std::optional< robot_state::RobotState > queryState(const std::string &instanceName, const armem::Time &timestamp, const std::optional< std::string > &providerName) const
Definition: Reader.cpp:255
armarx::armem::client::Reader
Reads data from a memory server.
Definition: Reader.h:24
Reader.h
armarx::armem::robot_state::description::RobotDescription
Definition: types.h:44
armarx::armem::robot_state::Robot
Definition: types.h:126
armarx::armem::articulated_object::Reader::queryDescriptions
std::vector< robot_state::description::RobotDescription > queryDescriptions(const armem::Time &timestamp, const std::optional< std::string > &providerName) const
Definition: Reader.cpp:164
armarx::armem::articulated_object::Reader::synchronize
bool synchronize(ArticulatedObject &obj, const armem::Time &timestamp, const std::optional< std::string > &providerName) const override
Definition: Reader.cpp:141
armarx::memory
Brief description of class memory.
Definition: memory.h:39
armarx::armem::articulated_object::Reader::~Reader
~Reader() override=default
interfaces.h
forward_declarations.h
armarx::armem::MemoryID
A memory ID.
Definition: MemoryID.h:47
armarx::armem::articulated_object::Reader::Reader
Reader()=default
armarx::armem::wm::Memory
Client-side working memory.
Definition: memory_definitions.h:133
armarx::armem::articulated_object::Reader::getArticulatedObjectState
std::optional< robot_state::RobotState > getArticulatedObjectState(const armarx::armem::wm::Memory &memory) const
Definition: Reader.cpp:332
armarx::armem::articulated_object::Reader::getProviderName
std::string getProviderName() const
armarx::armem::articulated_object::Reader::setProviderName
void setProviderName(const std::string &providerName)
armarx::core::time::DateTime
Represents a point in time.
Definition: DateTime.h:24
armarx::armem::articulated_object::Reader::getRobotDescriptions
std::vector< robot_state::description::RobotDescription > getRobotDescriptions(const armarx::armem::wm::Memory &memory) const
Definition: Reader.cpp:375
IceUtil::Handle< class PropertyDefinitionContainer >
forward_declarations.h
armarx::armem::articulated_object
Definition: ArticulatedObjectReader.cpp:25
armarx::armem::client::MemoryNameSystem
The memory name system (MNS) client.
Definition: MemoryNameSystem.h:69
armarx::armem::articulated_object::Reader::queryDescription
std::optional< robot_state::description::RobotDescription > queryDescription(const std::string &name, const armem::Time &timestamp, const std::optional< std::string > &providerName) const
Definition: Reader.cpp:208
armarx::armem::articulated_object::Reader
Definition: Reader.h:43
armarx::armem::articulated_object::Reader::connect
void connect(armem::client::MemoryNameSystem &memoryNameSystem)
Definition: Reader.cpp:33
armarx::armem::articulated_object::Reader::registerPropertyDefinitions
void registerPropertyDefinitions(armarx::PropertyDefinitionsPtr &def)
Definition: Reader.h:50
armarx::armem::articulated_object::ReaderInterface
Definition: interfaces.h:9