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
e348f8c8
Commit
e348f8c8
authored
13 years ago
by
Thomas Moulard
Browse files
Options
Downloads
Patches
Plain Diff
Add tf_publisher.
parent
7d8e6690
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/tf_publisher
+65
-0
65 additions, 0 deletions
scripts/tf_publisher
with
65 additions
and
0 deletions
scripts/tf_publisher
0 → 100755
+
65
−
0
View file @
e348f8c8
#!/usr/bin/env python
#
# This script looks for a particular tf transformation
# and publish it as a TransformStamped topic.
# This may be useful to insert tf frames into dynamic-graph
# through dynamic_graph_bridge.
#
import
roslib
roslib
.
load_manifest
(
'
dynamic_graph_bridge
'
)
import
rospy
import
tf
import
geometry_msgs.msg
def
main
():
rospy
.
init_node
(
'
tf_publisher
'
,
anonymous
=
True
)
frame
=
rospy
.
get_param
(
'
~frame
'
,
''
)
childFrame
=
rospy
.
get_param
(
'
~child_frame
'
,
''
)
topic
=
rospy
.
get_param
(
'
~topic
'
,
''
)
rateSeconds
=
rospy
.
get_param
(
'
~rate
'
,
5
)
if
not
frame
or
not
childFrame
or
not
topic
:
logpy
.
error
(
"
frame, childFrame and topic are required parameters
"
)
return
rate
=
rospy
.
Rate
(
rateSeconds
)
tl
=
tf
.
TransformListener
()
pub
=
rospy
.
Publisher
(
topic
,
geometry_msgs
.
msg
.
TransformStamped
)
transform
=
geometry_msgs
.
msg
.
TransformStamped
()
transform
.
header
.
frame_id
=
frame
transform
.
child_frame_id
=
childFrame
ok
=
False
while
not
rospy
.
is_shutdown
()
and
not
ok
:
try
:
tl
.
waitForTransform
(
childFrame
,
frame
,
rospy
.
Time
(),
rospy
.
Duration
(
0.1
))
ok
=
True
except
tf
.
Exception
,
e
:
rospy
.
logwarn
(
"
waiting for tf transform
"
)
ok
=
False
while
not
rospy
.
is_shutdown
():
time
=
tl
.
getLatestCommonTime
(
frame
,
childFrame
)
(
p
,
q
)
=
tl
.
lookupTransform
(
childFrame
,
frame
,
time
)
transform
.
header
.
seq
+=
1
transform
.
header
.
stamp
=
time
transform
.
transform
.
translation
.
x
=
p
[
0
]
transform
.
transform
.
translation
.
y
=
p
[
1
]
transform
.
transform
.
translation
.
z
=
p
[
2
]
transform
.
transform
.
rotation
.
x
=
q
[
0
]
transform
.
transform
.
rotation
.
y
=
q
[
1
]
transform
.
transform
.
rotation
.
z
=
q
[
2
]
transform
.
transform
.
rotation
.
w
=
q
[
3
]
pub
.
publish
(
transform
)
rate
.
sleep
()
main
()
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