Kinematics¶
Factory Function¶
create_ik_solver(chain_name: str, config: IKConfig | PinkIKConfig | None = None, side: str | None = None, urdf_path: str | None = None, backend: str = 'trac_ik', *, joint_names: list[str] | None = None, self_collision: bool = False) -> IKSolverBase
¶
Factory function to create an IK solver for a named chain.
Input
chain_name: Name of the chain (e.g. "left_arm", "whole_body").
config: IK configuration — IKConfig for trac_ik,
PinkIKConfig for pink (uses defaults if None).
side: Optional "left" or "right" suffix for compound names.
urdf_path: Override the default URDF file path.
backend: "trac_ik" (default) or "pink".
joint_names: (pink only) Explicit controlled joint names.
Derived from the kinematic chain if None.
self_collision: (pink only) Build a collision model from the
URDF's co-located SRDF for collision avoidance.
Output: An IKSolverBase instance (TracIKSolver or PinkIKSolver).
Examples:
create_ik_solver("left_arm") create_ik_solver("whole_body", side="left") create_ik_solver("whole_body", side="left", backend="pink", config=PinkIKConfig(com_cost=0.1))
Source code in autolife_planning/kinematics/ik_solver_base.py
TRAC-IK Solver¶
TracIKSolver(chain_config: ChainConfig, config: IKConfig | None = None)
¶
Bases: IKSolverBase
IK solver wrapping the TRAC-IK C++ library.
Source code in autolife_planning/kinematics/trac_ik_solver.py
joint_limits: tuple[np.ndarray, np.ndarray]
property
¶
Joint limits as (lower_bounds, upper_bounds) arrays.
set_joint_limits(lower: np.ndarray, upper: np.ndarray) -> None
¶
Override joint limits for the solver.
Input
lower: Lower bounds array of length num_joints upper: Upper bounds array of length num_joints
Source code in autolife_planning/kinematics/trac_ik_solver.py
fk(joint_positions: np.ndarray) -> SE3Pose
¶
Compute forward kinematics in world frame.
Input
joint_positions: Joint angles array of length num_joints
Output: SE3Pose of the end effector in world frame
Source code in autolife_planning/kinematics/trac_ik_solver.py
solve(target_pose: SE3Pose, seed: np.ndarray | None = None, config: IKConfig | None = None) -> IKResult
¶
Solve IK with random restart loop.
Input
target_pose: Desired end-effector pose seed: Initial joint configuration (random if None) config: Override default IK config for this solve
Output: IKResult with solution status and joint positions
Source code in autolife_planning/kinematics/trac_ik_solver.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | |
Pink Constrained IK Solver¶
PinkIKSolver(chain_config: ChainConfig, config: PinkIKConfig | None = None, joint_names: list[str] | None = None, collision_context: CollisionContext | None = None)
¶
Bases: IKSolverBase
Constrained IK solver built on Pink's QP-based differential IK.
Supports Levenberg-Marquardt damping (singularity avoidance), posture regularization, CoM stability, and collision barriers.
Use via the unified factory::
solver = create_ik_solver("whole_body", side="left", backend="pink",
config=PinkIKConfig(com_cost=0.1))
Source code in autolife_planning/kinematics/pink_ik_solver.py
set_collision_context(context: CollisionContext | None) -> None
¶
Replace the collision context (e.g. after updating obstacles).
fk(joint_positions: np.ndarray) -> SE3Pose
¶
Compute forward kinematics for the end effector.
Source code in autolife_planning/kinematics/pink_ik_solver.py
solve(target_pose: SE3Pose, seed: np.ndarray | None = None, config: PinkIKConfig | None = None) -> IKResult
¶
Solve IK, returning a standard :class:IKResult.
Accepts :class:PinkIKConfig; falls back to constructor default.
Source code in autolife_planning/kinematics/pink_ik_solver.py
solve_constrained(target_pose: SE3Pose, seed: np.ndarray | None = None, config: PinkIKConfig | None = None) -> ConstrainedIKResult
¶
Full constrained IK solve with trajectory output.
Input
target_pose: Desired end-effector pose. seed: Initial joint configuration (controlled joints). Uses Pinocchio neutral config if None. config: Override the default PinkIKConfig for this call.
Output: ConstrainedIKResult including the iteration trajectory.
Source code in autolife_planning/kinematics/pink_ik_solver.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | |
Collision Model¶
CollisionContext(model: Any, collision_model: Any, data: Any, collision_data: Any)
dataclass
¶
Pinocchio model with collision geometry.
build_collision_model(urdf_path: str, srdf_path: str | None = None, mesh_dir: str | None = None, min_distance: float = 0.01) -> CollisionContext
¶
Build a Pinocchio model with collision geometry from URDF + SRDF.
After SRDF filtering, pairs that are already closer than min_distance at the neutral configuration are removed. These are typically adjacent links whose meshes overlap and would make the QP infeasible.
Input
urdf_path: Path to the URDF file.
srdf_path: Path to SRDF for collision pair filtering.
If None, auto-resolves from same directory as URDF.
mesh_dir: Directory for resolving package:// mesh URIs.
Defaults to the URDF's parent directory.
min_distance: Pairs closer than this at neutral are pruned (meters).
Output: CollisionContext with model, collision model, and associated data.
Source code in autolife_planning/kinematics/collision_model.py
add_pointcloud_obstacles(context: CollisionContext, points: np.ndarray, radius: float = 0.02, voxel_size: float | None = None) -> int
¶
Add pointcloud obstacles as spheres to the collision model.
Each point becomes a sphere attached to the universe joint.
Collision pairs are added between every robot geometry and every
new obstacle sphere so that SelfCollisionBarrier checks them.
Input
context: Collision context to modify in place. points: (N, 3) array of obstacle positions in world frame. radius: Sphere radius in meters. voxel_size: If set, downsample the pointcloud to a voxel grid first.
Output: Number of obstacle spheres added.
Source code in autolife_planning/kinematics/collision_model.py
Forward Kinematics (Pinocchio)¶
pinocchio_fk
¶
Pinocchio-based forward kinematics and Jacobian computation.
Used by motion planning. IK solving is handled by trac_ik_solver.py.
PinocchioContext(model: Any, data: Any, end_effector_frame_id: int, joint_names: list[str], joint_ids: list[int])
dataclass
¶
Context holding Pinocchio model and data for FK/Jacobian computations.
create_pinocchio_context(urdf_path: str, end_effector_frame: str, joint_names: list[str] | None = None) -> PinocchioContext
¶
Create a Pinocchio context from URDF file.
Input
urdf_path: Path to the URDF file end_effector_frame: Name of the end effector frame/link joint_names: Optional list of joint names to control (if None, uses all joints)
Output: PinocchioContext containing model and data for FK/Jacobian computations
Source code in autolife_planning/kinematics/pinocchio_fk.py
compute_forward_kinematics(context: PinocchioContext, joint_positions: np.ndarray) -> SE3Pose
¶
Compute forward kinematics for the end effector.
Input
context: Pinocchio context with model and data joint_positions: Joint positions array
Output: SE3Pose of the end effector
Source code in autolife_planning/kinematics/pinocchio_fk.py
compute_jacobian(context: PinocchioContext, joint_positions: np.ndarray, local_frame: bool = False) -> np.ndarray
¶
Compute the Jacobian matrix at the end effector.
Input
context: Pinocchio context with model and data joint_positions: Joint positions array local_frame: If True, compute Jacobian in local frame; else world frame
Output: Jacobian matrix, shape (6, n_joints)