Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Python3 ArmarX
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software
ArmarX
Python3 ArmarX
Commits
1cc21d48
Commit
1cc21d48
authored
1 week ago
by
Timo Birr
Browse files
Options
Downloads
Patches
Plain Diff
Add new convinience method for euler angles
parent
873d9c64
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
armarx_core/math/transform.py
+32
-0
32 additions, 0 deletions
armarx_core/math/transform.py
with
32 additions
and
0 deletions
armarx_core/math/transform.py
+
32
−
0
View file @
1cc21d48
...
...
@@ -53,6 +53,8 @@ class Transform:
self
.
rot_quat
=
value
elif
value
.
shape
==
(
3
,
3
):
self
.
rot_mat
=
value
elif
value
.
shape
==
(
3
,
):
self
.
rot_mat
=
Transform
.
euler_to_rotation_matrix
(
value
[
0
],
value
[
1
],
value
[
2
])
else
:
raise
ValueError
(
f
"
Invalid rotation value:
{
value
}
"
)
...
...
@@ -172,3 +174,33 @@ class Transform:
f
"
Expected
{
name
}
of shape
{
shape_str
}
, but got array of shape
{
value
.
shape
}
.
"
)
return
value
@classmethod
def
euler_to_rotation_matrix
(
cls
,
roll
:
float
,
pitch
:
float
,
yaw
:
float
)
->
np
.
ndarray
:
"""
Converts roll, pitch, yaw (in radians) to a 3x3 rotation matrix.
Parameters:
roll (float): Rotation around the x-axis (φ)
pitch (float): Rotation around the y-axis (θ)
yaw (float): Rotation around the z-axis (ψ)
Returns:
np.ndarray: 3x3 rotation matrix
"""
# Compute individual rotation matrices
R_x
=
np
.
array
([[
1
,
0
,
0
],
[
0
,
np
.
cos
(
roll
),
-
np
.
sin
(
roll
)],
[
0
,
np
.
sin
(
roll
),
np
.
cos
(
roll
)]])
R_y
=
np
.
array
([[
np
.
cos
(
pitch
),
0
,
np
.
sin
(
pitch
)],
[
0
,
1
,
0
],
[
-
np
.
sin
(
pitch
),
0
,
np
.
cos
(
pitch
)]])
R_z
=
np
.
array
([[
np
.
cos
(
yaw
),
-
np
.
sin
(
yaw
),
0
],
[
np
.
sin
(
yaw
),
np
.
cos
(
yaw
),
0
],
[
0
,
0
,
1
]])
# Compute full rotation matrix: R = Rz * Ry * Rx
R
=
R_z
@
R_y
@
R_x
return
R
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