motrixsim.ik#
Classes:
|
Use Damped Least Squares (DLS) method to solve inverse kinematics problem. |
|
Use gauss newton iterative method to solve inverse kinematics problem. |
|
Represents a kinematic chain for inverse kinematics (IK) solving. |
- class motrixsim.ik.DlsSolver(max_iter=100, step_size=0.5, tolerance=0.001, damping=0.001)#
基类:
objectUse Damped Least Squares (DLS) method to solve inverse kinematics problem.
DLS is a robust optimization method that adds regularization to handle singular configurations and improve numerical stability. It's also known as Levenberg-Marquardt for IK applications.
- 参数:
max_iter (int) -- Maximum number of iterations (default: 100).
step_size (float) -- Step size for each iteration (default: 0.5).
tolerance (float) -- Tolerance for convergence (default: 1e-3).
damping (float) -- Damping parameter for regularization (default: 1e-3). - Small values (1e-6 to 1e-4): Near Gauss-Newton behavior - Medium values (1e-4 to 1e-2): Good balance for most applications - Large values (1e-2 to 1.0): More stable but slower convergence
Methods:
solve(ik_model, data, target_pose)Solve the IK problem for the given chain and target pose.
- solve(ik_model, data, target_pose)#
Solve the IK problem for the given chain and target pose.
- 参数:
- 返回:
A numpy array with shape (data.shape, ik_model.num_dof_pos + 2,). For each row, the first element is the number of iterations used, the second element is the final residual, and the remaining elements are the solved DOF positions.
- class motrixsim.ik.GaussNewtonSolver(max_iter=100, step_size=0.5, tolerance=0.001)#
基类:
objectUse gauss newton iterative method to solve inverse kinematics problem.
- 参数:
max_iter (int) -- Maximum number of iterations (default: 100).
step_size (float) -- Step size for each iteration (default: 0.5).
tolerance (float) -- Tolerance for convergence (default: 1e-3).
Methods:
solve(ik_model, data, target_pose)Solve the IK problem for the given chain and target pose.
- solve(ik_model, data, target_pose)#
Solve the IK problem for the given chain and target pose.
- 参数:
- 返回:
A numpy array with shape (data.shape, ik_model.num_dof_pos + 2,). For each row, the first element is the number of iterations used, the second element is the final residual, and the remaining elements are the solved DOF positions.
- class motrixsim.ik.IkChain(model, end_link, start_link=None, end_effector_offset=None)#
基类:
objectRepresents a kinematic chain for inverse kinematics (IK) solving.
- 参数:
model (SceneModel) -- The scene model containing the kinematic structure.
end_link (str) -- The name of the end link of the IK chain.
start_link (Optional[str]) -- The name of the start link of the IK chain. If not provided, the root link will be used.
end_effector_offset (Optional[ndarray]) -- A 7-element array representing the end-effector offset as a pose (x, y, z, i, j, k, w) in end link's local space. If not provided, no offset will be applied.
- 抛出:
RuntimeError -- If the IK chain contains unsupported joint types. (Currently only hinge and slider are supported.)
Methods:
get_bias_force(data)Get the joint space bias force of the chain.
get_dof_pos(data)Get the DoF positions of the IK chain from the simulation data.
get_dof_vel(data)Get the DoF velocities of the IK chain from the simulation data.
get_end_effector_jac(data)Get the Jacobian matrix of the end effector.
get_end_effector_pose(data)Get the end effector pose in world coordinates.
get_end_effector_vel(data)Get the end effector velocity in world coordinates.
get_end_point_jac(data, end_point)Get the Jacobian matrix of a specific point fixed to the end link.
get_inertia_matrix(data)Get the joint space inertia matrix of the chain.
get_link(index)Get the link at the specified index in the IK chain.
Attributes:
Get the number of DoF positions in the IK chain.
Get the number of DoF velocities in the IK chain.
Get the number of links in the IK chain.
- get_bias_force(data)#
Get the joint space bias force of the chain.
- 参数:
data (SceneData) -- The scene data containing the current state.
- 返回:
The joint space bias force of the chain. Shape:
(*data.shape, num_dof_vel).- 返回类型:
ndarray
- get_dof_pos(data)#
Get the DoF positions of the IK chain from the simulation data.
- 参数:
data (SceneData) -- The scene data containing the current state.
- 返回:
The DoF positions of the chain. Shape:
(*data.shape, num_dof_pos).- 返回类型:
ndarray
- get_dof_vel(data)#
Get the DoF velocities of the IK chain from the simulation data.
- 参数:
data (SceneData) -- The scene data containing the current state.
- 返回:
The DoF velocities of the chain. Shape:
(*data.shape, num_dof_vel).- 返回类型:
ndarray
- get_end_effector_jac(data)#
Get the Jacobian matrix of the end effector.
- 参数:
data (SceneData) -- The scene data containing the current state.
- 返回:
The Jacobian matrix of the end effector. Shape: ``(*data.shape, 6,
- 返回类型:
ndarray
num_dof_vel)``. The first 3 rows are angular velocity, the last 3 rows are linear velocity.
- get_end_effector_pose(data)#
Get the end effector pose in world coordinates.
- 参数:
data (SceneData) -- The scene data containing the current state.
- 返回:
The end effector pose array. Shape:
(*data.shape, 7). Each pose is a- 返回类型:
ndarray
7-element array with [x, y, z, i, j, k, w] format.
- get_end_effector_vel(data)#
Get the end effector velocity in world coordinates.
- 参数:
data (SceneData) -- The scene data containing the current state.
- 返回:
The end effector velocity array. Shape:
(*data.shape, 6). Each velocity is- 返回类型:
ndarray
a 6-element array with first 3 elements representing angular velocity and last 3 elements representing linear velocity.
- get_end_point_jac(data, end_point)#
Get the Jacobian matrix of a specific point fixed to the end link.
- 参数:
data (SceneData) -- The scene data containing the current state.
end_point (ndarray) -- A 3-element array representing the point in the end link's local
frame.
num_dof_vel)``. The first 3 rows are angular velocity, the last 3 rows are linear velocity.
- get_inertia_matrix(data)#
Get the joint space inertia matrix of the chain.
- 参数:
data (SceneData) -- The scene data containing the current state.
- 返回:
The joint space inertia matrix of the chain. Shape: ``(*data.shape,
- 返回类型:
ndarray
chain.num_dof_vel, chain.num_dof_vel)``.
- get_link(index)#
Get the link at the specified index in the IK chain.
- 参数:
index (int) -- The index of the link in the chain (0-based).
- 返回:
The link object at the specified index.
- 返回类型:
- 抛出:
IndexError -- If the index is out of bounds.
- num_dof_pos#
Get the number of DoF positions in the IK chain.
- 返回:
The number of degree of freedom positions.
- 返回类型:
int
- num_dof_vel#
Get the number of DoF velocities in the IK chain.
- 返回:
The number of degree of freedom velocities.
- 返回类型:
int
- num_links#
Get the number of links in the IK chain.
- 返回:
The number of links in the chain.
- 返回类型:
int