ik

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2023 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package ik contains tols for doing gradient-descent based inverse kinematics, allowing for the minimization of arbitrary metrics based on the output of calling `Transform` on the given frame.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JointMetric

func JointMetric(segment *Segment) float64

JointMetric is a metric which will sum the squared differences in each input from start to end.

func L2InputMetric

func L2InputMetric(segment *Segment) float64

L2InputMetric is a metric which will return a L2 norm of the StartConfiguration and EndConfiguration in an arc input.

func OrientDist

func OrientDist(o1, o2 spatial.Orientation) float64

OrientDist returns the arclength between two orientations in degrees.

func OrientDistToRegion

func OrientDistToRegion(goal spatial.Orientation, alpha float64) func(spatial.Orientation) float64

OrientDistToRegion will return a function which will tell you how far the unit sphere component of an orientation vector is from a region defined by a point and an arclength around it. The theta value of OV is disregarded. This is useful, for example, in defining the set of acceptable angles of attack for writing on a whiteboard.

func SquaredNormNoOrientSegmentMetric

func SquaredNormNoOrientSegmentMetric(segment *Segment) float64

SquaredNormNoOrientSegmentMetric is a metric which will return the cartesian distance between the two positions.

Types

type InverseKinematics

type InverseKinematics interface {
	// Solve receives a context, the goal arm position, and current joint angles.
	Solve(context.Context, chan<- *Solution, []referenceframe.Input, StateMetric, int) error
}

InverseKinematics defines an interface which, provided with seed inputs and a Metric to minimize to zero, will output all found solutions to the provided channel until cancelled or otherwise completes.

func CreateCombinedIKSolver

func CreateCombinedIKSolver(model referenceframe.Frame, logger golog.Logger, nCPU int) (InverseKinematics, error)

CreateCombinedIKSolver is not supported on windows. TODO(RSDK-1772): support motion planning on windows

type Segment

type Segment struct {
	StartPosition      spatial.Pose
	EndPosition        spatial.Pose
	StartConfiguration []referenceframe.Input
	EndConfiguration   []referenceframe.Input
	Frame              referenceframe.Frame
}

Segment contains all the information a constraint needs to determine validity for a movement. It contains the starting inputs, the ending inputs, corresponding poses, and the frame it refers to. Pose fields may be empty, and may be filled in by a constraint that needs them.

type SegmentMetric

type SegmentMetric func(*Segment) float64

SegmentMetric are functions which produce some score given an Segment. Lower is better. This is used to sort produced IK solutions by goodness, for example.

func NewSquaredNormSegmentMetric

func NewSquaredNormSegmentMetric(orientationScaleFactor float64) SegmentMetric

NewSquaredNormSegmentMetric returns a metric which will return the cartesian distance between the two positions. It allows the caller to choose the scaling level of orientation.

type Solution

type Solution struct {
	Configuration []referenceframe.Input
	Score         float64
	Exact         bool
}

Solution is the struct returned from an IK solver. It contains the solution configuration, the score of the solution, and a flag indicating whether that configuration and score met the solution criteria requested by the caller.

type State

type State struct {
	Position      spatial.Pose
	Configuration []referenceframe.Input
	Frame         referenceframe.Frame
}

State contains all the information a constraint needs to determine validity for a movement. It contains the starting inputs, the ending inputs, corresponding poses, and the frame it refers to. Pose fields may be empty, and may be filled in by a constraint that needs them.

type StateMetric

type StateMetric func(*State) float64

StateMetric are functions which, given a State, produces some score. Lower is better. This is used for gradient descent to converge upon a goal pose, for example.

func CombineMetrics

func CombineMetrics(metrics ...StateMetric) StateMetric

CombineMetrics will take a variable number of Metrics and return a new Metric which will combine all given metrics into one, summing their distances.

func NewPoseFlexOVMetric

func NewPoseFlexOVMetric(goal spatial.Pose, alpha float64) StateMetric

NewPoseFlexOVMetric will provide a distance function which will converge on a pose with an OV within an arclength of `alpha` of the ov of the goal given.

func NewPositionOnlyMetric

func NewPositionOnlyMetric(goal spatial.Pose) StateMetric

NewPositionOnlyMetric returns a Metric that reports the point-wise distance between two poses without regard for orientation. This is useful for scenarios where there are not enough DOF to control orientation, but arbitrary spatial points may still be arrived at.

func NewSquaredNormMetric

func NewSquaredNormMetric(goal spatial.Pose) StateMetric

NewSquaredNormMetric is the default distance function between two poses to be used for gradient descent.

func NewZeroMetric

func NewZeroMetric() StateMetric

NewZeroMetric always returns zero as the distance between two points.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL