Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
RoboQualityController
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
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
RoboCT (Public)
RoboQuality
RoboQualityController
Commits
2159d229
Commit
2159d229
authored
8 months ago
by
Simon Wittl
Browse files
Options
Downloads
Patches
Plain Diff
added static broadcaster
parent
f29feedf
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
package.xml
+6
-0
6 additions, 0 deletions
package.xml
rq_controller/tf2/__init__.py
+0
-0
0 additions, 0 deletions
rq_controller/tf2/__init__.py
rq_controller/tf2/static_broadcaster.py
+73
-0
73 additions, 0 deletions
rq_controller/tf2/static_broadcaster.py
setup.py
+1
-0
1 addition, 0 deletions
setup.py
with
80 additions
and
0 deletions
package.xml
+
6
−
0
View file @
2159d229
...
...
@@ -12,6 +12,12 @@
<test_depend>
ament_pep257
</test_depend>
<test_depend>
python3-pytest
</test_depend>
<exec_depend>
geometry_msgs
</exec_depend>
<exec_depend>
python3-numpy
</exec_depend>
<exec_depend>
rclpy
</exec_depend>
<exec_depend>
tf2_ros_py
</exec_depend>
<exec_depend>
turtlesim
</exec_depend>
<export>
<build_type>
ament_python
</build_type>
</export>
...
...
This diff is collapsed.
Click to expand it.
rq_controller/tf2/__init__.py
0 → 100644
+
0
−
0
View file @
2159d229
This diff is collapsed.
Click to expand it.
rq_controller/tf2/static_broadcaster.py
0 → 100644
+
73
−
0
View file @
2159d229
import
math
import
sys
from
geometry_msgs.msg
import
TransformStamped
import
numpy
as
np
import
rclpy
from
rclpy.node
import
Node
from
tf2_ros.static_transform_broadcaster
import
StaticTransformBroadcaster
class
StaticFramePublisher
(
Node
):
"""
Broadcast transforms that never change.
This example publishes transforms from `world` to a static turtle frame.
The transforms are only published once at startup, and are constant for all
time.
"""
def
__init__
(
self
,
frame
,
position
,
quaternion
,
name
:
str
=
'
static_broadcaster
'
,
parent_frame
:
str
=
'
world
'
):
super
().
__init__
(
name
)
self
.
tf_static_broadcaster
=
StaticTransformBroadcaster
(
self
)
# Publish static transforms once at startup
self
.
make_transforms
(
frame
,
position
.
split
(
"
"
),
quaternion
.
split
(
"
"
),
parent_frame
)
def
make_transforms
(
self
,
frame
,
position
,
quaternion
,
parent_frame
):
t
=
TransformStamped
()
t
.
header
.
stamp
=
self
.
get_clock
().
now
().
to_msg
()
t
.
header
.
frame_id
=
parent_frame
t
.
child_frame_id
=
frame
t
.
transform
.
translation
.
x
=
float
(
position
[
0
])
t
.
transform
.
translation
.
y
=
float
(
position
[
1
])
t
.
transform
.
translation
.
z
=
float
(
position
[
2
])
t
.
transform
.
rotation
.
x
=
float
(
quaternion
[
0
])
t
.
transform
.
rotation
.
y
=
float
(
quaternion
[
1
])
t
.
transform
.
rotation
.
z
=
float
(
quaternion
[
2
])
t
.
transform
.
rotation
.
w
=
float
(
quaternion
[
3
])
self
.
tf_static_broadcaster
.
sendTransform
(
t
)
def
main
(
args
=
None
):
logger
=
rclpy
.
logging
.
get_logger
(
'
logger
'
)
rclpy
.
init
(
args
=
args
)
node
=
rclpy
.
create_node
(
'
static_broadcaster
'
)
parent_frame
=
node
.
declare_parameter
(
'
parent_frame
'
,
'
world
'
).
value
frame
=
node
.
declare_parameter
(
'
frame
'
,
'
object
'
).
value
name
=
node
.
declare_parameter
(
'
name
'
,
'
static_broadcaster
'
).
value
position
=
node
.
declare_parameter
(
'
position
'
,
'
0 0 0
'
).
value
quaternion
=
node
.
declare_parameter
(
'
quaternion
'
,
'
0 0 0 1
'
).
value
node
=
StaticFramePublisher
(
frame
,
position
,
quaternion
,
name
,
parent_frame
)
try
:
rclpy
.
spin
(
node
)
except
KeyboardInterrupt
:
pass
rclpy
.
shutdown
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
setup.py
+
1
−
0
View file @
2159d229
...
...
@@ -20,6 +20,7 @@ setup(
tests_require
=
[
'
pytest
'
],
entry_points
=
{
'
console_scripts
'
:
[
'
tf_static_broadcaster = rq_controller.tf2.static_broadcaster: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