Skip to content

Commit

Permalink
fix: typing
Browse files Browse the repository at this point in the history
  • Loading branch information
engnadeau committed Aug 23, 2022
1 parent e346bd3 commit f8e4d22
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions pybotics/optimization.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
"""Optimization module.
isort:skip_file
"""
"""Optimization module."""
from copy import deepcopy
from itertools import repeat
from typing import Sequence, Union, MutableSequence
Expand Down Expand Up @@ -61,7 +58,7 @@ def apply_optimization_vector(self, vector: npt.NDArray[np.float64]) -> None:
# extract vector segments
segments = np.split(
vector, [num_kc_parameters, num_kc_parameters + num_tool_parameters]
)
) # type: ignore
kc_segment = segments[0]
tool_segment = segments[1]
world_segment = segments[2]
Expand Down Expand Up @@ -109,12 +106,15 @@ def compute_absolute_error(
"""Compute the absolute error of a given position."""
pose = robot.fk(q)
actual_position = position_from_matrix(pose)
error = position - actual_position
return float(np.linalg.norm(error))
error = position - actual_position # type: npt.NDArray[np.float64]
result = float(np.linalg.norm(error)) # type: ignore
return result


def compute_absolute_errors(
qs: npt.NDArray[np.float64], positions: npt.NDArray[np.float64], robot: Robot
qs: Sequence[npt.NDArray[np.float64]],
positions: Sequence[npt.NDArray[np.float64]],
robot: Robot,
) -> npt.NDArray[np.float64]:
"""
Compute the absolute errors of a given set of positions.
Expand All @@ -123,7 +123,8 @@ def compute_absolute_errors(
:param positions: Array of Cartesian positions, shape=(n-poses, 3)
:param robot: Robot model
"""
return list(map(compute_absolute_error, qs, positions, repeat(robot)))
result = np.array(map(compute_absolute_error, qs, positions, repeat(robot)))
return result


def compute_relative_error(
Expand Down

0 comments on commit f8e4d22

Please sign in to comment.