Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features/alignment optimization #96

Merged
merged 165 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 161 commits
Commits
Show all changes
165 commits
Select commit Hold shift + click to select a range
3eb2e12
fix canting vectors and remove 3d to 4d conversion because it is now …
MarleneBusch Nov 11, 2024
ee07044
add 3d to 4d conversion methods and lat long function
MarleneBusch Nov 11, 2024
e54b27f
add wgs84 constants
MarleneBusch Nov 11, 2024
b1785b3
fix dimensions
MarleneBusch Nov 12, 2024
b0991eb
add orientation from motor positions function and rename others
MarleneBusch Nov 12, 2024
0bf08f9
add orientation from motor positions function and rename others
MarleneBusch Nov 12, 2024
1b1dce1
add some paint data files
MarleneBusch Nov 12, 2024
73cdd48
remove measurement data from git
MarleneBusch Nov 12, 2024
1011cb8
add power plant coordiantes
MarleneBusch Nov 12, 2024
3a16490
add alignment optimizer
MarleneBusch Nov 12, 2024
597fd94
add power plant coordiantes
MarleneBusch Nov 12, 2024
b931a61
add paint to surface converter
MarleneBusch Nov 12, 2024
06ce3fe
add power plant coordiantes
MarleneBusch Nov 12, 2024
7564f35
new scenario + generatorfor paint data
MarleneBusch Nov 12, 2024
3676362
adaption to changes in kinematic
MarleneBusch Nov 12, 2024
6fe4f39
test for the calibration
MarleneBusch Nov 12, 2024
5572d94
fix indexing
MarleneBusch Nov 13, 2024
e687237
new function for lat lon to m but not working yet
MarleneBusch Nov 13, 2024
948c60e
add power plant config and generate new h5 files
MarleneBusch Nov 13, 2024
73d54bd
formatting
MarleneBusch Nov 13, 2024
83fbd47
formatting
MarleneBusch Nov 13, 2024
f68b603
formatting - needs to be updated
MarleneBusch Nov 13, 2024
999275e
add power plant coordinates
MarleneBusch Nov 13, 2024
1aa00ba
formatting
MarleneBusch Nov 13, 2024
e3a621d
formatting
MarleneBusch Nov 13, 2024
55cd70b
update bitmaps
MarleneBusch Nov 13, 2024
7ed28c7
formatting
MarleneBusch Nov 13, 2024
56685cb
remove forward() method from actuators and rename everything to motor…
MarleneBusch Nov 13, 2024
01b509d
change order of computation
MarleneBusch Nov 13, 2024
ccf9392
remove s require grad statement
MarleneBusch Nov 13, 2024
df1c6e5
add center of mass function
MarleneBusch Nov 13, 2024
49bb6f3
add motor position and ray tracing optimizer
MarleneBusch Nov 13, 2024
406b06f
remove inplace operation
MarleneBusch Nov 13, 2024
eb66239
cuda:3 for testing - neds to be removed somewhen
MarleneBusch Nov 13, 2024
530b359
make center of mass differentiable
MarleneBusch Nov 14, 2024
d2b1d21
alignment optimizer now also with raytracing possible
MarleneBusch Nov 14, 2024
e93f92e
add test for optimizer with raytracing, not done yet
MarleneBusch Nov 14, 2024
9b2b7a8
add pytest for converting WGS84 coordinates to enu
MarleneBusch Nov 15, 2024
6f61db3
replace math with torch
MarleneBusch Nov 15, 2024
c43a7ab
rename WGS84 converter
MarleneBusch Nov 15, 2024
f4e4643
change WGS84 converter name
MarleneBusch Nov 15, 2024
b534360
change WGS84 converter name
MarleneBusch Nov 15, 2024
2299a7f
generate new scenario with correct data
MarleneBusch Nov 15, 2024
03eb9e1
add alignment with motor position methods
MarleneBusch Nov 19, 2024
58b879c
add alignment with motor position methods
MarleneBusch Nov 19, 2024
3f90f8e
fix bugs in both optimization loops
MarleneBusch Nov 19, 2024
0738768
change dtype in WGS84 converter
MarleneBusch Nov 19, 2024
4913745
add measurement data for tests
MarleneBusch Nov 19, 2024
79e022f
remove math from generators and generate new scenarios
MarleneBusch Nov 19, 2024
7248cb6
update bitmaps
MarleneBusch Nov 19, 2024
1733ad8
refactor method
MarleneBusch Nov 19, 2024
a8d46f6
add expected values for alignment optimizer
MarleneBusch Nov 19, 2024
efd72e0
cleanup test
MarleneBusch Nov 19, 2024
b2d1e38
fix values
MarleneBusch Nov 19, 2024
535a143
add default device
MarleneBusch Nov 19, 2024
43415e6
change cuda:3 to cuda
MarleneBusch Nov 19, 2024
46e05f9
remove bitmap.png
MarleneBusch Nov 19, 2024
4ca2588
fix bug in torch.load()
MarleneBusch Nov 20, 2024
e1dafea
fix all pre-commit hook issues
MarleneBusch Nov 20, 2024
a18a6f5
remove unused deflec files
MarleneBusch Nov 20, 2024
cc7f46a
check all paths and fix them
MarleneBusch Nov 20, 2024
a719fa2
new structure to save data in the tests and tutorials directories whe…
MarleneBusch Nov 20, 2024
ba51634
remove old files
MarleneBusch Nov 20, 2024
da09bf2
remove paint_to_surface_converter.py from codecovergae because I saw …
MarleneBusch Nov 20, 2024
b613012
change alignment optimizer test to only compare optimized parameters …
MarleneBusch Nov 20, 2024
47e6936
apply pre-commit hooks
MarleneBusch Nov 20, 2024
a11c401
refactor
MarleneBusch Nov 26, 2024
65976a6
add getter functions for testing and tutorials
MarleneBusch Nov 26, 2024
7ea3704
start refactoring, but not done yet
MarleneBusch Nov 26, 2024
9b5ea64
add tutorials
MarleneBusch Nov 26, 2024
3908869
fix logger
MarleneBusch Nov 26, 2024
18e1437
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 26, 2024
d5a492a
remove cuda:3 statement
MarleneBusch Nov 27, 2024
173320a
new expected optimized parameters
MarleneBusch Nov 27, 2024
0034b3f
refactor
MarleneBusch Nov 27, 2024
7164025
apply pre-commit hooks
MarleneBusch Nov 27, 2024
fff8391
fix
MarleneBusch Nov 27, 2024
7a38f09
add better comments/docstrings to linear actuator and rename variable…
MarleneBusch Dec 4, 2024
8d95e6b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 4, 2024
615ebe3
fix docstring
MarleneBusch Dec 4, 2024
cad5feb
add datatypes for surface_points and surface_normals in the docstring…
MarleneBusch Dec 4, 2024
d8b0cd9
Merge branch 'features/alignment_optimization' of github.com:ARTIST-A…
MarleneBusch Dec 4, 2024
3dcb5b9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 4, 2024
936cd1d
change actuator parameter names
MarleneBusch Dec 4, 2024
f44817d
change actuator parameter names
MarleneBusch Dec 4, 2024
e873cd2
add optional caluclation withou squeeze
MarleneBusch Dec 4, 2024
3a9d535
Merge branch 'features/alignment_optimization' of github.com:ARTIST-A…
MarleneBusch Dec 4, 2024
60e317b
fix docstrings
MarleneBusch Dec 4, 2024
8f6cf31
add datatype for plane_e and plane_u
MarleneBusch Dec 4, 2024
e67cbd7
remove private method from docstring
MarleneBusch Dec 4, 2024
15a0d25
add suggestions from pull review
MarleneBusch Dec 4, 2024
105adb9
refactor actuator parameter names
MarleneBusch Dec 4, 2024
2319d14
add scenario with updated actuator parameter names
MarleneBusch Dec 4, 2024
2cd10c6
remove cuda:1
MarleneBusch Dec 4, 2024
294fbdc
change assertions to Value errors
MarleneBusch Dec 5, 2024
61f8a21
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 5, 2024
a4a3cee
add new test
MarleneBusch Dec 5, 2024
6486fb7
correct tests
MarleneBusch Dec 5, 2024
6eed277
fix condition for ValueError
MarleneBusch Dec 5, 2024
9df08e7
apply pre-commit hooks
MarleneBusch Dec 5, 2024
ba2e979
add full stop to log message
mcw92 Dec 6, 2024
d410832
fix formatting for RTD
mcw92 Dec 6, 2024
efe283f
add missing forward methos
MarleneBusch Dec 6, 2024
8260d89
fix test
MarleneBusch Dec 6, 2024
0659d7b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 6, 2024
cc0bea7
move wgs constants to util function
MarleneBusch Dec 6, 2024
a52668f
fix docstrings
MarleneBusch Dec 6, 2024
ad0e16d
fix issue for facets with different amount of points
MarleneBusch Dec 6, 2024
5f6b908
change parameter of getter function fpr kinematic parameters
MarleneBusch Dec 6, 2024
5ef7054
adapt get calibration data method
MarleneBusch Dec 6, 2024
dcc8618
new surface converter
MarleneBusch Dec 6, 2024
354eb4b
add utils function
MarleneBusch Dec 6, 2024
cfb98b1
add periods to docstrings
MarleneBusch Dec 6, 2024
1c02d49
add conftest and move device fixture there
MarleneBusch Dec 6, 2024
89a5114
paint_loader
MarleneBusch Dec 6, 2024
1b8f1b0
Merge branch 'features/alignment_optimization' of github.com:ARTIST-A…
MarleneBusch Dec 6, 2024
8224bd5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 6, 2024
af8b215
update expected bitmaps, generate new scenarios and adapt scenario ge…
MarleneBusch Dec 11, 2024
cc30c94
add new keys
MarleneBusch Dec 11, 2024
060dc18
move device fixture to conftest
MarleneBusch Dec 11, 2024
2cae9af
refactoring, rename variables, fix slicing, remove certain parameters
MarleneBusch Dec 11, 2024
c895f09
fix logging
MarleneBusch Dec 11, 2024
cccecdc
adapt kinematic initial orientation
MarleneBusch Dec 11, 2024
055143f
remove kinematic offsets
MarleneBusch Dec 11, 2024
9c1ac1f
add paint loader
MarleneBusch Dec 11, 2024
f819a86
add util functions
MarleneBusch Dec 11, 2024
2b15953
merge paint and stral surface converters
MarleneBusch Dec 11, 2024
d67ccf7
fix tests
MarleneBusch Dec 11, 2024
f0f61da
bug fix
MarleneBusch Dec 11, 2024
7e8f5d1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 11, 2024
5b7a439
apply pre-commit hooks
MarleneBusch Dec 11, 2024
acf9841
Merge branch 'features/alignment_optimization' of github.com:ARTIST-A…
MarleneBusch Dec 11, 2024
dd2b0cb
remove cuda:3
MarleneBusch Dec 11, 2024
19ef902
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 11, 2024
dfc23a1
fix typo
MarleneBusch Dec 11, 2024
daaeb30
change get center of mass function
MarleneBusch Dec 11, 2024
4694915
add calibration data extractor
MarleneBusch Dec 11, 2024
4c883a9
fix tests and add new tests
MarleneBusch Dec 11, 2024
a73fc18
fix bug
MarleneBusch Dec 11, 2024
aa71964
add keys
MarleneBusch Dec 11, 2024
918d476
remove old function
MarleneBusch Dec 11, 2024
86285b2
apply pre-commit hooks
MarleneBusch Dec 11, 2024
071deba
add pytest-mock dependency
MarleneBusch Dec 11, 2024
d22e049
remove surface converter and paint loader from code cov
MarleneBusch Dec 11, 2024
5201b33
add value error test
MarleneBusch Dec 11, 2024
cfc989a
add tests for ValueErrors
MarleneBusch Dec 12, 2024
180e2bb
rename function
MarleneBusch Dec 12, 2024
41e6e07
rename function
MarleneBusch Dec 12, 2024
89f3776
remove double ValueError check
MarleneBusch Dec 12, 2024
97738e1
remove double ValueError check
MarleneBusch Dec 12, 2024
5e87868
test for all forward methods
MarleneBusch Dec 12, 2024
ab2846e
pretty formatting of data
kalebphipps Dec 13, 2024
e5db029
number tutorial name
kalebphipps Dec 13, 2024
6e6cfe3
Merge branch 'main' into features/alignment_optimization
kalebphipps Dec 13, 2024
78e40e9
fix keys
MarleneBusch Dec 13, 2024
3584eed
fix type hints
MarleneBusch Dec 13, 2024
6eb9109
refactor surface converter
MarleneBusch Dec 13, 2024
b612666
adapt to refactores surface converter
MarleneBusch Dec 13, 2024
d4b4294
add more tests and test cases
MarleneBusch Dec 13, 2024
c4e9a21
add surface converter and paint loader to code coverage
MarleneBusch Dec 13, 2024
7718e60
add another test
MarleneBusch Dec 13, 2024
6b92379
move pytest-mock to dev dependency
kalebphipps Dec 16, 2024
b2eb1a0
add converter to test surface from points
kalebphipps Dec 16, 2024
a5239c6
fix docstrings
kalebphipps Dec 16, 2024
03dc00d
fix test dependencies
kalebphipps Dec 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 30 additions & 39 deletions artist/field/actuator.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Actuator(torch.nn.Module):
----------
joint_number : int
Descriptor (number) of the joint.
clockwise : bool
clockwise_axis_movement : bool
Turning direction of the joint.
increment : torch.Tensor
The stroke length change per motor step.
Expand All @@ -20,30 +20,30 @@ class Actuator(torch.nn.Module):
offset : torch.Tensor
The offset between the linear actuator's pivoting point and the point
around which the actuator is allowed to pivot.
radius : torch.Tensor
pivot_radius : torch.Tensor
The actuator's pivoting radius.
phi_0 : torch.Tensor
initial_angle : torch.Tensor
The angle that the actuator introduces to the manipulated coordinate system at the initial stroke length.

Methods
-------
motor_position_to_angle()
Calculate the joint angle for a given motor position.
angle_to_motor_position()
Calculate the motor position for a given angle.
forward()
The forward kinematic.
motor_steps_to_angles()
Translate motor steps to a joint angle.
angles_to_motor_steps()
Translate a joint angle to motor steps.
Specify the forward pass.
"""

def __init__(
self,
joint_number: int,
clockwise: bool,
clockwise_axis_movement: bool,
increment: torch.Tensor,
initial_stroke_length: torch.Tensor,
offset: torch.Tensor,
radius: torch.Tensor,
phi_0: torch.Tensor,
pivot_radius: torch.Tensor,
initial_angle: torch.Tensor,
) -> None:
"""
Initialize an abstract actuator.
Expand All @@ -59,7 +59,7 @@ def __init__(
----------
joint_number : int
Descriptor (number) of the joint.
clockwise : bool
clockwise_axis_movement : bool
Turning direction of the joint.
increment : torch.Tensor
The stroke length change per motor step.
Expand All @@ -68,30 +68,30 @@ def __init__(
offset : torch.Tensor
The offset between the linear actuator's pivoting point and the point
around which the actuator is allowed to pivot.
radius : torch.Tensor
pivot_radius : torch.Tensor
The actuator's pivoting radius.
phi_0 : torch.Tensor
initial_angle : torch.Tensor
The angle that the actuator introduces to the manipulated coordinate system at the initial stroke length.
"""
super().__init__()
self.joint_number = joint_number
self.clockwise = clockwise
self.clockwise_axis_movement = clockwise_axis_movement
self.increment = increment
self.initial_stroke_length = initial_stroke_length
self.offset = offset
self.radius = radius
self.phi_0 = phi_0
self.pivot_radius = pivot_radius
self.initial_angle = initial_angle

def motor_steps_to_angles(
self, motor_steps: torch.Tensor, device: Union[torch.device, str] = "cuda"
def motor_position_to_angle(
self, motor_position: torch.Tensor, device: Union[torch.device, str] = "cuda"
) -> torch.Tensor:
"""
Translate motor steps to a joint angle.
Calculate the joint angle for a given motor position.

Parameters
----------
motor_steps : torch.Tensor
The motor steps.
motor_position : torch.Tensor
The motor position.
device : Union[torch.device, str]
The device on which to initialize tensors (default is cuda).

Expand All @@ -102,16 +102,16 @@ def motor_steps_to_angles(
"""
raise NotImplementedError("Must be overridden!")

def angles_to_motor_steps(
self, angles: torch.Tensor, device: Union[torch.device, str] = "cuda"
def angle_to_motor_position(
self, angle: torch.Tensor, device: Union[torch.device, str] = "cuda"
) -> torch.Tensor:
"""
Translate a joint angle to motor steps.
Calculate the motor position for a given angle.

Parameters
----------
angles : torch.Tensor
The joint angles.
angle : torch.Tensor
The joint angle.
device : Union[torch.device, str]
The device on which to initialize tensors (default is cuda).

Expand All @@ -122,22 +122,13 @@ def angles_to_motor_steps(
"""
raise NotImplementedError("Must be overridden!")

def forward(
self, actuator_pos: torch.Tensor, device: Union[torch.device, str] = "cuda"
) -> torch.Tensor:
def forward(self) -> None:
"""
Perform forward kinematic.

Parameters
----------
actuator_pos : torch.Tensor
The position of the actuator.
device : Union[torch.device, str]
The device on which to initialize tensors (default is cuda).
Specify the forward pass.

Raises
------
NotImplementedError
This abstract method must be overridden.
Whenever called.
"""
raise NotImplementedError("Must be overridden!")
40 changes: 28 additions & 12 deletions artist/field/actuator_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ class ActuatorArray(torch.nn.Module):
----------
actuator_list : List[Actuator]
The list of actuators to be wrapped.

Methods
-------
forward()
Specify the forward pass.
"""

def __init__(
Expand Down Expand Up @@ -56,19 +61,19 @@ def __init__(
# Try to load an actuator from the given configuration. This will fail, if ARTIST
# does not recognize the actuator type defined in the configuration.
try:
actuator_object = actuator_type_mapping[actuator_config.actuator_type]
actuator_object = actuator_type_mapping[actuator_config.type]
# Check if the actuator configuration contains actuator parameters and initialize an actuator with
# these parameters.
if actuator_config.actuator_parameters is not None:
if actuator_config.parameters is not None:
actuator_array.append(
actuator_object(
joint_number=i + 1,
clockwise=actuator_config.actuator_clockwise,
increment=actuator_config.actuator_parameters.increment,
initial_stroke_length=actuator_config.actuator_parameters.initial_stroke_length,
offset=actuator_config.actuator_parameters.offset,
radius=actuator_config.actuator_parameters.radius,
phi_0=actuator_config.actuator_parameters.phi_0,
clockwise_axis_movement=actuator_config.clockwise_axis_movement,
increment=actuator_config.parameters.increment,
initial_stroke_length=actuator_config.parameters.initial_stroke_length,
offset=actuator_config.parameters.offset,
pivot_radius=actuator_config.parameters.pivot_radius,
initial_angle=actuator_config.parameters.initial_angle,
)
)
# If the actuator config does not contain actuator parameters, initialize an actuator with default
Expand All @@ -80,17 +85,28 @@ def __init__(
actuator_array.append(
actuator_object(
joint_number=i + 1,
clockwise=actuator_config.actuator_clockwise,
clockwise_axis_movement=actuator_config.clockwise_axis_movement,
increment=torch.tensor(0.0, device=device),
initial_stroke_length=torch.tensor(0.0, device=device),
offset=torch.tensor(0.0, device=device),
radius=torch.tensor(0.0, device=device),
phi_0=torch.tensor(0.0, device=device),
pivot_radius=torch.tensor(0.0, device=device),
initial_angle=torch.tensor(0.0, device=device),
)
)
except KeyError:
raise KeyError(
f"Currently the selected actuator type: {actuator_config.actuator_type} is not supported."
f"Currently the selected actuator type: {actuator_config.type} is not supported."
)

self.actuator_list = actuator_array

def forward(self) -> None:
"""
Specify the forward pass.

Raises
------
NotImplementedError
Whenever called.
"""
raise NotImplementedError("Not Implemented!")
59 changes: 25 additions & 34 deletions artist/field/actuator_ideal.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,48 +13,48 @@ class IdealActuator(Actuator):

Methods
-------
motor_steps_to_angles()
Calculate the angles given motor steps.
angles_to_motor_steps()
Calculate the motor steps given the angles.
motor_position_to_angle()
Calculate the joint angle for a given motor position.
angle_to_motor_position()
Calculate the motor position for a given angle.
forward()
Perform the forward kinematic.
Specify the forward pass.

See Also
--------
:class:`Actuator` : The parent class.
"""

def motor_steps_to_angles(
self, motor_steps: torch.Tensor, device: Union[torch.device, str] = "cuda"
def motor_position_to_angle(
self, motor_position: torch.Tensor, device: Union[torch.device, str] = "cuda"
) -> torch.Tensor:
"""
Translate motor steps to a joint angle.
Calculate the joint angle for a given motor position.

Parameters
----------
motor_steps : torch.Tensor
The motor steps.
motor_position : torch.Tensor
The motor position.
device : Union[torch.device, str]
The device on which to initialize tensors (default is cuda).

Returns
-------
torch.Tensor
The joint angle.
The joint angle corresponding to the motor position.
"""
return motor_steps
return motor_position

def angles_to_motor_steps(
self, angles: torch.Tensor, device: Union[torch.device, str] = "cuda"
def angle_to_motor_position(
self, angle: torch.Tensor, device: Union[torch.device, str] = "cuda"
) -> torch.Tensor:
"""
Translate a joint angle to motor steps.
Calculate the motor position for a given angle.

Parameters
----------
angles : torch.Tensor
The joint angles.
angle : torch.Tensor
The joint angle.
device : Union[torch.device, str]
The device on which to initialize tensors (default is cuda).

Expand All @@ -63,24 +63,15 @@ def angles_to_motor_steps(
torch.Tensor
The motor steps.
"""
return angles
return angle

def forward(
self, actuator_pos: torch.Tensor, device: Union[torch.device, str] = "cuda"
) -> torch.Tensor:
def forward(self) -> None:
"""
Perform the forward kinematic for an ideal actuator.

Parameters
----------
actuator_pos : torch.Tensor
The position of the actuator.
device : Union[torch.device, str]
The device on which to initialize tensors (default is cuda).
Specify the forward pass.

Returns
-------
torch.Tensor
The required angles.
Raises
------
NotImplementedError
Whenever called.
"""
return actuator_pos
raise NotImplementedError("Not Implemented!")
Loading
Loading