pick-凯发k8网页登录
this example shows how to set up a pick-and-place workflow for a robotic manipulator like the kinova® gen3.
the pick-and-place workflow implemented in this example can be adapted to different scenarios, planners, simulation platforms, and object detection options. the example shown here uses model predictive control for planning and control, and simulates the robot in matlab. for other uses, see:
overview
this example sorts detected objects and places them on benches using a kinova gen3 manipulator. the example uses tools from four toolboxes:
robotics system toolbox™ is used to model, simulate, and visualize the manipulator, and for collision-checking.
model predictive control toolbox™ and optimization toolbox™ are used to generated optimized, collision-free trajectories for the manipulator to follow.
stateflow® is used to schedule the high-level tasks in the example and step from task to task.
this example builds on key concepts from two related examples:
shows how to generate and simulate interpolated joint trajectories to move from an initial to a desired end-effector pose.
plan and execute collision-free trajectories using kinova gen3 manipulator shows how to plan closed-loop collision-free robot trajectories to a desired end-effector pose using nonlinear model predictive control.
stateflow chart
this example uses a stateflow chart to schedule tasks in the example. open the chart to examine the contents and follow state transitions during chart execution.
edit examplehelperflowchartpickplace.sfx
the chart dictates how the manipulator interacts with the objects, or parts. it consists of basic initialization steps, followed by two main sections:
identify parts and determine where to place them
execute pick-and-place workflow
initialize the robot and environment
first, the chart creates an environment consisting of the kinova gen3 manipulator, three parts to be sorted, the shelves used for sorting, and a blue obstacle. next, the robot moves to the home position.
identify the parts and determine where to place them
in the first step of the identification phase, the parts must be detected. the examplecommanddetectparts
function directly gives the object poses. replace this class with your own object detection algorithm based on your sensors or objects.
next, the parts must be classified. the examplecommandclassifyparts
function classifies the parts into two types to determine where to place them (top or bottom shelf). again, you can replace this function with any method for classifying parts.
execute pick-and-place workflow
once parts are identified and their destinations have been assigned, the manipulator must iterate through the parts and move them onto the appropriate tables.
pick up the object
the picking phase moves the robot to the object, picks it up, and moves to a safe position, as shown in the following diagram:
the examplecommandcomputegrasppose
function computes the grasp pose. the class computes a task-space grasping position for each part. intermediate steps for approaching and reaching towards the part are also defined relative to the object.
this robot picks up objects using a simulated gripper. when the gripper is activated, examplecommandactivategripper
adds the collision mesh for the part onto the rigidbodytree
representation of the robot, which simulates grabbing it. collision detection includes this object while it is attached. then, the robot moves to a retracted position away from the other parts.
place the object
the robot then places the object on the appropriate shelf.
as with the picking workflow, the placement approach and retracted positions are computed relative to the known desired placement position. the gripper is deactivated using examplecommandactivategripper
, which removes the part from the robot.
moving the manipulator to a specified pose
most of the task execution consists of instructing the robot to move between different specified poses. the examplehelperplanexecutetrajectorypickplace
function defines a solver using a nonlinear model predictive controller (see (model predictive control toolbox)) that computes a feasible, collision-free optimized reference trajectory using (model predictive control toolbox) and . the obstacles are represented as spheres to ensure the accurate approximation of the constraint jacobian in the definition of the nonlinear model predictive control algorithm (see [1]). the helper function then simulates the motion of the manipulator under computed-torque control as it tracks the reference trajectory using the object, and updates the visualization. the helper function is called from the stateflow chart via examplecommandmovetotaskconfig
, which defines the correct inputs.
this workflow is examined in detail in plan and execute collision-free trajectories using kinova gen3 manipulator. the controller is used to ensure collision-free motion. for simpler trajectories where the paths are known to be obstacle-free, trajectories could be executed using trajectory generation tools and simulated using the manipulator motion models. see .
task scheduling in a stateflow chart
this example uses a stateflow chart to direct the workflow in matlab®. for more info on creating state flow charts, see create stateflow charts for execution as matlab objects (stateflow).
the stateflow chart directs task execution in matlab by using command functions. when the command finishes executing, it sends an input event to wake up the chart and proceed to the next step of the task execution, see execute a standalone chart (stateflow).
run and visualize the simulation
this simulation uses a kinova gen3 manipulator with a robotiq gripper. load the robot model from a .mat
file as a rigidbodytree
object.
load('examplehelperkinovagen3grippercoll.mat');
initialize the pick and place coordinator
set the initial robot configuration. create the coordinator, which handles the robot control, by giving the robot model, initial configuration, and end-effector name.
currentrobotjconfig = homeconfiguration(robot);
coordinator = examplehelpercoordinatorpickplace(robot,currentrobotjconfig, "gripper");
specify the home configuration and two poses for placing objects of different types.
coordinator.homerobottaskconfig = trvec2tform([0.4, 0, 0.6])*axang2tform([0 1 0 pi]); coordinator.placingpose{1} = trvec2tform([0.23 0.62 0.33])*axang2tform([0 1 0 pi]); coordinator.placingpose{2} = trvec2tform([0.23 -0.62 0.33])*axang2tform([0 1 0 pi]);
run and visualize the simulation
connect the coordinator to the stateflow chart. once started, the stateflow chart is responsible for continuously going through the states of detecting objects, picking them up and placing them in the correct staging area.
coordinator.flowchart = examplehelperflowchartpickplace('coordinator', coordinator);
use a dialog to start the pick-and-place task execution. click yes in the dialog to begin the simulation.
answer = questdlg('do you want to start the pick-and-place job now?', ... 'start job','yes','no', 'no'); switch answer case 'yes' % trigger event to start pick and place in the stateflow chart coordinator.flowchart.startpickplace; case 'no' % end pick and place coordinator.flowchart.endpickplace; delete(coordinator.flowchart); delete(coordinator); end
ending the pick-and-place task
the stateflow chart will finish executing automatically after 3 failed attempts to detect new objects. to end the pick-and-place task prematurely, uncomment and execute the following lines of code or press ctrl c in the command window.
% coordinator.flowchart.endpickplace; % delete(coordinator.flowchart); % delete(coordinator);
observe the simulation states
during execution, the active states at each point in time are highlighted in blue in the stateflow chart. this helps keeping track of what the robot does and when. you can click through the subsystems to see the details of the state in action.
visualize the pick-and-place action
the example uses for robot visualization. the visualization shows the robot in the working area as it moves parts around. the robot avoids obstacles in the environment (blue cylinder) and places objects on top or bottom shelf based on their classification. the robot continues working until all parts have been placed.
references
[1] schulman, j., et al. "motion planning with sequential convex optimization and convex collision checking." the international journal of robotics research 33.9 (2014): 1251-1270.