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
48022a9f
Commit
48022a9f
authored
1 month ago
by
oliverkania
Browse files
Options
Downloads
Patches
Plain Diff
added joint reader and rviz
parent
6921488d
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
launch/urdf_rviz.launch.py
+20
-0
20 additions, 0 deletions
launch/urdf_rviz.launch.py
my_robot_package/joint_reader.py
+58
-0
58 additions, 0 deletions
my_robot_package/joint_reader.py
setup.py
+4
-0
4 additions, 0 deletions
setup.py
with
82 additions
and
0 deletions
launch/urdf_rviz.launch.py
0 → 100644
+
20
−
0
View file @
48022a9f
from
launch
import
LaunchDescription
from
launch_ros.actions
import
Node
def
generate_launch_description
():
return
LaunchDescription
([
Node
(
package
=
'
robot_state_publisher
'
,
executable
=
'
robot_state_publisher
'
,
output
=
'
screen
'
,
parameters
=
[{
'
robot_description
'
:
open
(
'
/home/admim/ros2_ws/install/ur_description/share/ur_description/urdf/ur.urdf.xacro
'
,
'
r
'
).
read
()
}]
),
Node
(
package
=
'
rviz2
'
,
executable
=
'
rviz2
'
,
output
=
'
screen
'
)
])
\ No newline at end of file
This diff is collapsed.
Click to expand it.
my_robot_package/joint_reader.py
0 → 100755
+
58
−
0
View file @
48022a9f
#!/usr/bin/env python3
import
rclpy
import
math
from
rclpy.node
import
Node
from
sensor_msgs.msg
import
JointState
from
rtde_receive
import
RTDEReceiveInterface
class
JointReaderNode
(
Node
):
def
__init__
(
self
):
super
().
__init__
(
'
joint_reader
'
)
# Replace with the IP of your UR simulator VM
self
.
rtde_r
=
RTDEReceiveInterface
(
"
192.168.178.144
"
)
self
.
publisher
=
self
.
create_publisher
(
JointState
,
'
joint_states
'
,
10
)
self
.
timer
=
self
.
create_timer
(
0.1
,
self
.
publish_joint_states
)
# 10 Hz
self
.
get_logger
().
info
(
"
Connected to UR RTDE. Publishing joint states.
"
)
def
publish_joint_states
(
self
):
try
:
# UR joint names (standard 6 DOF)
joint_names
=
[
"
shoulder_pan_joint
"
,
# base
"
shoulder_lift_joint
"
,
# shoulder
"
elbow_joint
"
,
"
wrist_1_joint
"
,
"
wrist_2_joint
"
,
"
wrist_3_joint
"
]
joint_positions
=
None
joint_positions
=
self
.
rtde_r
.
getActualQ
()
# List of 6 joint angles
msg
=
JointState
()
msg
.
header
.
stamp
=
self
.
get_clock
().
now
().
to_msg
()
msg
.
name
=
joint_names
msg
.
position
=
joint_positions
self
.
publisher
.
publish
(
msg
)
joint_degrees
=
[
round
(
math
.
degrees
(
p
),
2
)
for
p
in
joint_positions
]
log
=
"
,
"
.
join
(
f
"
{
n
}
:
{
d
}
°
"
for
n
,
d
in
zip
(
joint_names
,
joint_degrees
))
self
.
get_logger
().
info
(
f
"
Joint angles (deg):
{
log
}
"
)
except
Exception
as
e
:
self
.
get_logger
().
warn
(
f
"
Failed to read joint data:
{
e
}
"
)
def
main
(
args
=
None
):
rclpy
.
init
(
args
=
args
)
node
=
JointReaderNode
()
try
:
rclpy
.
spin
(
node
)
except
KeyboardInterrupt
:
pass
node
.
destroy_node
()
rclpy
.
shutdown
()
if
__name__
==
'
__main__
'
:
main
()
This diff is collapsed.
Click to expand it.
setup.py
+
4
−
0
View file @
48022a9f
from
setuptools
import
find_packages
,
setup
from
glob
import
glob
import
os
package_name
=
'
my_robot_package
'
...
...
@@ -10,6 +12,7 @@ setup(
(
'
share/ament_index/resource_index/packages
'
,
[
'
resource/
'
+
package_name
]),
(
'
share/
'
+
package_name
,
[
'
package.xml
'
]),
(
os
.
path
.
join
(
'
share
'
,
package_name
,
'
launch
'
),
glob
(
'
launch/*.launch.py
'
)),
],
install_requires
=
[
'
setuptools
'
],
zip_safe
=
True
,
...
...
@@ -20,6 +23,7 @@ setup(
tests_require
=
[
'
pytest
'
],
entry_points
=
{
'
console_scripts
'
:
[
'
joint_reader = my_robot_package.joint_reader: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