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 ¶
- func FSConfigurationDistance(segment *SegmentFS) float64
- func FSConfigurationL2Distance(segment *SegmentFS) float64
- func JointMetric(segment *Segment) float64
- func L2InputMetric(segment *Segment) float64
- func NewMetricMinFunc(metric StateMetric, frame referenceframe.Frame, logger logging.Logger) func([]float64) float64
- func NewPoseFlexOVMetricConstructor(alpha float64) func(spatial.Pose) StateMetric
- func OrientDist(o1, o2 spatial.Orientation) float64
- func OrientDistToRegion(goal spatial.Orientation, alpha float64) func(spatial.Orientation) float64
- func SolveMetric(ctx context.Context, ik Solver, frame referenceframe.Frame, ...) error
- func SquaredNormNoOrientSegmentMetric(segment *Segment) float64
- func WeightedSquaredNormSegmentMetric(segment *Segment) float64
- type Segment
- type SegmentFS
- type SegmentFSMetric
- type SegmentMetric
- type Solution
- type Solver
- type State
- type StateFS
- type StateFSMetric
- type StateMetric
- func CombineMetrics(metrics ...StateMetric) StateMetric
- func NewPosWeightSquaredNormMetric(goal spatial.Pose) StateMetric
- func NewPositionOnlyMetric(goal spatial.Pose) StateMetric
- func NewScaledSquaredNormMetric(goal spatial.Pose, orientationDistanceScale float64) StateMetric
- func NewSquaredNormMetric(goal spatial.Pose) StateMetric
- func NewZeroMetric() StateMetric
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FSConfigurationDistance ¶ added in v0.54.0
FSConfigurationDistance is a fs metric which will sum the abs differences in each input from start to end.
func FSConfigurationL2Distance ¶ added in v0.54.0
FSConfigurationL2Distance is a fs metric which will sum the L2 norm differences in each input from start to end.
func JointMetric ¶
JointMetric is a metric which will sum the squared differences in each input from start to end.
func L2InputMetric ¶
L2InputMetric is a metric which will return a L2 norm of the StartConfiguration and EndConfiguration in an arc input.
func NewMetricMinFunc ¶ added in v0.48.1
func NewMetricMinFunc(metric StateMetric, frame referenceframe.Frame, logger logging.Logger) func([]float64) float64
NewMetricMinFunc takes a metric and a frame, and converts to a function able to be minimized with Solve().
func NewPoseFlexOVMetricConstructor ¶ added in v0.10.0
func NewPoseFlexOVMetricConstructor(alpha float64) func(spatial.Pose) StateMetric
NewPoseFlexOVMetricConstructor 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 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 SolveMetric ¶ added in v0.48.1
func SolveMetric( ctx context.Context, ik Solver, frame referenceframe.Frame, solutionChan chan<- *Solution, seed []referenceframe.Input, solveMetric StateMetric, rseed int, logger logging.Logger, ) error
SolveMetric is a wrapper for Metrics to be used easily with Solve for IK solvers.
func SquaredNormNoOrientSegmentMetric ¶
SquaredNormNoOrientSegmentMetric is a metric which will return the cartesian distance between the two positions.
func WeightedSquaredNormSegmentMetric ¶ added in v0.54.0
WeightedSquaredNormSegmentMetric is a distance function between two poses to be used for gradient descent. This changes the magnitude of the position delta used to be smaller and avoid numeric instability issues that happens with large floats. It also scales the orientation distance to give more weight to it.
Types ¶
type Segment ¶
type Segment struct { StartPosition spatial.Pose EndPosition spatial.Pose StartConfiguration []referenceframe.Input EndConfiguration []referenceframe.Input Frame referenceframe.Frame }
Segment is a referenceframe.Frame-specific 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 SegmentFS ¶ added in v0.54.0
type SegmentFS struct { StartConfiguration map[string][]referenceframe.Input EndConfiguration map[string][]referenceframe.Input FS referenceframe.FrameSystem }
SegmentFS is a referenceframe.FrameSystem-specific contains all the information a constraint needs to determine validity for a movement. It contains the starting inputs, the ending inputs, and the framesystem it refers to.
type SegmentFSMetric ¶ added in v0.54.0
SegmentFSMetric are functions which produce some score given an SegmentFS. Lower is better. This is used to sort produced IK solutions by goodness, for example.
type SegmentMetric ¶
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 ¶
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 Solver ¶ added in v0.48.1
type Solver interface { referenceframe.Limited // Solve receives a context, a channel to which solutions will be provided, a function whose output should be minimized, and a // number of iterations to run. Solve(context.Context, chan<- *Solution, []float64, func([]float64) float64, int) error }
Solver defines an interface which, provided with seed inputs and a function to minimize to zero, will output all found solutions to the provided channel until cancelled or otherwise completes.
func CreateCombinedIKSolver ¶
func CreateCombinedIKSolver( limits []referenceframe.Limit, logger logging.Logger, nCPU int, goalThreshold float64, ) (Solver, error)
CreateCombinedIKSolver creates a combined parallel IK solver that operates on a frame with a number of nlopt solvers equal to the nCPU passed in. Each will be given a different random seed. When asked to solve, all solvers will be run in parallel and the first valid found solution will be returned.
func CreateNloptSolver ¶ added in v0.48.1
func CreateNloptSolver( limits []referenceframe.Limit, logger logging.Logger, iter int, exact, useRelTol bool, ) (Solver, error)
CreateNloptSolver creates an nloptIK object that can perform gradient descent on functions. The parameters are the limits of the solver, a logger, and the number of iterations to run. If the iteration count is less than 1, it will be set to the default of 5000.
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 particular state or configuration. It contains inputs, the corresponding poses, and the frame it refers to. Pose field may be empty, and may be filled in by a constraint that needs it.
type StateFS ¶ added in v0.54.0
type StateFS struct { Configuration map[string][]referenceframe.Input FS referenceframe.FrameSystem }
StateFS contains all the information a constraint needs to determine validity for a particular state or configuration of an entire framesystem. It contains inputs, the corresponding poses, and the frame it refers to. Pose field may be empty, and may be filled in by a constraint that needs it.
type StateFSMetric ¶ added in v0.54.0
StateFSMetric are functions which, given a StateFS, produces some score. Lower is better. This is used for gradient descent to converge upon a goal pose, for example.
func CombineFSMetrics ¶ added in v0.54.0
func CombineFSMetrics(metrics ...StateFSMetric) StateFSMetric
CombineFSMetrics will take a variable number of StateFSMetrics and return a new StateFSMetric which will combine all given metrics into one, summing their distances.
func NewZeroFSMetric ¶ added in v0.54.0
func NewZeroFSMetric() StateFSMetric
NewZeroFSMetric always returns zero as the distance.
type StateMetric ¶
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 NewPosWeightSquaredNormMetric ¶ added in v0.17.0
func NewPosWeightSquaredNormMetric(goal spatial.Pose) StateMetric
NewPosWeightSquaredNormMetric is a distance function between two poses to be used for gradient descent. This changes the magnitude of the position delta used to be smaller and avoid numeric instability issues that happens with large floats. TODO: RSDK-6053 this should probably be done more flexibly.
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 NewScaledSquaredNormMetric ¶ added in v0.31.0
func NewScaledSquaredNormMetric(goal spatial.Pose, orientationDistanceScale float64) StateMetric
NewScaledSquaredNormMetric is a distance function between two poses. It allows the user to scale the contribution of orientation.
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.