11#!/usr/bin/env python
22import sys
33
4- import moveit_commander
5- import numpy as np
6- import rospy
7- from geometry_msgs .msg import PoseStamped
8- import moveit .core
9- from moveit .core import kinematic_constraints , collision_detection , robot_model
10- from moveit .core .planning_scene import PlanningScene
11-
12-
134def main ():
145 rospy .init_node ("planning_scene_tutorial" )
156 moveit_commander .roscpp_initialize (sys .argv )
@@ -28,10 +19,18 @@ def main():
2819 # using data from the robot's joints and the sensors on the robot. In
2920 # this tutorial, we will instantiate a PlanningScene class directly,
3021 # but this method of instantiation is only intended for illustration.
31-
32- urdf_path = "/opt/ros/noetic/share/moveit_resources_panda_description/urdf/panda.urdf"
33- srdf_path = "/opt/ros/noetic/share/moveit_resources_panda_moveit_config/config/panda.srdf"
34- kinematic_model = moveit .core .load_robot_model (urdf_path , srdf_path )
22+ import moveit_commander
23+ import numpy as np
24+ import rospy
25+ from geometry_msgs .msg import PoseStamped
26+ import moveit .core
27+ from moveit .core import kinematic_constraints , collision_detection , robot_model
28+ from moveit .core .planning_scene import PlanningScene
29+
30+ r = rospkg .RosPack ()
31+ urdf_path = pathlib .Path (r .get_path ("moveit_resources_panda_description" )) / "urdf" / "panda.urdf"
32+ srdf_path = pathlib .Path (r .get_path ("moveit_resources_panda_moveit_config" )) / "config" / "panda.srdf"
33+ kinematic_model = moveit .core .load_robot_model (urdf_path .as_posix (), srdf_path .as_posix ())
3534 planning_scene = PlanningScene (kinematic_model , collision_detection .World ())
3635 current_state = planning_scene .getCurrentStateNonConst ()
3736 joint_model_group = current_state .getJointModelGroup ("panda_arm" )
@@ -137,7 +136,6 @@ def main():
137136 acm = planning_scene .getAllowedCollisionMatrix ()
138137 copied_state = planning_scene .getCurrentState ()
139138
140- # for (it2 = collision_result.contacts.begin() it2 != collision_result.contacts.end() + +it2)
141139 for (first_name , second_name ), contacts in collision_result .contacts :
142140 acm .setEntry (first_name , second_name , True )
143141 collision_result .clear ()
0 commit comments