ForceTorqueObserver.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::
17* @author Mirko Waechter ( mirko.waechter at kit dot edu)
18* @date 2013
19* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20* GNU General Public License
21*/
22
23#pragma once
24
25#include <mutex>
26
28
29#include <RobotAPI/interface/units/ForceTorqueUnit.h>
30#include <RobotAPI/interface/visualization/DebugDrawerInterface.h>
32
33namespace armarx
34{
35 /**
36 * \class ForceTorqueObserverPropertyDefinitions
37 * \brief
38 */
40 {
41 public:
44 {
45 defineRequiredProperty<std::string>("ForceTorqueTopicName",
46 "Name of the ForceTorqueUnit Topic");
48 "VisualizeForce", true, "Visualize the force with an arrow in the debug drawer");
50 "RobotUpdateFrequency", 50, "Update frequency of the local robot");
51 defineOptionalProperty<int>("VisualizeForceUpdateFrequency",
52 30,
53 "Frequency with which the force is visualized");
55 "ForceVisualizerFactor",
56 0.01f,
57 "Factor by which the forces are scaled to fit into 0..1 (only for visulization) ");
59 "MaxExpectedTorqueValue",
60 30,
61 "The torque visualization circle reaches the full circle at this value");
63 "TorqueVisuDeadZone", 1, "Torques below this threshold are not visualized.");
65 "MaxForceArrowLength", 150, "Length of the force visu arrow in mm");
67 "RobotStateComponentName",
68 "RobotStateComponent",
69 "Name of the RobotStateComponent that should be used");
71 "SensorRobotNodeMapping",
72 "",
73 "Triplets of sensor node name, target frame robot node name and optional channel "
74 "name: Sensor values are also reported in the frame of the robot node: e. g. "
75 "SensorName:RobotNodeName[:ChannelName],SensorName2:RobotNodeName2[:ChannelName2]");
76 }
77 };
78
79 /**
80 * \class ForceTorqueObserver
81 * \ingroup RobotAPI-SensorActorUnits-observers
82 * \brief Observer monitoring Force/Torque values
83 *
84 * The ForceTorqueObserver monitors F/T values published by ForceTorqueUnit-implementations and offers condition checks on these values.
85 * Available condition checks are: *updated*, *larger*, *equals*, *smaller* and *magnitudelarger*.
86 */
88 virtual public Observer,
89 virtual public ForceTorqueUnitObserverInterface
90 {
91 public:
93
94 void setTopicName(std::string topicName);
95
96 // framework hooks
97 std::string
98 getDefaultName() const override
99 {
100 return "ForceTorqueUnitObserver";
101 }
102
103 void onInitObserver() override;
104 void onConnectObserver() override;
105 void onExitObserver() override;
106
107 void visualizerFunction();
108
109 void reportSensorValues(const std::string& sensorNodeName,
110 const FramedDirectionBasePtr& forces,
111 const FramedDirectionBasePtr& torques,
112 const Ice::Current&) override;
113
114 /**
115 * @see PropertyUser::createPropertyDefinitions()
116 */
118
119 private:
120 void updateRobot();
121
122 std::mutex dataMutex;
123 std::string topicName;
125 VirtualRobot::RobotPtr localRobot;
126 DebugDrawerInterfacePrx debugDrawer;
129 // One sensor can be reported in multiple frames => multimap
130 std::multimap<std::string, std::pair<std::string, std::string>> sensorRobotNodeMapping;
131
132 void offerValue(const std::string& nodeName,
133 const std::string& type,
134 const FramedDirectionBasePtr& value,
135 const DataFieldIdentifierPtr& id);
136
137 // ForceTorqueUnitObserverInterface interface
138 public:
139 DatafieldRefBasePtr
140 createNulledDatafield(const DatafieldRefBasePtr& forceTorqueDatafieldRef,
141 const Ice::Current&) override;
142
143 DatafieldRefBasePtr getForceDatafield(const std::string& nodeName,
144 const Ice::Current&) override;
145 DatafieldRefBasePtr getTorqueDatafield(const std::string& nodeName,
146 const Ice::Current&) override;
147
148 DataFieldIdentifierPtr getForceDatafieldId(const std::string& nodeName,
149 const std::string& frame);
150 DataFieldIdentifierPtr getTorqueDatafieldId(const std::string& nodeName,
151 const std::string& frame);
152
153
154 // ManagedIceObject interface
155 protected:
156 void onDisconnectComponent() override;
157 };
158} // namespace armarx
void reportSensorValues(const std::string &sensorNodeName, const FramedDirectionBasePtr &forces, const FramedDirectionBasePtr &torques, const Ice::Current &) override
void onConnectObserver() override
Framework hook.
void setTopicName(std::string topicName)
void onExitObserver() override
Framework hook.
void onDisconnectComponent() override
Hook for subclass.
DatafieldRefBasePtr getForceDatafield(const std::string &nodeName, const Ice::Current &) override
DatafieldRefBasePtr getTorqueDatafield(const std::string &nodeName, const Ice::Current &) override
DataFieldIdentifierPtr getTorqueDatafieldId(const std::string &nodeName, const std::string &frame)
PropertyDefinitionsPtr createPropertyDefinitions() override
void onInitObserver() override
Framework hook.
DatafieldRefBasePtr createNulledDatafield(const DatafieldRefBasePtr &forceTorqueDatafieldRef, const Ice::Current &) override
DataFieldIdentifierPtr getForceDatafieldId(const std::string &nodeName, const std::string &frame)
std::string getDefaultName() const override
Retrieve default name of component.
ObserverPropertyDefinitions(std::string prefix)
Definition Observer.h:52
IceUtil::Handle< PeriodicTask< T > > pointer_type
Shared pointer type for convenience.
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)
PropertyDefinition< PropertyType > & defineRequiredProperty(const std::string &name, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
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< DataFieldIdentifier > DataFieldIdentifierPtr
Typedef of DataFieldIdentifierPtr as IceInternal::Handle<DataFieldIdentifier> for convenience.
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface > DebugDrawerInterfacePrx