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
31#include <RobotAPI/interface/armem/addon/LegacyRobotStateMemoryAdapterInterface.h>
32
33// ArmarX
35
36#include <RobotAPI/interface/armem/mns/MemoryNameSystemInterface.h>
42
43namespace armarx::armem
44{
46 virtual public armarx::Component,
47 virtual public robot_state::LegacyRobotStateMemoryAdapterInterface
48 {
49 public:
50 /// @see armarx::ManagedIceObject::getDefaultName()
51 std::string getDefaultName() const override;
52
53 void reportControlModeChanged(const NameControlModeMap&,
54 Ice::Long,
55 bool,
56 const Ice::Current&) override;
57 void reportJointAngles(const NameValueMap&, Ice::Long, bool, const Ice::Current&) override;
58 void
59 reportJointVelocities(const NameValueMap&, Ice::Long, bool, const Ice::Current&) override;
60 void reportJointTorques(const NameValueMap&, Ice::Long, bool, const Ice::Current&) override;
61 void reportJointAccelerations(const NameValueMap&,
62 Ice::Long,
63 bool,
64 const Ice::Current&) override;
65 void
66 reportJointCurrents(const NameValueMap&, Ice::Long, bool, const Ice::Current&) override;
67 void reportJointMotorTemperatures(const NameValueMap&,
68 Ice::Long,
69 bool,
70 const Ice::Current&) override;
71 void
72 reportJointStatuses(const NameStatusMap&, Ice::Long, bool, const Ice::Current&) override;
73
74 // void reportPlatformPose(const PlatformPose &, const Ice::Current &) override;
75 void
76 reportPlatformVelocity(Ice::Float, Ice::Float, Ice::Float, const Ice::Current&) override;
77 void reportPlatformOdometryPose(Ice::Float,
78 Ice::Float,
79 Ice::Float,
80 const Ice::Current&) override;
81
82 void reportGlobalRobotPose(const ::armarx::TransformStamped&,
83 const ::Ice::Current& = ::Ice::emptyCurrent) override;
84
85 protected:
86 /// @see PropertyUser::createPropertyDefinitions()
88
89 /// @see armarx::ManagedIceObject::onInitComponent()
90 void onInitComponent() override;
91
92 /// @see armarx::ManagedIceObject::onConnectComponent()
93 void onConnectComponent() override;
94
95 /// @see armarx::ManagedIceObject::onDisconnectComponent()
96 void onDisconnectComponent() override;
97
98 /// @see armarx::ManagedIceObject::onExitComponent()
99 void onExitComponent() override;
100
101 private:
102 void commitArmar3RobotDescription();
103
104 void updateTimestamps(long dataGeneratedUs);
105 void checkUpdateAndSendToMemory();
106
107 private:
108 // Update to send to the memory
109 struct Update
110 {
111 std::map<std::string, float> jointAngles = {};
112 std::map<std::string, float> jointVelocities = {};
113 std::map<std::string, float> jointTorques = {};
114 std::map<std::string, float> jointAccelerations = {};
115 std::map<std::string, float> jointCurrents = {};
116 armarx::PlatformPose platformPose = {};
117 std::tuple<float, float, float> platformVelocity = {0, 0, 0};
118 std::tuple<float, float, float> platformOdometryPose = {0, 0, 0};
119 };
120
121 // Update
122 bool updateChanged = true;
123 double _timestampUpdateFirstModifiedInUs;
124 Update update;
125
126 // Component properties
127 struct Properties
128 {
129 std::string memoryNameSystemName = "MemoryNameSystem";
130 std::string robotStateMemoryName = "RobotState";
131 int frequency = 100;
132 };
133
134 Properties properties;
135
136 // RunningTask
138
139 // Memory
140 MemoryID propEntityID =
143 "Armar3",
144 "Armar3");
145 MemoryID locEntityID = MemoryID(
148 "Armar3",
150
151 armem::client::Writer memoryWriter;
152
153 mutable std::mutex updateMutex;
154 };
155} // namespace armarx::armem
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition Component.h:94
IceUtil::Handle< PeriodicTask< T > > pointer_type
Shared pointer type for convenience.
void reportJointAccelerations(const NameValueMap &, Ice::Long, bool, const Ice::Current &) override
void reportJointStatuses(const NameStatusMap &, Ice::Long, bool, const Ice::Current &) override
void reportGlobalRobotPose(const ::armarx::TransformStamped &, const ::Ice::Current &=::Ice::emptyCurrent) override
void reportJointCurrents(const NameValueMap &, Ice::Long, bool, const Ice::Current &) override
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void reportControlModeChanged(const NameControlModeMap &, Ice::Long, bool, const Ice::Current &) override
void reportJointMotorTemperatures(const NameValueMap &, Ice::Long, bool, const Ice::Current &) override
void reportPlatformOdometryPose(Ice::Float, Ice::Float, Ice::Float, const Ice::Current &) override
void reportJointAngles(const NameValueMap &, Ice::Long, bool, const Ice::Current &) override
void reportJointVelocities(const NameValueMap &, Ice::Long, bool, const Ice::Current &) override
void reportPlatformVelocity(Ice::Float, Ice::Float, Ice::Float, const Ice::Current &) override
void reportJointTorques(const NameValueMap &, Ice::Long, bool, const Ice::Current &) override
Helps a memory client sending data to a memory.
Definition Writer.h:23
const std::string localizationCoreSegment
Definition constants.h:29
const std::string proprioceptionCoreSegment
Definition constants.h:30
std::string const OdometryFrame
Definition FramedPose.h:66
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.