RobotStateObserver.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 ArmarX::Core
17 * @author Stefan Ulbrich <stefan dot ulbrich at kit dot edu>, Kai Welke (welke _at_ kit _dot_ edu)
18 * @date 2011 Kai Welke
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
23 #pragma once
24 
25 #include <string>
26 
27 #include <VirtualRobot/VirtualRobot.h>
28 
31 #include <ArmarXCore/interface/observers/VariantBase.h>
34 
35 #include <RobotAPI/interface/core/RobotState.h>
36 #include <RobotAPI/interface/core/RobotStateObserverInterface.h>
37 #include <RobotAPI/interface/units/KinematicUnitInterface.h>
38 
39 namespace armarx
40 {
41 
42  /**
43  * RobotStatePropertyDefinition Property Definitions
44  */
46  {
47  public:
50  {
51  defineOptionalProperty<std::string>(
52  "TCPsToReport",
53  "",
54  "comma seperated list of nodesets' endeffectors, which poses and velocities that "
55  "should be reported. * for all, empty for none");
56  }
57  };
58 
59  using FramedPoseBaseMap = ::std::map<::std::string, ::armarx::FramedPoseBasePtr>;
60 
61  /**
62  * ArmarX RobotStateObserver.
63  *
64  * The RobotStateObserver allows to install conditions on all channel reported by the KinematicUnit.
65  * These include joint angles, velocities, torques and motor temperatures
66  *
67  * The RobotStateObserver retrieves its configuration from a VirtualRobot robot model. Within the model, the joints
68  * which are observer by the unit are define by a robotnodeset
69  */
71  virtual public Observer,
72  virtual public RobotStateObserverInterface
73  {
74  public:
76  // framework hooks
77  void onInitObserver() override;
78  void onConnectObserver() override;
79 
80  PropertyDefinitionsPtr createPropertyDefinitions() override;
81 
82  void setRobot(VirtualRobot::RobotPtr robot);
83 
84  std::string
85  getDefaultName() const override
86  {
87  return "RobotStateObserver";
88  }
89 
90  void updatePoses();
91  void updateNodeVelocities(const NameValueMap& jointVel, long timestampMicroSeconds);
92 
93  protected:
94  void updateVelocityDatafields(const FramedDirectionMap& tcpTranslationVelocities,
95  const FramedDirectionMap& tcpOrientationVelocities);
96 
97  void udpatePoseDatafields(const FramedPoseBaseMap& poseMap);
98 
99  private:
100  std::string robotNodeSetName;
102  VirtualRobot::RobotPtr robot, velocityReportRobot;
103  std::vector<std::pair<VirtualRobot::RobotNodePtr, std::string>> nodesToReport;
104  std::recursive_mutex dataMutex;
105  IceUtil::Time lastVelocityUpdate;
106 
107  // RobotStateObserverInterface interface
108  public:
109  void getPoseDatafield_async(const AMD_RobotStateObserverInterface_getPoseDatafieldPtr& amd,
110  const std::string& nodeName,
111  const Ice::Current&) const override;
112  };
113 
115 } // namespace armarx
armarx::Observer
Baseclass for all ArmarX Observers.
Definition: Observer.h:84
armarx::RobotStateObserverPropertyDefinitions::RobotStateObserverPropertyDefinitions
RobotStateObserverPropertyDefinitions(std::string prefix)
Definition: RobotStateObserver.h:48
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:345
armarx::RobotStateObserver
ArmarX RobotStateObserver.
Definition: RobotStateObserver.h:70
armarx::RobotStateObserver::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: RobotStateObserver.h:85
armarx::FramedPoseBaseMap
::std::map<::std::string, ::armarx::FramedPoseBasePtr > FramedPoseBaseMap
Definition: RobotStateObserver.h:59
Observer.h
IceInternal::Handle< RobotStateObserver >
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
Component.h
armarx::control::njoint_controller::platform::platform_follower_controller::NameValueMap
std::map< std::string, float > NameValueMap
Definition: PlatformFollowerController.h:88
armarx::RobotStateObserverPropertyDefinitions
RobotStatePropertyDefinition Property Definitions.
Definition: RobotStateObserver.h:45
IceUtil::Handle< class PropertyDefinitionContainer >
IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface >
ImportExport.h
ConditionCheck.h
ARMARXCORE_IMPORT_EXPORT
#define ARMARXCORE_IMPORT_EXPORT
Definition: ImportExport.h:38
armarx::ObserverPropertyDefinitions
Definition: Observer.h:49
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:19