cgse-coordinates 0.17.2__py3-none-any.whl → 0.17.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,8 +8,7 @@ Those methods start with the name `hexapod_`, e.g. `hexapod_goto_zero_position()
8
8
 
9
9
  """
10
10
 
11
- from typing import List
12
-
11
+ import numpy as np
13
12
  from egse.coordinates.refmodel import ReferenceFrameModel
14
13
 
15
14
  HEXUSR = "hexusr"
@@ -21,107 +20,99 @@ HEXOBUSR = "hexobusr"
21
20
 
22
21
  class CSLReferenceFrameModel(ReferenceFrameModel):
23
22
  """
24
- The CSL Reference Frame Model is a specific reference model that adds convenience methods
25
- for manipulating the Hexapod PUNA which is part of the overall CSL Setup.
23
+ The CSL reference Frame Model is a specific reference model that adds convenience methods for manipulating the
24
+ Hexapod PUNA which is part of the overall CSL Setup.
26
25
  """
27
26
 
28
27
  _DEGREES_DEFAULT = ReferenceFrameModel._DEGREES_DEFAULT
29
28
 
30
- def _create_obusr(self):
29
+ def _create_obusr(self) -> None:
30
+ """Creates the Object User Reference Frame if it does not exist yet."""
31
+
31
32
  if HEXOBUSR in self:
32
33
  return
33
34
 
34
35
  hexusr = self.get_frame(HEXUSR)
35
36
  hexobj = self.get_frame(HEXOBJ)
36
37
 
37
- transformation = hexusr.getActiveTransformationTo(hexobj)
38
+ transformation = hexusr.get_active_transformation_to(hexobj)
38
39
 
39
- self.add_frame(HEXOBUSR, transformation=transformation, ref=HEXUSR)
40
+ self.add_frame(HEXOBUSR, transformation=transformation, reference=HEXUSR)
40
41
  self.add_link(HEXOBUSR, HEXOBJ)
41
42
 
42
- def hexapod_move_absolute(self, translation, rotation, degrees=_DEGREES_DEFAULT):
43
- """
44
- Move/define the Object Coordinate System position and orientation expressed
45
- in the invariant user coordinate system.
43
+ def hexapod_move_absolute(self, translation: np.ndarray, rotation: np.ndarray, degrees: bool = _DEGREES_DEFAULT):
44
+ """Moves/defines the Object Coordinate System expressed in the invariant User Coordinate System.
46
45
 
47
- The rotation centre coincides with the Object Coordinates System origin and
48
- the movements are controlled with translation components at first (Tx, Ty, tZ)
49
- and then the rotation components (Rx, Ry, Rz).
46
+ The rotation centre coincides with the Object Coordinates System origin and the movements are controlled with
47
+ translation components first (Tx, Ty, tZ) and then the rotation components (Rx, Ry, Rz).
50
48
 
51
49
  Args:
52
- translation: the translation vector
53
- rotation: the rotation vector
54
- degrees: use degrees [default: True]
50
+ translation (np.ndarray): Translation vector.
51
+ rotation (np.ndarray): Rotation vector.
52
+ degrees (bool): Indicates whether the rotation angles are specified in degrees, rather than radians.
55
53
  """
56
54
 
57
55
  self.move_absolute_self(HEXOBUSR, translation, rotation, degrees=degrees)
58
56
 
59
- def hexapod_move_relative_object(self, translation, rotation, degrees=_DEGREES_DEFAULT):
60
- """
61
- Hexapod Command:
62
- Move the object relative to its current object position and orientation.
57
+ def hexapod_move_relative_object(
58
+ self, translation: np.ndarray, rotation: np.ndarray, degrees: bool = _DEGREES_DEFAULT
59
+ ):
60
+ """Moves the object relative to its current position and orientation
63
61
 
64
62
  The relative movement is expressed in the object coordinate system.
65
63
 
66
64
  Args:
67
- translation: the translation vector
68
- rotation: the rotation vector
69
- degrees: use degrees [default: True]
65
+ translation (np.ndarray): Translation vector.
66
+ rotation (np.ndarray): Rotation vector.
67
+ degrees (bool): Indicates whether the rotation angles are specified in degrees, rather than radians.
70
68
  """
71
69
 
72
70
  self.move_relative_self(HEXOBJ, translation, rotation, degrees=degrees)
73
71
 
74
- def hexapod_move_relative_user(self, translation, rotation, degrees=_DEGREES_DEFAULT):
75
- """
76
- Hexapod Command:
77
- Move the object relative to its current object position and orientation.
72
+ def hexapod_move_relative_user(
73
+ self, translation: np.ndarray, rotation: np.ndarray, degrees: bool = _DEGREES_DEFAULT
74
+ ) -> None:
75
+ """Moves the object relative to its current object position and orientation.
78
76
 
79
77
  The relative movement is expressed in the (invariant) user coordinate system.
80
78
 
81
79
  Args:
82
- translation: the translation vector
83
- rotation: the rotation vector
84
- degrees: use degrees [default: True]
80
+ translation (np.ndarray): Translation vector.
81
+ rotation (np.ndarray): Rotation vector.
82
+ degrees (bool): Indicates whether the rotation angles are specified in degrees, rather than radians.
85
83
  """
86
84
 
87
85
  self.move_relative_other_local(HEXOBJ, HEXUSR, translation, rotation, degrees=degrees)
88
86
 
89
87
  def hexapod_configure_coordinates(
90
88
  self,
91
- usr_trans: List[float],
92
- usr_rot: List[float],
93
- obj_trans: List[float],
94
- obj_rot: List[float],
95
- ):
96
- """
97
- Change the definition of the User Coordinate System and the Object Coordinate System in
98
- the Hexapod.
99
-
100
- The parameters tx_u, ty_u, tz_u, rx_u, ry_u, rz_u are used to define the user coordinate
101
- system
102
- relative to the Machine Coordinate System and the parameters tx_o, ty_o, tz_o, rx_o,
103
- ry_o, rz_o
104
- are used to define the Object Coordinate System relative to the Platform Coordinate System.
89
+ usr_trans: np.ndarray,
90
+ usr_rot: np.ndarray,
91
+ obj_trans: np.ndarray,
92
+ obj_rot: np.ndarray,
93
+ ) -> None:
94
+ """Changes the definition of the User Coordinate System and the Object Coordinate System in the hexapod.
105
95
 
96
+ Args:
97
+ usr_trans (np.ndarray): Translation vector used to define the User Coordinate System relative to the Machine Coordinate System.
98
+ usr_rot (np.ndarray): Rotation vector used to define the User Coordinate System relative to the Machine Coordinate System.
99
+ obj_trans (np.ndarray): Translation vector used to define the Object Coordinate System relative to the Platform Coordinate System.
100
+ obj_rot (np.ndarray): Rotation vector used to define the Object Coordinate System relative to the Platoform Coordinate System.
106
101
  """
107
102
 
108
103
  self.remove_link(HEXUSR, HEXMEC)
109
104
  self.remove_link(HEXOBJ, HEXPLT)
110
- self.get_frame(HEXUSR).setTranslationRotation(usr_trans, usr_rot)
111
- self.get_frame(HEXOBJ).setTranslationRotation(obj_trans, obj_rot)
105
+ self.get_frame(HEXUSR).set_translation_rotation(usr_trans, usr_rot)
106
+ self.get_frame(HEXOBJ).set_translation_rotation(obj_trans, obj_rot)
112
107
  self.add_link(HEXUSR, HEXMEC)
113
108
  self.add_link(HEXOBJ, HEXPLT)
114
109
 
115
- def hexapod_goto_zero_position(self):
116
- """
117
- Ask the hexapod to go to the zero position.
118
- """
110
+ def hexapod_goto_zero_position(self) -> None:
111
+ """Instructs the hexapod to go to its zero position"""
119
112
 
120
- self.move_absolute_self(HEXPLT, translation=[0, 0, 0], rotation=[0, 0, 0])
113
+ self.move_absolute_self(HEXPLT, translation=np.array([0, 0, 0]), rotation=np.array([0, 0, 0]))
121
114
 
122
- def hexapod_goto_retracted_position(self):
123
- """
124
- Ask the hexapod to go to its retracted position.
125
- """
115
+ def hexapod_goto_retracted_position(self) -> None:
116
+ """Instructs the hexapod to go to its retracted position."""
126
117
 
127
- self.move_absolute_self(HEXPLT, translation=[0, 0, -20], rotation=[0, 0, 0])
118
+ self.move_absolute_self(HEXPLT, translation=np.array([0, 0, -20]), rotation=np.array([0, 0, 0]))
@@ -1,28 +1,15 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- """
4
- Created on Sat Oct 3 11:53:23 2020
5
-
6
- @author: pierre
7
- """
8
-
9
1
  import sys
10
2
  import pandas
11
3
 
12
4
  from egse.setup import Setup
13
5
 
14
6
 
15
- def laser_tracker_to_dict(filexls, setup: Setup):
16
- """
17
- laser_tracker_to_dict(filexls)
18
-
19
- INPUT
20
-
21
- filexls : CSL - provided excell file (from a laser tracker)
22
-
23
- OUTPUT
7
+ def laser_tracker_to_dict(file_xls: str, setup: Setup):
8
+ """Reads the laser tracker file and returns a dictionary of reference frames.
24
9
 
25
- dictionary compatible with egse.coordinates.dict_to_ref_model
10
+ Args:
11
+ file_xls (str): Path to the laser tracker file. This is an excell sheet provided by CSL.
12
+ setup (Setup): Setup object containing the default reference frames.
26
13
 
27
14
  Known Features:
28
15
  - no link can be included:
@@ -37,6 +24,8 @@ def laser_tracker_to_dict(filexls, setup: Setup):
37
24
  - the names of the reference frames are returned lowercase, without '_'
38
25
  ("Master" is an exception)
39
26
 
27
+ Returns:
28
+ Dictionary of reference frames compatible with egse.coordinates.dict_to_ref_model.
40
29
  """
41
30
 
42
31
  # Predefined model -- gliso ~ master
@@ -72,22 +61,24 @@ def laser_tracker_to_dict(filexls, setup: Setup):
72
61
 
73
62
  # Read input file
74
63
 
75
- pan = pandas.read_excel(filexls, sheet_name="Data", usecols="A:D", names=["desc", "x", "y", "z"])
64
+ pan = pandas.read_excel(file_xls, sheet_name="Data", usecols="A:D", names=["desc", "x", "y", "z"])
76
65
 
77
- nrows = pan.shape[0]
66
+ num_rows = pan.shape[0]
78
67
 
79
68
  desc = pan["desc"].values
80
69
  colx = pan["x"].values
81
70
  coly = pan["y"].values
82
71
  colz = pan["z"].values
83
72
 
84
- refFrames = dict()
85
- refFrames["Master"] = "ReferenceFrame//([0.0000,0.0000,0.0000 | [0.0000,0.0000,0.0000 | Master | Master | [])"
73
+ reference_frames = dict()
74
+ reference_frames["Master"] = (
75
+ "ReferenceFrame//([0.0000,0.0000,0.0000 | [0.0000,0.0000,0.0000 | Master | Master | [])"
76
+ )
86
77
 
87
78
  links = "[]"
88
79
 
89
80
  i, frame = -1, -1
90
- while i < nrows:
81
+ while i < num_rows:
91
82
  i += 1
92
83
 
93
84
  try:
@@ -111,10 +102,10 @@ def laser_tracker_to_dict(filexls, setup: Setup):
111
102
  else:
112
103
  ref = "None"
113
104
 
114
- refFrames[name] = f"ReferenceFrame//({translation} | {rotation} | {name} | {ref} | {links})"
105
+ reference_frames[name] = f"ReferenceFrame//({translation} | {rotation} | {name} | {ref} | {links})"
115
106
 
116
107
  except:
117
108
  print(f"Frame extraction issue after row {i} : {desc[i]}")
118
109
  print(sys.exc_info())
119
110
 
120
- return refFrames
111
+ return reference_frames