ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Clearing PlanningScene at beginning of script (moveit_commander)

asked 2018-01-29 03:47:09 -0500

cschindlbeck gravatar image

updated 2018-01-29 03:56:09 -0500

Hello everyone,

i have a script where i add objects to the Planning Scene in MoveIt!. I want to clear all previously added objects at the beginning of the script, however, that does not work. What am i doing wrong? I also tried to iterate over all known objects but without success.

Is it because every time i start the script i create a new node and the objects of the "previous" node are not accessible?

rospy.init_node('planningscenenode', anonymous=True)
scene = moveit_commander.PlanningSceneInterface()

scene.remove_world_object()  # Does not work at the beginning
sleep(1)

co = CollisionObject()
co.id = 'plate'+str(0)
co.meshes = rospkg.RosPack().get_path('agilus')+"/meshes/" + "plate.stl"
ps = PoseStamped()
ps.pose.position.x = -0.6
ps.pose.position.y = -0.6
ps.pose.position.z = 0
ps.pose.orientation = Quaternion(*tf.transformations.quaternion_from_euler(np.deg2rad(float(0)), np.deg2rad(float(0)), np.deg2rad(float(0))))

co.mesh_poses = ps
co.mesh_poses.header.frame_id = '/base_link'
scene.add_mesh(co.id, co.mesh_poses, co.meshes)

Thanks in advance!

edit retag flag offensive close merge delete

Comments

This doesn't answer your question, but why are you using the built-in sleep vs the rospy version?

jayess gravatar image jayess  ( 2018-01-29 04:28:21 -0500 )edit

Lack of knowledge. I will consider it in future code.

cschindlbeck gravatar image cschindlbeck  ( 2018-01-29 07:18:40 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-01-29 10:07:23 -0500

cschindlbeck gravatar image

updated 2018-01-30 02:06:26 -0500

I found a dirty fix

rospy.sleep(2)
scene.remove_world_object()
rospy.sleep(2)

There should be a better way right?

Edit: The problem could be related to https://github.com/ros-planning/movei...

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-01-29 03:47:09 -0500

Seen: 343 times

Last updated: Jan 30 '18