-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
741c34b
commit a9db589
Showing
5 changed files
with
371 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import numpy as np | ||
from airo_typing import JointConfigurationType | ||
|
||
|
||
def rank_by_distance_to_desirable_configurations( | ||
configurations: list[JointConfigurationType], desirable_configurations: list[JointConfigurationType] | ||
) -> list[JointConfigurationType]: | ||
"""Ranks joint configurations based on their distance to a set of desirable configurations. | ||
Args: | ||
configurations: The list of joint configurations to be ranked. | ||
desirable_configurations: A list of desirable joint configurations. | ||
Returns: | ||
A list of joint configurations, sorted in ascending order of their | ||
distance to the closest desirable configuration. | ||
""" | ||
|
||
distances = [] | ||
for config in configurations: | ||
distances_to_desirable = [ | ||
np.linalg.norm(config - desirable_config) for desirable_config in desirable_configurations | ||
] | ||
min_distance = min(distances_to_desirable) | ||
distances.append(min_distance) | ||
|
||
ranked_configurations = [x for _, x in sorted(zip(distances, configurations))] | ||
return ranked_configurations |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import numpy as np | ||
from airo_drake import calculate_joint_path_length | ||
from airo_typing import JointPathType | ||
|
||
|
||
def choose_shortest_path(paths: list[JointPathType]) -> JointPathType: | ||
"""Selects the shortest path from a list of possible paths. | ||
Args: | ||
paths: A list of potential joint paths. | ||
Returns: | ||
The path from the input list that has the shortest length. | ||
""" | ||
path_lengths = [calculate_joint_path_length(p) for p in paths] | ||
shortest_idx = np.argmin(path_lengths) | ||
return paths[shortest_idx] |
Oops, something went wrong.