Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RobotAPI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software
ArmarX
RobotAPI
Commits
3fd21b26
Commit
3fd21b26
authored
9 years ago
by
Mirko Wächter
Browse files
Options
Downloads
Patches
Plain Diff
forces are now visualized
parent
80bfeae2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
source/RobotAPI/components/units/ForceTorqueObserver.cpp
+44
-1
44 additions, 1 deletion
source/RobotAPI/components/units/ForceTorqueObserver.cpp
source/RobotAPI/components/units/ForceTorqueObserver.h
+9
-1
9 additions, 1 deletion
source/RobotAPI/components/units/ForceTorqueObserver.h
with
53 additions
and
2 deletions
source/RobotAPI/components/units/ForceTorqueObserver.cpp
+
44
−
1
View file @
3fd21b26
...
...
@@ -31,6 +31,7 @@
#include
<RobotAPI/libraries/core/checks/ConditionCheckMagnitudeChecks.h>
#include
<RobotAPI/libraries/core/observerfilters/OffsetFilter.h>
#include
<ArmarXCore/observers/variant/DatafieldRef.h>
#include
<RobotAPI/libraries/core/remoterobot/RemoteRobot.h>
#include
<RobotAPI/libraries/core/RobotAPIObjectFactories.h>
...
...
@@ -75,12 +76,48 @@ void ForceTorqueObserver::onInitObserver()
offerConditionCheck
(
"magnitudelarger"
,
new
ConditionCheckMagnitudeLarger
());
offerConditionCheck
(
"magnitudesmaller"
,
new
ConditionCheckMagnitudeSmaller
());
usingProxy
(
"RobotStateComponent"
);
usingTopic
(
"DebugDrawerUpdates"
);
}
void
ForceTorqueObserver
::
onConnectObserver
()
{
assignProxy
(
robot
,
"RobotStateComponent"
);
debugDrawer
=
getTopic
<
DebugDrawerInterfacePrx
>
(
"DebugDrawerUpdates"
);
visualizerTask
=
new
PeriodicTask
<
ForceTorqueObserver
>
(
this
,
&
ForceTorqueObserver
::
visualizerFunction
,
50
,
false
,
"visualizerFunction"
);
localRobot
=
RemoteRobot
::
createLocalClone
(
robot
);
visualizerTask
->
start
();
}
void
ForceTorqueObserver
::
visualizerFunction
()
{
RemoteRobot
::
synchronizeLocalClone
(
localRobot
,
robot
);
auto
channels
=
getAvailableChannels
(
false
);
for
(
auto
&
channel
:
channels
)
{
if
(
localRobot
->
hasRobotNode
(
channel
.
first
))
{
DatafieldRefPtr
field
=
DatafieldRefPtr
::
dynamicCast
(
getForceDatafield
(
channel
.
first
,
Ice
::
Current
()));
FramedDirectionPtr
value
=
field
->
getDataField
()
->
get
<
FramedDirection
>
();
auto
force
=
value
->
toGlobal
(
localRobot
);
// ARMARX_INFO << deactivateSpam(5,channel.first) << "new force" << channel.first << " : " << force->toEigen();
float
forceMag
=
force
->
toEigen
().
norm
()
/
100
;
forceMag
=
std
::
min
(
1.0
f
,
forceMag
);
debugDrawer
->
setArrowVisu
(
"Forces"
,
"Force"
+
channel
.
first
,
new
Vector3
(
localRobot
->
getRobotNode
(
channel
.
first
)
->
getGlobalPose
()),
force
,
DrawColor
{
forceMag
,
1.0
f
-
forceMag
,
0.0
f
,
0.5
f
},
50
,
5
);
}
else
{
// ARMARX_INFO << deactivateSpam(5,channel.first) << "No node name " << channel.first;
}
}
}
...
...
@@ -106,7 +143,7 @@ void ForceTorqueObserver::offerValue(std::string nodeName, const std::string& ty
}
else
{
setDataField
(
id
->
channelName
,
id
->
datafieldName
,
Variant
(
value
));
setDataField
FlatCopy
(
id
->
channelName
,
id
->
datafieldName
,
new
Variant
(
value
));
}
...
...
@@ -232,3 +269,9 @@ DataFieldIdentifierPtr ForceTorqueObserver::getTorqueDatafieldId(const std::stri
DataFieldIdentifierPtr
id
=
new
DataFieldIdentifier
(
getName
(),
channelName
,
datafieldName
);
return
id
;
}
void
ForceTorqueObserver
::
onExitObserver
()
{
if
(
visualizerTask
)
visualizerTask
->
stop
();
}
This diff is collapsed.
Click to expand it.
source/RobotAPI/components/units/ForceTorqueObserver.h
+
9
−
1
View file @
3fd21b26
...
...
@@ -26,6 +26,7 @@
#include
<RobotAPI/interface/units/ForceTorqueUnit.h>
#include
<RobotAPI/libraries/core/FramedPose.h>
#include
<ArmarXCore/observers/Observer.h>
#include
<RobotAPI/interface/visualization/DebugDrawerInterface.h>
namespace
armarx
{
...
...
@@ -68,6 +69,9 @@ namespace armarx
}
void
onInitObserver
();
void
onConnectObserver
();
void
onExitObserver
();
void
visualizerFunction
();
virtual
void
reportSensorValues
(
const
std
::
string
&
sensorNodeName
,
const
FramedDirectionBasePtr
&
forces
,
const
FramedDirectionBasePtr
&
torques
,
const
Ice
::
Current
&
);
...
...
@@ -84,7 +88,10 @@ namespace armarx
private
:
armarx
::
Mutex
dataMutex
;
std
::
string
topicName
;
RobotStateComponentInterfacePrx
robot
;
VirtualRobot
::
RobotPtr
localRobot
;
DebugDrawerInterfacePrx
debugDrawer
;
PeriodicTask
<
ForceTorqueObserver
>::
pointer_type
visualizerTask
;
void
offerValue
(
std
::
string
nodeName
,
const
std
::
string
&
type
,
FramedDirectionBasePtr
value
,
const
DataFieldIdentifierPtr
&
id
);
...
...
@@ -97,6 +104,7 @@ namespace armarx
DataFieldIdentifierPtr
getForceDatafieldId
(
const
std
::
string
&
nodeName
,
const
std
::
string
&
frame
);
DataFieldIdentifierPtr
getTorqueDatafieldId
(
const
std
::
string
&
nodeName
,
const
std
::
string
&
frame
);
};
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment