|
| 1 | +#!/usr/bin/env python |
1 | 2 | import sys |
2 | 3 |
|
3 | 4 | import moveit_commander |
4 | 5 | import numpy as np |
5 | 6 | import rospy |
6 | 7 | from geometry_msgs.msg import PoseStamped |
7 | | -from moveit_msgs.msg import DisplayRobotState |
8 | 8 | from pymoveit import kinematic_constraints, collision_detection, robot_model, random_numbers |
9 | 9 | from pymoveit.planning_scene import PlanningScene |
10 | 10 |
|
@@ -58,6 +58,21 @@ def main(): |
58 | 58 | planning_scene.checkSelfCollision(collision_request, collision_result) |
59 | 59 | rospy.loginfo(f"Test 1: Current state is {'in' if collision_result.collision else 'not in'} self collision") |
60 | 60 |
|
| 61 | + # Now, we can get contact information for any collisions that might |
| 62 | + # have happened at a given configuration of the Panda arm. We can ask |
| 63 | + # for contact information by filling in the appropriate field in the |
| 64 | + # collision request and specifying the maximum number of contacts to |
| 65 | + # be returned as a large number. |
| 66 | + |
| 67 | + collision_request.contacts = True |
| 68 | + collision_request.max_contacts = 1000 |
| 69 | + |
| 70 | + collision_result.clear() |
| 71 | + planning_scene.checkSelfCollision(collision_request, collision_result) |
| 72 | + for (first_name, second_name), contacts in collision_result.contacts.items(): |
| 73 | + rospy.loginfo(f"Contact between {first_name} and {second_name}") |
| 74 | + |
| 75 | + |
61 | 76 | # Change the state |
62 | 77 | # ~~~~~~~~~~~~~~~~ |
63 | 78 | # |
@@ -104,21 +119,6 @@ def main(): |
104 | 119 | rospy.loginfo( |
105 | 120 | f"Test 4: Current state is {'valid' if current_state.satisfiesBounds(joint_model_group) else 'not valid'}") |
106 | 121 |
|
107 | | - # Now, we can get contact information for any collisions that might |
108 | | - # have happened at a given configuration of the Panda arm. We can ask |
109 | | - # for contact information by filling in the appropriate field in the |
110 | | - # collision request and specifying the maximum number of contacts to |
111 | | - # be returned as a large number. |
112 | | - |
113 | | - collision_request.contacts = True |
114 | | - collision_request.max_contacts = 1000 |
115 | | - |
116 | | - collision_result.clear() |
117 | | - planning_scene.checkSelfCollision(collision_request, collision_result) |
118 | | - rospy.loginfo(f"Test 5: Current state is {'in' if collision_result.collision else 'not in'} self collision") |
119 | | - for (first_name, second_name), contacts in collision_result.contacts: |
120 | | - rospy.loginfo(f"Contact between {first_name} and {second_name}") |
121 | | - |
122 | 122 | # Modifying the Allowed Collision Matrix |
123 | 123 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
124 | 124 | # |
@@ -218,9 +218,6 @@ def main(): |
218 | 218 | rospy.loginfo( |
219 | 219 | f"Test 10: Random state is {'constrained' if constraint_eval_result.satisfied else 'not constrained'}") |
220 | 220 |
|
221 | | - # User-defined constraints |
222 | | - # ~~~~~~~~~~~~~~~~~~~~~~~~ |
223 | | - |
224 | 221 | # Whenever isStateValid is called, three checks are conducted: (a) |
225 | 222 | # collision checking (b) constraint checking and (c) feasibility |
226 | 223 | # checking using the user-defined callback. |
|
0 commit comments