控制一个机器人,参见 PyBullet快速上手教程(二).
Kinematics,Dynamics
目录
calculateInverseKinematics
You can compute the joint angles that makes the end-effector reach a given target position in Cartesian world space. Internally, Bullet uses an improved version of Samuel Buss Inverse Kinematics library. At the moment only the Damped Least Squares method with or without Null Space control is exposed, with a single end-effector target. Optionally you can also specify the target orientation of the end effector. In addition, there is an option to use the null-space to specify joint limits and rest poses. This optional null-space support requires all 4 lists (lowerLimits, upperLimits, jointRanges, restPoses), otherwise regular IK will be used. See also inverse_kinematics.py example in Bullet/examples/pybullet/examples folder for details.
逆向运动学计算:给定对象id,当前关节位置和末端执行器的目标位置,计算逆向运动学并返回新的关节状态。输入参数如下
required | bodyUniqueId | int | 机器人的唯一ID,就是使用loadURDF... 时返回的数值 |
required | endEffectorLinkIndex | int | 末端执行器link索引 |
required | targetPosition | vec3, list of 3 floats | 目标位置(笛卡尔世界坐标系) |
optional | targetOrientation | vec3, list of 3 floats | 目标姿态(笛卡尔世界坐标系),四元数[x,y,z,w]。 如果未指定,将计算纯位置IK。 |
optional | lowerLimits | list of floats [0..nDof] | 可选的null-space IK,需要所有4个列表(lowerLimits,upperLimits, jointRanges,restPoses)。否则将使用常规IK |
optional | upperLimits | list of floats [0..nDof] | 关节限位 |
optional | jointRanges | list of floats [0..nDof] | |
optional | restPoses | list of floats [0..nDof] | Favor an IK solution closer to a given rest pose |
optional | jointDamping | list of floats [0..nDof] | jointDamping allow to tune the IK solution using joint damping factors |
optional | solver | int | p.IK_DLS or p.IK_SDLS, Damped Least Squares or Selective Damped Least Squares, as described in the paper by Samuel Buss "Selectively Damped Least Squares for Inverse Kinematics". |
optional | physicsClientId | int | if you are connected to multiple servers, you can pick one. |
calculateInverseKinematics返回关节位置列表。 有关示例,请参阅 Bullet / examples / pybullet / inverse_kinematics.py。
请注意,calculateInverseKinematics的计算结果只是一个近似值,并不精确。 使用“ccurateCalculateInverseKinematics”可以获得更准确的结果。
calculateInverseDynamics
calculateInverseDynamics将从指定的关节位置和速度开始计算达到给定关节加速度所需的力。输入参数列表:
required | bodyUniqueId | int | 机器人的唯一ID,就是使用loadURDF... 时返回的数值 |
required | objPositions | list of float | 每个自由度(DoF)的关节位置(角度)。Note that fixed joints have 0 degrees of freedom. The base is skipped/ignored in all cases (floating base and fixed base). |
required | objVelocities | list of float | 每个关节的速度 |
required | objAccelerations | list of float | 每个关节的期望加速度 |
optional | physicsClientId | int | if you are connected to multiple servers, you can pick one |
calculateInverseDynamics返回每个自由度的关节力列表。