klampt.model.subrobot module

Defines the SubRobotModel class, which is RobotModel-like but only modifies selected degrees of freedom of the robot (e.g., an arm, a leg).

Many, but not all, klampt module functions accept SubRobotModel in the place of RobotModel.

class klampt.model.subrobot.SubRobotModel(robot, links)[source]

Bases: object

A helper that lets you conveniently set/get quantities for a subset of moving links on a RobotModel. This class has the same API as RobotModel, but everything is re-indexed so that configurations and link indices only modify the given subset of links. As a reult, most methods applicable to a RobotModel can also be applied to a SubRobotModel.

You provide the list of moving link indices or names in the constructor.

The methods tofull and fromfull convert objects to and from the full robot.

Parameters
  • robot (RobotModel or SubRobotModel) – the robot to base this on.

  • links (list of ints or strs) – the links to use in this sub-robot.

tofull(object, reference=None)[source]

Converts the given index, link, configuration, velocity, or trajectory of a sub robot to the corresponding object of the full robot.

Parameters
  • object – an integer index, configuration, velocity, matrix, list of configurations, or Trajectory.

  • reference (list, optional) – describes the reference object that this should fill in for the indices not in this sub-robot. By default, uses the robot’s current configuration.

Returns

The corresponding object mapped to the full robot.

fromfull(object)[source]

Converts the given index, configuration, velocity, or trajectory of a full robot to the corresponding object of the sub-robot.

Parameters

object – an integer index, configuration, velocity, matrix, list of configurations, or Trajectory.

Returns

The corresponding object mapped to the sub-robot.

Note

For indices, if the index doesn’t belong to the sub-robot then None is returned.

Return type

int

Return type

SubRobotModelLink

numDrivers()[source]
Return type

int

driver(index)[source]
Return type

SubRobotModelDriver

getConfig()[source]
Return type

Sequence[float]

getVelocity()[source]
Return type

Sequence[float]

setConfig(q)[source]
Return type

None

setVelocity(q)[source]
Return type

None

getJointLimits()[source]
Return type

Tuple[Sequence[float], Sequence[float]]

setJointLimits(qmin, qmax)[source]
Return type

None

getVelocityLimits()[source]
Return type

Sequence[float]

setVelocityLimits(vmax)[source]
Return type

None

getAccelerationLimits()[source]
Return type

Sequence[float]

setAccelerationLimits(amax)[source]
Return type

None

getTorqueLimits()[source]
Return type

Sequence[float]

setTorqueLimits(tmax)[source]
Return type

None

setDOFPosition(index, qi)[source]
Return type

None

getDOFPosition(index)[source]
Return type

float

getCom()[source]
getComJacobian()[source]
getLinearMomentum()[source]
Return type

Sequence[float]

getAngularMomentum()[source]
Return type

Sequence[float]

getKineticEnergy()[source]
Return type

float

getTotalInertia()[source]
getMassMatrix()[source]
getMassMatrixInv()[source]
getCoriolisForceMatrix()[source]
getCoriolisForces()[source]
getGravityForces(g)[source]
torquesFromAccel(ddq)[source]
accelFromTorques(t)[source]
interpolate(a, b, u)[source]
Return type

Sequence[float]

distance(a, b)[source]
Return type

float

interpolateDeriv(a, b)[source]
Return type

Sequence[float]

randomizeConfig(unboundedScale=1.0)[source]
Return type

None

configToDrivers(q)[source]
Return type

Sequence[float]

velocityToDrivers(dq)[source]
Return type

Sequence[float]

configFromDrivers(driverValues)[source]
Return type

Sequence[float]

velocityFromDrivers(driverVelocities)[source]
Return type

Sequence[float]

selfCollisionEnabled(link1, link2)[source]
enableSelfCollision(link1, link2, value=True)[source]
selfCollides()[source]
drawGL(keepAppearance=True)[source]
reduce()[source]
mount(link, subRobot, R, t)[source]
sensor(index)[source]

Returns the SimSensorModel corresponding to index. Note however that you can’t set the “link” setting according to this SubRobotModel.

Parameters

index (int or str) –

Bases: object

A helper that lets you treat links of a subrobot just like a normal RobotModelLink. Correctly implements jacobians and indices with respect to the sub-robot.

robot()[source]
getIndex()[source]
getParent()[source]
parent()[source]
setParent(p)[source]
getJacobian(p)[source]
getPositionJacobian(p)[source]
getOrientationJacobian()[source]
class klampt.model.subrobot.SubRobotModelDriver(driver, robot)[source]

Bases: object

A helper that lets you treat drivers of a subrobot just like a normal RobotModelDriver.

robot()[source]