Main Content

generalizedInverseKinematics

Create multiconstraint inverse kinematics solver

Description

ThegeneralizedInverseKinematicsSystem Object™使用一组运动学约束来计算由A指定的刚体树模型的联合配置rigidBodyTree目的。ThegeneralizedInverseKinematicsobject uses a nonlinear solver to satisfy the constraints or reach the best approximation.

Specify the constraint types,ConstraintInputs, before calling the object. To change constraint inputs after calling the object, call释放(gik).

将约束输入指定为约束对象并调用generalizedInverseKinematics这些对象传递到其中。要创建约束对象,请使用以下对象:

If your only constraint is the end-effector position and orientation, consider using反向基础学as your solver instead.

有关封闭形式的分析逆运动溶液,请参见金宝搏官方网站分析蛋白酶.

解决广义的逆运动学约束:

  1. Create thegeneralizedInverseKinematics对象并设置其属性。

  2. 用参数调用对象,就好像它是一个函数一样。

To learn more about how System objects work, see什么是系统对象?

创建

Description

example

gik=概括性基础化学returns a generalized inverse kinematics solver with no rigid body tree model specified. Specify arigidBodyTreemodel and theConstraintInputs使用此求解器之前的属性。

gik=概括的inverseversematics('RigidBodyTree',rigidbodytree,'ConstraintInputs',inputTypes)returns a generalized inverse kinematics solver with the rigid body tree model and the expected constraint inputs specified.

gik=概括性基础化学(姓名,Value)返回一个广义的逆运动求解器,每个指定的属性名称将每个指定的属性名称设置为一个或多个姓名,Valuepair arguments.姓名必须出现在单引号中('')。您可以指定几个名称-值对arguments in any order as姓名1,Value1,...,NameN,ValueN.

特性

expand all

除非另有说明,否则属性是nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and therelease功能解锁它们。

如果财产是可调, you can change its value at any time.

有关更改属性值的更多信息,请参见System Design in MATLAB Using System Objects.

This property is read-only.

约束输入的数量, specified as a scalar. The value of this property is the number of constraint types specified in theConstraintInputsproperty.

约束输入类型,指定为字符向量的单元格数组。可能的约束输入类型及其关联的约束对象是:

There are also closed-loop joint constraints that constrain two rigid bodies such that the constrained motion is similar to that of an additional joint between the two bodies. Their constraint input types with their associated constraint objects are:

使用约束对象指定所需的参数,并在调用它时将这些对象类型传递到对象中。例如:

Create the generalized inverse kinematics solver object. Specify theRigidBodyTreeConstraintInputs特性。

gik =概括性基础化学(...'RigidBodyTree',rigidbodytree,'ConstraintInputs',{'position',“瞄准”});

Create the corresponding constraint objects.

positionTgt = constraintPositionTarget('left_palm'); aimConst = constraintAiming('right_palm');

Pass the constraint objects into the solver object with an initial guess.

configsol= gik(initialGuess,positionTgt,aimConst);

Rigid body tree model, specified as arigidBodyTree目的。在使用求解器之前定义此属性。如果您修改了刚体的身体树型号,请将刚体树重新分配到该属性。例如:

Create IK solver and specify the rigid body tree.

gik =概括性基础化学(...'RigidBodyTree',rigidbodytree,'ConstraintInputs',{'position',“瞄准”});

修改刚体树模型。

addBody(rigidbodytree,rigidBody('Body1'),'base')

Reassign the rigid body tree to the IK solver. If the solver or thefunction is called before modifying the rigid body tree model, userelease允许更改属性。

gik.RigidBodyTree = rigidbodytree;

Algorithm for solving inverse kinematics, specified as either'BFGSGradientProcotion'或者'LevenbergMarquardt'. For details of each algorithm, seeInverse Kinematics Algorithms.

Parameters associated with the specified algorithm, specified as a structure. The fields in the structure are specific to the algorithm. SeeSolver Parameters.

Usage

Description

[configsol,solInfo] = gik(initialguess,约束,...,约束objn)找到联合配置,configsol,基于最初的猜测和约束描述对象的逗号分隔列表。约束描述的数量取决于ConstraintInputsproperty.

Input Arguments

expand all

机器人配置的最初猜测, specified as a structure array or vector. The value ofinitialguessdepends on theDataFormatproperty of the object specified in theRigidBodyTreeproperty specified ingik.

Use this initial guess to guide the solver to the target robot configuration. However, the solution is not guaranteed to be close to this initial guess.

约束描述定义为theConstraintInputsproperty ofgik, specified as one or more of these constraint objects:

输出参数

expand all

机器人配置解决方案,返回为结构数组或向量,取决于DataFormatproperty of the object specified in theRigidBodyTreeproperty specified ingik.

The structure array contains these fields:

  • JointName- 字符向量,用于指定的关节名称RigidBodyTree机器人模型

  • 联合位置— Position of the corresponding joint

The vector output is an array of the joint positions that would be given in联合位置用于结构输出。

该联合配置是在溶液公差内实现目标终端效果的计算解决方案。

Note

对于起伏的接头,如果关节限制超过2*pi, where joint position wrapping occurs, then the returned joint position is the one closest to the joint's lower bound.

Solution information, returned as a structure containing these fields:

  • Iterations- 求解器运行的迭代次数。

  • numrandomrestarts— Number of random restarts because the solver got stuck in a local minimum.

  • ConstraintViolation— Information about the constraint, returned as a structure array. Each structure in the array has these fields:

    • Type: Type of the corresponding constraint input, as specified in theConstraintInputsproperty.

    • Violation:相应约束类型的约束违规行为的向量。0表示满足约束。

  • ExitFlag— Code that gives more details on the solver execution and what caused it to return. For the exit flags of each solver type, seeExit Flags.

  • Status— Character vector describing whether the solution is within the tolerances defined by each constraint ('成功')。如果解决方案不在公差之外,则给出求解器可以找到的最佳解决方案('可以提供的最好的')。

Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object namedobj, use this syntax:

释放(obj)

expand all

System objectalgorithm
release Release resources and allow changes toSystem objectproperty values and input characteristics
reset Reset internal states ofSystem object

Examples

collapse all

创建一个广义的逆运动求解器,该求解器将机器人臂固定在特定位置,并指向机器人基础。创建约束对象以将必要的约束参数传递到求解器中。

Load predefined KUKA LBR robot model, which is specified as arigidBodyTree目的。

loadexampleRobots.matlbr

创建用于求解广义逆运动学的系统对象™。

gik =概括性基础化学;

Configure the System object to use the KUKA LBR robot.

gik.RigidBodyTree = lbr;

告诉求解器期望位置标题object and aconstraintAiming约束题词object as the constraint inputs.

gik.ConstraintInputs = {'position',“瞄准”};

Create the two constraint objects.

  1. The origin of the body namedtool0is located at[0.0 0.5 0.5]relative to the robot's base frame.

  2. Thez-axis of the body namedtool0points toward the origin of the robot's base frame.

postgt = CondraintPositionTarget('tool0'); posTgt.TargetPosition = [0.0 0.5 0.5]; aimCon = constraintAiming('tool0'); aimCon.TargetPoint = [0.0 0.0 0.0];

Find a configuration that satisfies the constraints. You must pass the constraint objects into the System object in the order in which they were specified in theConstraintInputsproperty. Specify an initial guess at the robot configuration.

q0 = homeConfiguration(lbr);% Initial guess for solver[q,solutionInfo] = gik(q0,posTgt,aimCon);

Visualize the configuration returned by the solver.

show(lbr,q); title(['Solver status: 'solutionInfo.Status]) axis([-0.75 0.75 -0.75 0.75 -0.5 1])

图包含一个轴对象。The axes object with title Solver status: success contains 19 objects of type patch, line. These objects represent base_link, link_1, link_2, link_3, link_4, link_5, link_6, link_7, tool0, base.

Plot a line segment from the target position to the origin of the base. The origin of thetool0frame coincides with one end of the segment, and itsz-axis is aligned with the segment.

holdplot3([0.0 0.0],[0.5 0.0],[0.5 0.0],' -  o') 抓住off

图包含一个轴对象。具有标题求解器状态的轴对象:成功包含20个类型补丁的对象。这些对象表示base_link,link_1,link_2,link_3,link_4,link_4,link_5,link_6,link_7,link_7,tool0,base。

扩展功能

版本历史

Introduced in R2017a

expand all

Behavior change in future release