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
39namespace armarx
40{
41
42 /**
43 * RobotStatePropertyDefinition Property Definitions
44 */
46 {
47 public:
50 {
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
81
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
#define ARMARXCORE_IMPORT_EXPORT
ObserverPropertyDefinitions(std::string prefix)
Definition Observer.h:52
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
void onConnectObserver() override
Framework hook.
PropertyDefinitionsPtr createPropertyDefinitions() override
void onInitObserver() override
Framework hook.
std::string getDefaultName() const override
Retrieve default name of component.
void setRobot(VirtualRobot::RobotPtr robot)
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
::IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface > RobotStateComponentInterfacePrx
IceInternal::Handle< RobotStateObserver > RobotStateObserverPtr
::std::map<::std::string, ::armarx::FramedPoseBasePtr > FramedPoseBaseMap