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 
27 #include <ArmarXCore/interface/observers/VariantBase.h>
28 #include <RobotAPI/interface/units/KinematicUnitInterface.h>
29 #include <RobotAPI/interface/core/RobotStateObserverInterface.h>
30 #include <RobotAPI/interface/core/RobotState.h>
33 
34 #include <VirtualRobot/VirtualRobot.h>
35 
36 #include <string>
37 
38 namespace armarx
39 {
40 
41  /**
42  * RobotStatePropertyDefinition Property Definitions
43  */
46  {
47  public:
50  {
51  defineOptionalProperty<std::string>("TCPsToReport", "", "comma seperated list of nodesets' endeffectors, which poses and velocities that should be reported. * for all, empty for none");
52  }
53  };
54 
55  using FramedPoseBaseMap = ::std::map< ::std::string, ::armarx::FramedPoseBasePtr>;
56 
57  /**
58  * ArmarX RobotStateObserver.
59  *
60  * The RobotStateObserver allows to install conditions on all channel reported by the KinematicUnit.
61  * These include joint angles, velocities, torques and motor temperatures
62  *
63  * The RobotStateObserver retrieves its configuration from a VirtualRobot robot model. Within the model, the joints
64  * which are observer by the unit are define by a robotnodeset
65  */
67  virtual public Observer,
68  virtual public RobotStateObserverInterface
69  {
70  public:
72  // framework hooks
73  void onInitObserver() override;
74  void onConnectObserver() override;
75 
76  PropertyDefinitionsPtr createPropertyDefinitions() override;
77 
78  void setRobot(VirtualRobot::RobotPtr robot);
79 
80  std::string getDefaultName() const override
81  {
82  return "RobotStateObserver";
83  }
84 
85  void updatePoses();
86  void updateNodeVelocities(const NameValueMap& jointVel, long timestampMicroSeconds);
87  protected:
88 
89  void updateVelocityDatafields(const FramedDirectionMap& tcpTranslationVelocities, const FramedDirectionMap& tcpOrientationVelocities);
90 
91  void udpatePoseDatafields(const FramedPoseBaseMap& poseMap);
92  private:
93  std::string robotNodeSetName;
95  VirtualRobot::RobotPtr robot, velocityReportRobot;
96  std::vector<std::pair<VirtualRobot::RobotNodePtr, std::string> > nodesToReport;
97  std::recursive_mutex dataMutex;
98  IceUtil::Time lastVelocityUpdate;
99 
100  // RobotStateObserverInterface interface
101  public:
102  void getPoseDatafield_async(
103  const AMD_RobotStateObserverInterface_getPoseDatafieldPtr& amd,
104  const std::string& nodeName,
105  const Ice::Current&) const override;
106  };
107 
109 }
110 
armarx::Observer
Baseclass for all ArmarX Observers.
Definition: Observer.h:80
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:333
armarx::RobotStateObserver
ArmarX RobotStateObserver.
Definition: RobotStateObserver.h:66
armarx::RobotStateObserver::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: RobotStateObserver.h:80
armarx::navigation::platform_controller::platform_global_trajectory::NameValueMap
std::map< std::string, float > NameValueMap
Definition: PlatformGlobalTrajectoryController.h:93
Observer.h
IceInternal::Handle< RobotStateObserver >
armarx::FramedPoseBaseMap
::std::map< ::std::string, ::armarx::FramedPoseBasePtr > FramedPoseBaseMap
Definition: RobotStateObserver.h:55
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
Component.h
armarx::RobotStateObserverPropertyDefinitions
RobotStatePropertyDefinition Property Definitions.
Definition: RobotStateObserver.h:44
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:50
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18