Sample various poses within the bounds of a workspace goal region for a manipulator arm. Some end-effector poses may not be desirable due to the positioning of the arm bodies and obstacles in the scene. The workspaceGoalRegion
object defines the bounds on the xyz-position and zyx Euler orientation of the robot end effector. The sample
object function uniformly samples random poses within the bounds. Find configurations that achieve these end-effector poses and determine the best by visualization.
Load an existing robot model as a rigidBodyTree
object.
Add a can as a collisionCylinder
object to the robot arm.
The goal of this example is to place this can on a table with other cans. Add the table and other cans to the environment by creating a cell array of collision objects. Show the entire env
cell array.
Define Goal Region
Create a workspace goal region using the end-effector body name of the robot.
Define the goal region parameters for your workspace. The goal region includes a reference pose, xyz-position bounds, and orientation limits on the zyx Euler angles. This example specifies xyz bounds within the table dimensions and fixes rotation to a small range in the y- and x-axis.
Sample Poses
Uniformly sample poses within the table region using the sample
object function. In this example, set the rng
seed to get repeatable results. Create vectors for storing valid and invalid poses.
Check for Collisions
To find configurations for those poses, create an inverse kinematics (IK) solver.
Test the sampled poses by iterating through the sampled poses, solving for configurations using IK, and checking for collisions. Show the valid configurations.
Visualize A Singe Valid Pose
Plot all valid poses as transforms. The final valid configuration from checking collisions is still visible in the figure.
Show a valid configuration from the list. Change the index in validPoses
to look at different poses. Call hold off
to stop preserving figure elements. To manually inspect poses and configurations, comment out the final line when running.