Skip to content

Commit

Permalink
Overwrite str function for pose models
Browse files Browse the repository at this point in the history
  • Loading branch information
andchiind committed Feb 21, 2024
1 parent 3067890 commit 50ace03
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/alitra/models/orientation.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,9 @@ def from_rotation(rotation: Rotation, frame: Frame) -> Orientation:
:return: Orientation object
"""
return Orientation(*rotation.as_quat(), frame=frame) # type: ignore

def __str__(self):
"""
:return: Unique string representation of the orientation, ignoring the frame
"""
return "[" + str(self.x) + "," + str(self.y) + "," + str(self.z) + "," + str(self.w) + "]"
6 changes: 6 additions & 0 deletions src/alitra/models/pose.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,9 @@ def from_array(pos_array: np.ndarray, quat_array: np.ndarray, frame: Frame) -> P
Orientation.from_quat_array(quat_array, frame),
frame,
)

def __str__(self):
"""
:return: Unique string representation of the pose
"""
return "pos:" + str(self.position) + ", ori: " + str(self.orientation)
6 changes: 6 additions & 0 deletions src/alitra/models/position.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,9 @@ def from_array(position_array: np.ndarray, frame: Frame) -> Positions:
Position(x=position[0], y=position[1], z=position[2], frame=frame)
)
return Positions(positions=positions, frame=frame)

def __str__(self):
"""
:return: Unique string representation of the position, ignoring the frame
"""
return "(" + str(self.x) + "," + str(self.y) + "," + str(self.z) + ")"
50 changes: 50 additions & 0 deletions temp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from pathlib import Path

import numpy as np

from alitra import Frame, MapAlignment, Position, Transform, Translation, align_maps
from alitra.transform import Rotation

here = Path(__file__).parent.resolve()

'''
0.046175 0.998933 0.000000 246.629578
-0.998933 0.046175 0.000000 322.594238
0.000000 0.000000 1.000000 0.00000
0.000000 0.000000 0.000000 1.000000
'''
# E247453mm,N322511mm,U36001mm -> x=0.11907593905116448, y=0.8190074941458545, z=-0.176361
# E228668mm,N316922mm,U36052mm -> x=4.8833662578143295, y=-18.191902104254204, z=-0.12536099999999806
# E237508mm,N295502mm,U37667mm -> x=26.66857454840731, y=-10.294643102836075, z=1.489639000000004
# Path(here.joinpath("./test_data/test_map_robot.json"))
# map_path = Path(here.joinpath("./jsv1_p1_ap430_east.json"))
# map_alignment: MapAlignment = MapAlignment.from_config(map_path)
asset_frame = Frame("asset")
robot_frame = Frame("robot")
# transform: Transform = align_maps(map_alignment.map_from, map_alignment.map_to, "z")
rotation = Rotation.from_euler(seq="ZYX", angles=np.array([-87.5, 0, 0]), degrees=True)
translation: Translation = Translation(
x=246.629578, y=322.594238, z=36.177361, from_=robot_frame, to_=asset_frame
)
transform = Transform(
translation=translation, from_=robot_frame, to_=asset_frame, rotation=rotation
)
test_point: Position = Position(x=237.508, y=295.502, z=37.667, frame=asset_frame)
asd = transform.transform_position(test_point, from_=asset_frame, to_=robot_frame)
print(asd)

# 20185.046875, y=5239.305176, z=14.383026 -> 0 0 0
# E20179544mm,N5241228mm,U14971mm
# E20179402mm,N5245235mm,U14978mm
# E20183271mm,N5234000mm,U14413mm
# E20185765mm,N5234008mm,U15981mm


# P1
# E20185834mm,N5256737mm,U14978mm
# P2
# E20179285mm,N5250001mm,U14654mm
# P3
# E20179233mm,N5230268mm,U14980mm
# P4
# E20189729mm,N5228768mm,U14653mm

0 comments on commit 50ace03

Please sign in to comment.