attach
Description
attach(
attaches the non-platform
,targetname
,attachingbodyname
)rigidBodyTree
-based target platform
targetname
to the body attachingbodyname
of the
rigidBodyTree
-based source platform platform
.
attach(___,
specifies
options using one or more name-value arguments, in addition to all input arguments from the
previous syntax.Name=Value
)
Examples
Perform Pick and Place in Robot Scenario
Create a robotScenario
object.
scenario = robotScenario(UpdateRate=1,StopTime=10);
Create a rigidBodyTree
object of the Franka Emika Panda manipulator using loadrobot
.
robotRBT = loadrobot("frankaEmikaPanda");
Create a rigidBodyTree
-based robotPlatform
object using the manipulator model.
robot = robotPlatform("Manipulator",scenario, ... RigidBodyTree=robotRBT);
Create a non-rigidBodyTree
-based robotPlatform
object of a box to manipulate. Specify the mesh type and size.
box = robotPlatform("Box",scenario,Collision="mesh", ... InitialBasePosition=[0.5 0.15 0.278]); updateMesh(box,"Cuboid",Collision="mesh",Size=[0.06 0.06 0.1])
Visualize the scenario.
ax = show3D(scenario,Collisions="on");
view(79,36)
light
Specify the initial and the pick-up joint configuration of the manipulator, to move the manipulator from its initial pose to close to the box.
initialConfig = homeConfiguration(robot.RigidBodyTree);
pickUpConfig = [0.2371 -0.0200 0.0542 -2.2272 0.0013 ...
2.2072 -0.9670 0.0400 0.0400];
Create an RRT path planner using the manipulatorRRT
object, and specify the manipulator model.
planner = manipulatorRRT(robot.RigidBodyTree,scenario.CollisionMeshes); planner.IgnoreSelfCollision = true;
Plan the path between the initial and the pick-up joint configurations. Then, to visualize the entire path, interpolate the path into small steps.
rng("default")
path = plan(planner,initialConfig,pickUpConfig);
path = interpolate(planner,path,25);
Set up the simulation.
setup(scenario)
Check the collision before manipulator picks up the box.
checkCollision(robot,"Box", ... IgnoreSelfCollision="on")
ans = logical
0
Move the joints of the manipulator along the path and visualize the scenario.
helperRobotMove(path,robot,scenario,ax)
Check the collision after manipulator picks up the box.
checkCollision(robot,"Box", ... IgnoreSelfCollision="on")
ans = logical
1
Use the attach
function to attach the box to the gripper of the manipulator.
attach(robot,"Box","panda_hand", ... ChildToParentTransform=trvec2tform([0 0 0.1]))
Specify the drop-off joint configuration of the manipulator to move the manipulator from its pick-up pose to the box drop-off pose.
dropOffConfig = [-0.6564 0.2885 -0.3187 -1.5941 0.1103 ...
1.8678 -0.2344 0.04 0.04];
Plan the path between the pick-up and drop-off joint configurations.
path = plan(planner,pickUpConfig,dropOffConfig); path = interpolate(planner,path,25);
Move the joints of the manipulator along the path and visualize the scenario.
helperRobotMove(path,robot,scenario,ax)
Use the detach
function to detach the box from the manipulator gripper.
detach(robot)
Plan the path between the drop-off and initial joint configurations to move the manipulator from its box drop-off pose to its initial pose.
path = plan(planner,dropOffConfig,initialConfig); path = interpolate(planner,path,25);
Move the joints of the manipulator along the path and visualize the scenario.
helperRobotMove(path,robot,scenario,ax)
Helper function to move the joints of the manipulator.
function helperRobotMove(path,robot,scenario,ax) for idx = 1:size(path,1) jointConfig = path(idx,:); move(robot,"joint",jointConfig) show3D(scenario,fastUpdate=true,Parent=ax,Collisions="on"); drawnow advance(scenario); end end
Input Arguments
platform
— rigidBodyTree
-based source platform
robotPlatform
object
rigidBodyTree
-based source platform, specified as a robotPlatform
object.
targetname
— Non-rigidBodyTree
-based target platform
string scalar | character vector
Non-rigidBodyTree
-based target platform, specified as a string
scalar or character vector.
Example: "Box"
Data Types: char
| string
attachingbodyname
— Body of source robot platform
string scalar | character vector
Body of the source robot platform, specified as a string scalar or character vector.
Example: "panda_hand"
Data Types: char
| string
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Example: ChildToParentTransform=trvec2tform([0 0 0.1])
ChildToParentTransform
— Transformation of attached target platform body relative to source platform attaching body
eye(4)
(default) | 4-by-4 homogeneous transformation matrix
Transformation of the attached target platform body relative to the source platform attaching body, specified as a 4-by-4 homogeneous transformation matrix.
Example: ChildToParentTransform=trvec2tform([0 0
0.1])
Data Types: single
| double
Collision
— Collision object to add to target platform mesh
collisionBox
object | collisionCapsule
object | collisionCylinder
object | collisionMesh
object | collisionSphere
object
Collision object to add to target platform mesh, specified as an externally
created collision object such as a collisionBox
, collisionCapsule
, collisionCylinder
, collisionMesh
, or collisionSphere
. If you do not specify a collision object, then the target
platform uses its default collision mesh.
Version History
Introduced in R2023a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)