Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Robot 3d SLAM
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Oliver Kania
Robot 3d SLAM
Commits
63cf9f12
Commit
63cf9f12
authored
1 month ago
by
Oliver Kania
Browse files
Options
Downloads
Patches
Plain Diff
added broadcaster node
parent
3c7c6792
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.vscode/c_cpp_properties.json
+20
-0
20 additions, 0 deletions
.vscode/c_cpp_properties.json
.vscode/settings.json
+20
-0
20 additions, 0 deletions
.vscode/settings.json
my_robot_package/tof_tf_caster.py
+62
-0
62 additions, 0 deletions
my_robot_package/tof_tf_caster.py
setup.py
+1
-0
1 addition, 0 deletions
setup.py
with
103 additions
and
0 deletions
.vscode/c_cpp_properties.json
0 → 100644
+
20
−
0
View file @
63cf9f12
{
"configurations"
:
[
{
"browse"
:
{
"databaseFilename"
:
"${default}"
,
"limitSymbolsToIncludedHeaders"
:
false
},
"includePath"
:
[
"/opt/ros/humble/include/**"
,
"/usr/include/**"
],
"name"
:
"ROS"
,
"intelliSenseMode"
:
"gcc-x64"
,
"compilerPath"
:
"/usr/bin/gcc"
,
"cStandard"
:
"gnu11"
,
"cppStandard"
:
"c++14"
}
],
"version"
:
4
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
.vscode/settings.json
0 → 100644
+
20
−
0
View file @
63cf9f12
{
"python.autoComplete.extraPaths"
:
[
"/home/sochi/40_BA_WS/ros2_ws/build/my_sensor_controller"
,
"/home/sochi/40_BA_WS/ros2_ws/install/my_sensor_controller/lib/python3.10/site-packages"
,
"/home/sochi/40_BA_WS/ros2_ws/build/my_robot_package"
,
"/home/sochi/40_BA_WS/ros2_ws/install/my_robot_package/lib/python3.10/site-packages"
,
"/home/sochi/40_BA_WS/ros2_ws/src/my_sensor_controller/install/my_sensor_controller/lib/python3.10/site-packages"
,
"/opt/ros/humble/lib/python3.10/site-packages"
,
"/opt/ros/humble/local/lib/python3.10/dist-packages"
],
"python.analysis.extraPaths"
:
[
"/home/sochi/40_BA_WS/ros2_ws/build/my_sensor_controller"
,
"/home/sochi/40_BA_WS/ros2_ws/install/my_sensor_controller/lib/python3.10/site-packages"
,
"/home/sochi/40_BA_WS/ros2_ws/build/my_robot_package"
,
"/home/sochi/40_BA_WS/ros2_ws/install/my_robot_package/lib/python3.10/site-packages"
,
"/home/sochi/40_BA_WS/ros2_ws/src/my_sensor_controller/install/my_sensor_controller/lib/python3.10/site-packages"
,
"/opt/ros/humble/lib/python3.10/site-packages"
,
"/opt/ros/humble/local/lib/python3.10/dist-packages"
]
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
my_robot_package/tof_tf_caster.py
0 → 100644
+
62
−
0
View file @
63cf9f12
#!/usr/bin/env python3
import
rclpy
from
rclpy.node
import
Node
from
sensor_msgs.msg
import
JointState
from
tf2_ros
import
TransformBroadcaster
from
geometry_msgs.msg
import
TransformStamped
import
math
import
tf_transformations
class
SensorTFBroadcaster
(
Node
):
def
__init__
(
self
):
super
().
__init__
(
'
sensor_tf_broadcaster
'
)
self
.
broadcaster
=
TransformBroadcaster
(
self
)
self
.
subscription
=
self
.
create_subscription
(
JointState
,
'
/joint_states
'
,
self
.
listener_callback
,
10
)
self
.
sensor_offset
=
(
0.1
,
0.0
,
0.1
)
# offset
def
listener_callback
(
self
,
msg
:
JointState
):
try
:
idx
=
msg
.
name
.
index
(
"
shoulder_pan_joint
"
)
angle
=
msg
.
position
[
idx
]
t
=
TransformStamped
()
t
.
header
.
stamp
=
self
.
get_clock
().
now
().
to_msg
()
t
.
header
.
frame_id
=
"
shoulder_pan_joint
"
t
.
child_frame_id
=
"
vl53_frame
"
# Apply static offset
t
.
transform
.
translation
.
x
=
self
.
sensor_offset
[
0
]
t
.
transform
.
translation
.
y
=
self
.
sensor_offset
[
1
]
t
.
transform
.
translation
.
z
=
self
.
sensor_offset
[
2
]
# Rotate sensor with shoulder_pan_joint (around Z axis)
# Combine static rotation (90° pitch, -90° yaw) with joint angle (around Z)
static_quat
=
tf_transformations
.
quaternion_from_euler
(
0
,
1.5708
,
-
1.5708
)
joint_quat
=
tf_transformations
.
quaternion_from_euler
(
angle
,
0
,
0
)
# Multiply quaternions: final = static * joint
quat
=
tf_transformations
.
quaternion_multiply
(
static_quat
,
joint_quat
)
t
.
transform
.
rotation
.
x
=
quat
[
0
]
t
.
transform
.
rotation
.
y
=
quat
[
1
]
t
.
transform
.
rotation
.
z
=
quat
[
2
]
t
.
transform
.
rotation
.
w
=
quat
[
3
]
self
.
broadcaster
.
sendTransform
(
t
)
except
ValueError
:
self
.
get_logger
().
warn
(
"
Joint shoulder_pan_joint not found in JointState
"
)
def
main
(
args
=
None
):
rclpy
.
init
(
args
=
args
)
node
=
SensorTFBroadcaster
()
rclpy
.
spin
(
node
)
node
.
destroy_node
()
rclpy
.
shutdown
()
if
__name__
==
'
__main__
'
:
main
()
This diff is collapsed.
Click to expand it.
setup.py
+
1
−
0
View file @
63cf9f12
...
...
@@ -25,6 +25,7 @@ setup(
'
console_scripts
'
:
[
'
joint_reader = my_robot_package.joint_reader:main
'
,
'
tof_pico_node = my_robot_package.tof_pico_node:main
'
,
'
tof_tf_caster = my_robot_package.tof_tf_caster: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