Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dynamic_graph_bridge
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stack Of Tasks
dynamic_graph_bridge
Commits
ac658382
Commit
ac658382
authored
6 years ago
by
Joseph Mirabel
Committed by
Joseph Mirabel
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add RosTfListener
parent
84ae4143
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CMakeLists.txt
+1
-0
1 addition, 0 deletions
CMakeLists.txt
src/ros_tf_listener.cpp
+9
-0
9 additions, 0 deletions
src/ros_tf_listener.cpp
src/ros_tf_listener.hh
+107
-0
107 additions, 0 deletions
src/ros_tf_listener.hh
with
117 additions
and
0 deletions
CMakeLists.txt
+
1
−
0
View file @
ac658382
...
...
@@ -133,6 +133,7 @@ endmacro()
compile_plugin
(
ros_publish
)
compile_plugin
(
ros_subscribe
)
compile_plugin
(
ros_queued_subscribe
)
compile_plugin
(
ros_tf_listener
)
compile_plugin
(
ros_time
)
compile_plugin
(
ros_joint_state
)
pkg_config_use_dependency
(
ros_joint_state pinocchio
)
...
...
This diff is collapsed.
Click to expand it.
src/ros_tf_listener.cpp
0 → 100644
+
9
−
0
View file @
ac658382
#include
"dynamic_graph_bridge/ros_init.hh"
#include
"ros_tf_listener.hh"
#include
<dynamic-graph/factory.h>
namespace
dynamicgraph
{
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN
(
RosTfListener
,
"RosTfListener"
);
}
This diff is collapsed.
Click to expand it.
src/ros_tf_listener.hh
0 → 100644
+
107
−
0
View file @
ac658382
#ifndef DYNAMIC_GRAPH_ROS_TF_LISTENER_HH
# define DYNAMIC_GRAPH_ROS_TF_LISTENER_HH
# include <boost/bind.hpp>
# include <tf/transform_listener.h>
# include <dynamic-graph/entity.h>
# include <dynamic-graph/signal.h>
# include <dynamic-graph/command-bind.h>
# include <sot/core/matrix-geometry.hh>
namespace
dynamicgraph
{
class
RosTfListener
;
namespace
internal
{
struct
TransformListenerData
{
typedef
Signal
<
sot
::
MatrixHomogeneous
,
int
>
signal_t
;
tf
::
TransformListener
&
listener
;
const
std
::
string
toFrame
,
fromFrame
;
tf
::
StampedTransform
transform
;
signal_t
signal
;
TransformListenerData
(
tf
::
TransformListener
&
l
,
const
std
::
string
&
to
,
const
std
::
string
&
from
,
const
std
::
string
&
signame
)
:
listener
(
l
)
,
toFrame
(
to
)
,
fromFrame
(
from
)
,
signal
(
signame
)
{
signal
.
setFunction
(
boost
::
bind
(
&
TransformListenerData
::
getTransform
,
this
,
_1
,
_2
));
}
sot
::
MatrixHomogeneous
&
getTransform
(
sot
::
MatrixHomogeneous
&
res
,
int
time
)
{
static
const
ros
::
Time
rosTime
(
0
);
try
{
listener
.
lookupTransform
(
toFrame
,
fromFrame
,
rosTime
,
transform
);
}
catch
(
const
tf
::
TransformException
&
ex
)
{
res
.
setIdentity
();
ROS_ERROR
(
"Enable to get transform at time %i: %s"
,
time
,
ex
.
what
());
}
for
(
sot
::
MatrixHomogeneous
::
Index
r
=
0
;
r
<
3
;
++
r
)
{
for
(
sot
::
MatrixHomogeneous
::
Index
c
=
0
;
c
<
3
;
++
c
)
res
.
linear
()(
r
,
c
)
=
transform
.
getBasis
().
getRow
(
r
)[
c
];
res
.
translation
()[
r
]
=
transform
.
getOrigin
()[
r
];
}
return
res
;
}
};
}
// end of internal namespace.
class
RosTfListener
:
public
Entity
{
DYNAMIC_GRAPH_ENTITY_DECL
();
public:
typedef
internal
::
TransformListenerData
TransformListenerData
;
RosTfListener
(
const
std
::
string
&
name
)
:
Entity
(
name
)
{
std
::
string
docstring
=
"
\n
"
" Add a signal containing the transform between two frames.
\n
"
"
\n
"
" Input:
\n
"
" - to : frame name
\n
"
" - from: frame name,
\n
"
" - signalName: the signal name in dynamic-graph"
"
\n
"
;
addCommand
(
"add"
,
command
::
makeCommandVoid3
(
*
this
,
&
RosTfListener
::
add
,
docstring
));
}
~
RosTfListener
()
{
for
(
Map_t
::
const_iterator
_it
=
listenerDatas
.
begin
();
_it
!=
listenerDatas
.
end
();
++
_it
)
delete
_it
->
second
;
}
void
add
(
const
std
::
string
&
to
,
const
std
::
string
&
from
,
const
std
::
string
&
signame
)
{
if
(
listenerDatas
.
find
(
signame
)
!=
listenerDatas
.
end
())
throw
std
::
invalid_argument
(
"A signal "
+
signame
+
" already exists in RosTfListener "
+
getName
());
boost
::
format
signalName
(
"RosTfListener(%1%)::output(MatrixHomo)::%2%"
);
signalName
%
getName
()
%
signame
;
TransformListenerData
*
tld
=
new
TransformListenerData
(
listener
,
to
,
from
,
signalName
.
str
());
signalRegistration
(
tld
->
signal
);
listenerDatas
[
signame
]
=
tld
;
}
private
:
typedef
std
::
map
<
std
::
string
,
TransformListenerData
*>
Map_t
;
Map_t
listenerDatas
;
tf
::
TransformListener
listener
;
};
}
// end of namespace dynamicgraph.
#endif // DYNAMIC_GRAPH_ROS_TF_LISTENER_HH
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