Complete the code to import the ROS package for collision avoidance planning.
import [1]
The moveit_commander package provides interfaces for motion planning including collision avoidance.
Complete the code to initialize the MoveGroupCommander for the robot arm.
group = moveit_commander.[1]('arm')
MoveGroupCommander is used to control a group of joints for planning and execution.
Fix the error in the code to set the target pose for collision-free planning.
pose_target = geometry_msgs.msg.Pose() pose_target.position.x = 0.4 pose_target.position.y = 0.1 pose_target.position.z = 0.3 pose_target.orientation.w = [1] group.set_pose_target(pose_target)
The orientation quaternion's w component should be 1.0 for no rotation.
Fill both blanks to add a collision object and attach it to the robot.
collision_object = moveit_msgs.msg.CollisionObject() collision_object.id = ['box'] collision_object.header.frame_id = group.get_planning_frame() box = shape_msgs.msg.SolidPrimitive() box.type = shape_msgs.msg.SolidPrimitive.[1] box.dimensions = [0.1, 0.1, 0.1] collision_object.primitives = [box] collision_object.[2] = [geometry_msgs.msg.Pose()] planning_scene = moveit_commander.PlanningSceneInterface() planning_scene.add_collision_object(collision_object) group.attach_object(collision_object.id[0])
The primitive type for a box is BOX. The poses of the primitives are set in the primitive_poses attribute.
Fill all three blanks to plan and execute a collision-free path.
plan = group.[1]() if len(plan.[2]) > 0: group.[3](plan)
plan() generates a plan. Checking len(joint_trajectory.points) ensures the plan has points. execute() runs the plan.
