forked from epfl-lasa/control-libraries
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: integrate collision detection feature into robot model (#163)
* feat: add headers * feat: implement source code * feat: add cpp tests * feat: add meshes * feat: add python bindings * feat: test collisions in python * fix: rename ur5e folder * fix: Dockerfile cache ID * 7.3.4 -> 7.3.5 * Update CHANGELOG * Update source/robot_model/include/robot_model/Model.hpp Co-authored-by: Dominic Reber <71256590+domire8@users.noreply.github.com> * fix: apply review changes * fix: move import from hpp to cpp * feat: update tests * fix: remove un-needed imports * fix: urdf ros control blocks * 7.3.6 -> 7.3.7 * Update CHANGELOG * fix: update doc strings * Update CHANGELOG.md Co-authored-by: Enrico Eberhard <32450951+eeberhard@users.noreply.github.com> * fix: optional parameter * fix: changelog * fix: create two Model constructors * fix: remove ambiguity in binding * fix: adjust doc string * fix: indentation * fix: nitpicks * 7.3.6 -> 7.3.7 * fix: apply nitpicks from code review Co-authored-by: Enrico Eberhard <32450951+eeberhard@users.noreply.github.com> * fix: add flag for copy constructor * feat: add default flag * fix: suggestions from code review Co-authored-by: Dominic Reber <71256590+domire8@users.noreply.github.com> * fix: space between namings Co-authored-by: Dominic Reber <71256590+domire8@users.noreply.github.com> * 7.3.7 -> 7.3.8 * fix: remove space Co-authored-by: Dominic Reber <71256590+domire8@users.noreply.github.com> * 7.3.8 -> 7.3.10 --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Dominic Reber <71256590+domire8@users.noreply.github.com> Co-authored-by: Dominic Reber <dominic@aica.tech> Co-authored-by: Enrico Eberhard <32450951+eeberhard@users.noreply.github.com>
- Loading branch information
1 parent
504922a
commit 852f164
Showing
30 changed files
with
789 additions
and
165 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
7.3.9 | ||
7.3.10 |
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
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,83 @@ | ||
import os | ||
import unittest | ||
|
||
from robot_model import Model | ||
from state_representation import JointPositions | ||
|
||
class RobotModelCollisionTesting(unittest.TestCase): | ||
ur5e_with_geometries = None | ||
ur5e_without_geometries = None | ||
test_non_colliding_configs = [] | ||
test_colliding_configs = [] | ||
|
||
@staticmethod | ||
def get_package_path_from_name(name): | ||
if name == "ur_description": | ||
return f'{os.path.dirname(os.path.realpath(__file__))}/' | ||
|
||
|
||
@classmethod | ||
def setUpClass(cls): | ||
test_fixtures_path = os.path.join(os.path.dirname(os.path.realpath(__file__))) | ||
cls.ur5e_with_geometries = Model("ur5e", os.path.join(test_fixtures_path, "ur5e.urdf"), meshloader_callback=cls.get_package_path_from_name) | ||
cls.ur5e_without_geometries = Model("ur5e", os.path.join(test_fixtures_path, "ur5e.urdf")) | ||
cls.set_test_non_colliding_configurations() | ||
cls.set_test_colliding_configurations() | ||
|
||
@classmethod | ||
def set_test_non_colliding_configurations(cls): | ||
config1 = JointPositions(cls.ur5e_with_geometries.get_robot_name(), 6) | ||
config1.set_positions([0.0, -1.63, 1.45, 0.38, 0.0, 0.0]) | ||
cls.test_non_colliding_configs.append(config1) | ||
|
||
config2 = JointPositions(cls.ur5e_with_geometries.get_robot_name(), 6) | ||
config2.set_positions([0.0, -1.88, 1.45, 0.38, -4.4, -3.14]) | ||
cls.test_non_colliding_configs.append(config2) | ||
|
||
config3 = JointPositions(cls.ur5e_with_geometries.get_robot_name(), 6) | ||
config3.set_positions([1.26, -1.26, 0.82, 0.38, -4.4, 3.14]) | ||
cls.test_non_colliding_configs.append(config3) | ||
|
||
@classmethod | ||
def set_test_colliding_configurations(cls): | ||
config1 = JointPositions(cls.ur5e_with_geometries.get_robot_name(), 6) | ||
config1.set_positions([1.26, -1.76, 2.89, 0.38, -4.4, -6.16]) | ||
cls.test_colliding_configs.append(config1) | ||
|
||
config2 = JointPositions(cls.ur5e_with_geometries.get_robot_name(), 6) | ||
config2.set_positions([1.26, -1.76, 2.89, 0.38, -1.38, -1.16]) | ||
cls.test_colliding_configs.append(config2) | ||
|
||
config3 = JointPositions(cls.ur5e_with_geometries.get_robot_name(), 6) | ||
config3.set_positions([1.26, -1.76, -3.08, 0.75, -1.38, -6.16]) | ||
cls.test_colliding_configs.append(config3) | ||
|
||
def test_number_of_collision_pairs_with_geometries(self): | ||
num_pairs = self.ur5e_with_geometries.get_number_of_collision_pairs() | ||
self.assertEqual(num_pairs, 15, "Expected 15 collision pairs for ur5e with geometries.") | ||
|
||
def test_number_of_collision_pairs_without_geometries(self): | ||
num_pairs = self.ur5e_without_geometries.get_number_of_collision_pairs() | ||
self.assertEqual(num_pairs, 0, "Expected zero collision pairs for model without geometries.") | ||
|
||
def test_geom_model_initialized_with_geometries(self): | ||
is_initialized = self.ur5e_with_geometries.is_geometry_model_initialized() | ||
self.assertTrue(is_initialized, "Expected geometry model to be initialized for model with geometries.") | ||
|
||
def test_geom_model_initialized_without_geometries(self): | ||
is_initialized = self.ur5e_without_geometries.is_geometry_model_initialized() | ||
self.assertFalse(is_initialized, "Expected geometry model to not be initialized for model without geometries.") | ||
|
||
def test_no_collision_detected(self): | ||
for config in self.test_non_colliding_configs: | ||
is_colliding = self.ur5e_with_geometries.check_collision(config) | ||
self.assertFalse(is_colliding, "Expected no collision for configuration") | ||
|
||
def test_collision_detected(self): | ||
for config in self.test_colliding_configs: | ||
is_colliding = self.ur5e_with_geometries.check_collision(config) | ||
self.assertTrue(is_colliding, "Expected collision for configuration") | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
Oops, something went wrong.