LegacyRobotStateMemoryAdapter.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  * @package RobotAPI::ArmarXObjects::MemoryNameSystem
17  * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu )
18  * @date 2020
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 #pragma once
24 
25 // STD/STL
26 #include <mutex>
27 
28 // Base Classes
30 #include <RobotAPI/interface/armem/addon/LegacyRobotStateMemoryAdapterInterface.h>
31 
32 // ArmarX
36 #include <RobotAPI/interface/armem/mns/MemoryNameSystemInterface.h>
38 
41 
42 namespace armarx::armem
43 {
45  virtual public armarx::Component,
46  virtual public robot_state::LegacyRobotStateMemoryAdapterInterface
47  {
48  public:
49 
50  /// @see armarx::ManagedIceObject::getDefaultName()
51  std::string getDefaultName() const override;
52 
53  void reportControlModeChanged(const NameControlModeMap&, Ice::Long, bool, const Ice::Current&) override;
54  void reportJointAngles(const NameValueMap&, Ice::Long, bool, const Ice::Current&) override;
55  void reportJointVelocities(const NameValueMap&, Ice::Long, bool, const Ice::Current&) override;
56  void reportJointTorques(const NameValueMap&, Ice::Long, bool, const Ice::Current&) override;
57  void reportJointAccelerations(const NameValueMap&, Ice::Long, bool, const Ice::Current&) override;
58  void reportJointCurrents(const NameValueMap&, Ice::Long, bool, const Ice::Current&) override;
59  void reportJointMotorTemperatures(const NameValueMap&, Ice::Long, bool, const Ice::Current&) override;
60  void reportJointStatuses(const NameStatusMap&, Ice::Long, bool, const Ice::Current&) override;
61 
62  // void reportPlatformPose(const PlatformPose &, const Ice::Current &) override;
63  void reportPlatformVelocity(Ice::Float, Ice::Float, Ice::Float, const Ice::Current &) override;
64  void reportPlatformOdometryPose(Ice::Float, Ice::Float, Ice::Float, const Ice::Current &) override;
65 
66  void reportGlobalRobotPose(const ::armarx::TransformStamped&, const ::Ice::Current& = ::Ice::emptyCurrent) override;
67 
68  protected:
69 
70  /// @see PropertyUser::createPropertyDefinitions()
72 
73  /// @see armarx::ManagedIceObject::onInitComponent()
74  void onInitComponent() override;
75 
76  /// @see armarx::ManagedIceObject::onConnectComponent()
77  void onConnectComponent() override;
78 
79  /// @see armarx::ManagedIceObject::onDisconnectComponent()
80  void onDisconnectComponent() override;
81 
82  /// @see armarx::ManagedIceObject::onExitComponent()
83  void onExitComponent() override;
84 
85  private:
86  void commitArmar3RobotDescription();
87 
88  void updateTimestamps(long dataGeneratedUs);
89  void checkUpdateAndSendToMemory();
90 
91  private:
92  // Update to send to the memory
93  struct Update
94  {
95  std::map<std::string, float> jointAngles = {};
96  std::map<std::string, float> jointVelocities = {};
97  std::map<std::string, float> jointTorques = {};
98  std::map<std::string, float> jointAccelerations = {};
99  std::map<std::string, float> jointCurrents = {};
100  armarx::PlatformPose platformPose = {};
101  std::tuple<float, float, float> platformVelocity = {0, 0, 0};
102  std::tuple<float, float, float> platformOdometryPose = {0, 0, 0};
103  };
104 
105  // Update
106  bool updateChanged = true;
107  double _timestampUpdateFirstModifiedInUs;
108  Update update;
109 
110  // Component properties
111  struct Properties
112  {
113  std::string memoryNameSystemName = "MemoryNameSystem";
114  std::string robotStateMemoryName = "RobotState";
115  int frequency = 100;
116  };
117  Properties properties;
118 
119  // RunningTask
121 
122  // Memory
125 
126  armem::client::Writer memoryWriter;
127 
128  mutable std::mutex updateMutex;
129  };
130 }
armarx::channels::PlatformUnitObserver::platformVelocity
const PlatformUnitDatafieldCreator platformVelocity("platformVelocity")
armarx::armem::LegacyRobotStateMemoryAdapter::onExitComponent
void onExitComponent() override
Definition: LegacyRobotStateMemoryAdapter.cpp:338
armarx::VariantType::Float
const VariantTypeId Float
Definition: Variant.h:918
Reader.h
armarx::armem::LegacyRobotStateMemoryAdapter::reportPlatformVelocity
void reportPlatformVelocity(Ice::Float, Ice::Float, Ice::Float, const Ice::Current &) override
Definition: LegacyRobotStateMemoryAdapter.cpp:245
Writer.h
armarx::armem::robot_state::constants::memoryName
const std::string memoryName
Definition: constants.h:26
armarx::armem
Definition: LegacyRobotStateMemoryAdapter.cpp:31
armarx::armem::LegacyRobotStateMemoryAdapter::getDefaultName
std::string getDefaultName() const override
Definition: LegacyRobotStateMemoryAdapter.cpp:50
constants.h
armarx::armem::robot_state::constants::proprioceptionCoreSegment
const std::string proprioceptionCoreSegment
Definition: constants.h:30
PeriodicTask.h
armarx::armem::LegacyRobotStateMemoryAdapter::reportJointAngles
void reportJointAngles(const NameValueMap &, Ice::Long, bool, const Ice::Current &) override
Definition: LegacyRobotStateMemoryAdapter.cpp:165
armarx::armem::robot_state::constants::robotRootNodeName
const std::string robotRootNodeName
Definition: constants.h:36
armarx::armem::LegacyRobotStateMemoryAdapter::reportJointTorques
void reportJointTorques(const NameValueMap &, Ice::Long, bool, const Ice::Current &) override
Definition: LegacyRobotStateMemoryAdapter.cpp:181
armarx::armem::LegacyRobotStateMemoryAdapter::onDisconnectComponent
void onDisconnectComponent() override
Definition: LegacyRobotStateMemoryAdapter.cpp:332
armarx::armem::LegacyRobotStateMemoryAdapter::reportPlatformOdometryPose
void reportPlatformOdometryPose(Ice::Float, Ice::Float, Ice::Float, const Ice::Current &) override
Definition: LegacyRobotStateMemoryAdapter.cpp:254
armarx::armem::MemoryID
A memory ID.
Definition: MemoryID.h:47
FramedPose.h
armarx::armem::LegacyRobotStateMemoryAdapter::reportGlobalRobotPose
void reportGlobalRobotPose(const ::armarx::TransformStamped &, const ::Ice::Current &=::Ice::emptyCurrent) override
Definition: LegacyRobotStateMemoryAdapter.cpp:223
armarx::armem::LegacyRobotStateMemoryAdapter::reportJointAccelerations
void reportJointAccelerations(const NameValueMap &, Ice::Long, bool, const Ice::Current &) override
Definition: LegacyRobotStateMemoryAdapter.cpp:189
armarx::armem::LegacyRobotStateMemoryAdapter::reportJointCurrents
void reportJointCurrents(const NameValueMap &, Ice::Long, bool, const Ice::Current &) override
Definition: LegacyRobotStateMemoryAdapter.cpp:197
armarx::VariantType::Long
const VariantTypeId Long
Definition: Variant.h:917
armarx::armem::client::Writer
Helps a memory client sending data to a memory.
Definition: Writer.h:22
armarx::armem::LegacyRobotStateMemoryAdapter::reportJointStatuses
void reportJointStatuses(const NameStatusMap &, Ice::Long, bool, const Ice::Current &) override
Definition: LegacyRobotStateMemoryAdapter.cpp:210
armarx::OdometryFrame
const std::string OdometryFrame
Definition: FramedPose.h:63
armarx::channels::KinematicUnitObserver::jointVelocities
const KinematicUnitDatafieldCreator jointVelocities("jointVelocities")
armarx::armem::LegacyRobotStateMemoryAdapter::reportJointMotorTemperatures
void reportJointMotorTemperatures(const NameValueMap &, Ice::Long, bool, const Ice::Current &) override
Definition: LegacyRobotStateMemoryAdapter.cpp:205
armarx::armem::LegacyRobotStateMemoryAdapter
Definition: LegacyRobotStateMemoryAdapter.h:44
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:95
armarx::control::njoint_controller::platform::platform_follower_controller::NameValueMap
std::map< std::string, float > NameValueMap
Definition: PlatformFollowerController.h:91
armarx::channels::KinematicUnitObserver::jointAngles
const KinematicUnitDatafieldCreator jointAngles("jointAngles")
armarx::channels::KinematicUnitObserver::jointCurrents
const KinematicUnitDatafieldCreator jointCurrents("jointCurrents")
armarx::channels::PlatformUnitObserver::platformPose
const PlatformUnitDatafieldCreator platformPose("platformPose")
armarx::armem::LegacyRobotStateMemoryAdapter::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: LegacyRobotStateMemoryAdapter.cpp:34
armarx::armem::robot_state::constants::localizationCoreSegment
const std::string localizationCoreSegment
Definition: constants.h:29
armarx::armem::LegacyRobotStateMemoryAdapter::onConnectComponent
void onConnectComponent() override
Definition: LegacyRobotStateMemoryAdapter.cpp:308
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::armem::LegacyRobotStateMemoryAdapter::onInitComponent
void onInitComponent() override
Definition: LegacyRobotStateMemoryAdapter.cpp:294
armarx::armem::LegacyRobotStateMemoryAdapter::reportJointVelocities
void reportJointVelocities(const NameValueMap &, Ice::Long, bool, const Ice::Current &) override
Definition: LegacyRobotStateMemoryAdapter.cpp:173
MemoryNameSystem.h
armarx::armem::LegacyRobotStateMemoryAdapter::reportControlModeChanged
void reportControlModeChanged(const NameControlModeMap &, Ice::Long, bool, const Ice::Current &) override
Definition: LegacyRobotStateMemoryAdapter.cpp:160
armarx::channels::KinematicUnitObserver::jointTorques
const KinematicUnitDatafieldCreator jointTorques("jointTorques")
armarx::human::MemoryID
const armem::MemoryID MemoryID
Definition: memory_ids.cpp:29