Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Trajektorien des menschlichen Aufstehens für die Entwicklung eines kooperativen Assistenzsystems
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ventsislav Dokusanski
Trajektorien des menschlichen Aufstehens für die Entwicklung eines kooperativen Assistenzsystems
Commits
4df21100
Commit
4df21100
authored
9 months ago
by
uquzq
Browse files
Options
Downloads
Patches
Plain Diff
Create a publisher for the pose of the end effector
parent
43ed19ed
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ros2_ws/src/simple_robot_1dof/simple_robot_1dof/forward_kinematics_node_1dof.py
+22
-3
22 additions, 3 deletions
...ot_1dof/simple_robot_1dof/forward_kinematics_node_1dof.py
with
22 additions
and
3 deletions
ros2_ws/src/simple_robot_1dof/simple_robot_1dof/forward_kinematics_node_1dof.py
+
22
−
3
View file @
4df21100
...
...
@@ -22,6 +22,8 @@ class Forward_Kinematics_Node_1Dof(Node):
self
.
point_publisher_
=
self
.
create_publisher
(
Marker
,
'
visualization_marker
'
,
10
)
# create a publisher for the plotjuggler angles
self
.
angle_publisher_
=
self
.
create_publisher
(
Float64
,
'
/angles_1dof/plotjuggler
'
,
10
)
# create a publisher for the pose
self
.
pose_publisher_
=
self
.
create_publisher
(
PoseStamped
,
'
/end_effector_pose
'
,
10
)
#RViz
self
.
path
=
Path
()
self
.
path
.
header
.
frame_id
=
"
map
"
...
...
@@ -35,14 +37,14 @@ class Forward_Kinematics_Node_1Dof(Node):
def
transformation
(
self
):
# Define the desired rotation here
theta
=
-
pi
/
2
theta
=
pi
/
2
# Split theta
theta_fraction
=
self
.
phi
*
theta
self
.
publish_angle
(
theta_fraction
)
# Define the vector
start_vector
=
np
.
array
([
-
1.0
,
0.0
,
0.0
,
1.0
])
start_vector
=
np
.
array
([
1.0
,
0.0
,
0.0
,
1.0
])
# Define the matrix
intermediate_rotation
=
np
.
array
([
...
...
@@ -54,7 +56,9 @@ class Forward_Kinematics_Node_1Dof(Node):
# Calculate the intermediate vectors
intermediate_vector
=
np
.
matmul
(
intermediate_rotation
,
start_vector
)
self
.
publish_pose
(
intermediate_vector
)
self
.
construct_path
(
intermediate_vector
)
def
construct_path
(
self
,
vector
):
...
...
@@ -104,6 +108,21 @@ class Forward_Kinematics_Node_1Dof(Node):
angle_msg
.
data
=
angle
*
180
/
pi
self
.
angle_publisher_
.
publish
(
angle_msg
)
def
publish_pose
(
self
,
vector
):
pose_msg
=
PoseStamped
()
pose_msg
.
header
.
frame_id
=
"
map
"
pose_msg
.
header
.
stamp
=
self
.
get_clock
().
now
().
to_msg
()
pose_msg
.
pose
.
position
.
x
=
vector
[
0
]
pose_msg
.
pose
.
position
.
y
=
vector
[
1
]
pose_msg
.
pose
.
position
.
z
=
vector
[
2
]
pose_msg
.
pose
.
orientation
.
x
=
0.0
pose_msg
.
pose
.
orientation
.
y
=
0.0
pose_msg
.
pose
.
orientation
.
z
=
0.0
pose_msg
.
pose
.
orientation
.
w
=
1.0
self
.
pose_publisher_
.
publish
(
pose_msg
)
def
main
(
args
=
None
):
rclpy
.
init
(
args
=
args
)
node
=
Forward_Kinematics_Node_1Dof
()
...
...
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