klampt.plan.kinetrajopt.utils module

Classes:

CostInterface()

An abstract base class for a cost function.

ConstrInterface()

An abstract base class for a constraint function.

ConstrContainer([eqs, ineqs])

This one maintains a grid for constraints.

JointLimitsConstr(qmin, qmax)

The class for joint limits

MaskedRobot(robot, index)

Creates a mask to robot so only certain links can be changed.

MaskedTerrain(world, index)

This object manages the obstacles we have to consider

class klampt.plan.kinetrajopt.utils.CostInterface[source]

Bases: object

An abstract base class for a cost function. The subclass must implement compute to evaluate f(x), d/dx f(x), and/or d^2/dx^2 f(x).

Methods:

compute(x[, grad_level])

Evaluates the cost and possibly (determining on grad_level) the derivative and/or Hessian.

compute(x, grad_level=0)[source]

Evaluates the cost and possibly (determining on grad_level) the derivative and/or Hessian.

Parameters
  • x (ndarray) – The evaluation point

  • grad_level (int, optional) – Which order of derivatives are computed. Defaults to 0, which only computes cost.

Returns

the cost and optional derivatives, structured as follows:

  • if grad_level == 0, it returns (cost,)

  • if grad_level == 1, it returns (cost,gradient)

  • if grad_level == 2, it returns (cost,gradient,hessian)

Return type

tuple

class klampt.plan.kinetrajopt.utils.ConstrInterface[source]

Bases: object

An abstract base class for a constraint function. The subclass must implement compute to evaluate g(x) and/or d/dx g(x).

The interpretation of whether this gives an equality or equality is not provided in this class. See ConstrContainer.

Currently sparsity is not supported.

Methods:

compute(x[, grad_level])

Evaluates the constraint function and possibly (determining on grad_level) the Jacobian.

compute(x, grad_level=0)[source]

Evaluates the constraint function and possibly (determining on grad_level) the Jacobian.

Parameters
  • x (ndarray) – the point to be evaluated

  • grad_level (int, optional) – which level of gradient is computed. Defaults to 0.

Returns

The constraint value and optional derivatives, structured as follows:

  • If grad_level == 0, it returns a 1-D ndarray of g(x)

  • If grad_level == 1, it also returns a 2-D ndarray giving the constraint Jacobian d/dx g(x).

Return type

tuple

class klampt.plan.kinetrajopt.utils.ConstrContainer(eqs=None, ineqs=None)[source]

Bases: object

This one maintains a grid for constraints.

Parameters
  • eqs – list of equality constraint in the format of (index, constr)

  • ineqs – list of equality constraint in the format of (index, constr)

Methods:

add_eq(index, constr)

Add an equality constraint to the container.

add_ineq(index, constr)

Add an inequality constraint to the container.

merge(container)

Merge current container with another container

add_eq(index, constr)[source]

Add an equality constraint to the container.

Parameters
  • index – int, at which point of the trajectory is the constraint imposed. Can be negative indexed. If None, it applies to all points.

  • constr – ConstrInterface, the constraint which has to be zero at the solution.

add_ineq(index, constr)[source]

Add an inequality constraint to the container.

Parameters
  • index – int, at which point of the trajectory is the constraint imposed. Can be negative indexed. If None, it applies to all points.

  • constr – ConstrInterface, the constraint which has to be negative at the solution.

merge(container)[source]

Merge current container with another container

Parameters

container – ConstrContainer, jsut another instance of constraint container

class klampt.plan.kinetrajopt.utils.JointLimitsConstr(qmin, qmax)[source]

Bases: klampt.plan.kinetrajopt.utils.ConstrInterface

The class for joint limits

Methods:

compute(x[, grad_level])

Evaluates the constraint function and possibly (determining on grad_level) the Jacobian.

compute(x, grad_level=0)[source]

Evaluates the constraint function and possibly (determining on grad_level) the Jacobian.

Parameters
  • x (ndarray) – the point to be evaluated

  • grad_level (int, optional) – which level of gradient is computed. Defaults to 0.

Returns

The constraint value and optional derivatives, structured as follows:

  • If grad_level == 0, it returns a 1-D ndarray of g(x)

  • If grad_level == 1, it also returns a 2-D ndarray giving the constraint Jacobian d/dx g(x).

Return type

tuple

class klampt.plan.kinetrajopt.utils.MaskedRobot(robot, index)[source]

Bases: object

Creates a mask to robot so only certain links can be changed.

Slightly faster than SubRobotModel since it uses numpy to do the indexing.

Parameters
  • object (robot) – klampt robot

  • index (arr-like) – list of active links

Methods:

setConfig(config)

positionJacobian(linkid[, config, lcl_pos])

orientationJacobian(linkid[, config])

numLink()

link_masked(num)

link(num)

setConfig(config)[source]
positionJacobian(linkid, config=None, lcl_pos=[0, 0, 0])[source]
orientationJacobian(linkid, config=None)[source]
class klampt.plan.kinetrajopt.utils.MaskedTerrain(world, index)[source]

Bases: object

This object manages the obstacles we have to consider

Methods:

terrain(num)

terrain_unmasked(num)

terrain(num)[source]
terrain_unmasked(num)[source]