tpspace

package
v0.48.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package tpspace defines an assortment of precomputable trajectories which can be used to plan nonholonomic 2d motion

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewNonMatchingInputError added in v0.25.0

func NewNonMatchingInputError(val1, val2 float64) error

NewNonMatchingInputError creates an error describing when.

func NewPTGFrameFromKinematicOptions added in v0.9.0

func NewPTGFrameFromKinematicOptions(
	name string,
	logger logging.Logger,
	turnRadMeters float64,
	trajCount int,
	geoms []spatialmath.Geometry,
	diffDriveOnly bool,
	canRotateInPlace bool,
) (referenceframe.Frame, error)

NewPTGFrameFromKinematicOptions will create a new Frame which is also a PTGProvider. It will precompute the default set of trajectories out to a given distance, or a default distance if the given distance is <= 0.

func PTGIKSeed added in v0.18.0

func PTGIKSeed(ptg PTGSolver) []referenceframe.Input

PTGIKSeed will generate a consistent set of valid, in-bounds inputs to be used with a PTGSolver as a seed for gradient descent.

func PTGSegmentMetric added in v0.12.0

func PTGSegmentMetric(segment *ik.Segment) float64

PTGSegmentMetric is a metric which returns the TP-space distance traversed in a segment. Since PTG inputs are relative, the distance travelled is the distance field of the ending configuration.

Types

type PTG

type PTG interface {
	// Velocities returns the linear and angular velocity at a specific point along a trajectory as a [-1, 1] proportion of maximum.
	Velocities(alpha, dist float64) (float64, float64, error)
	Transform([]referenceframe.Input) (spatialmath.Pose, error)
}

PTG is a Parameterized Trajectory Generator, which defines how to map back and forth from cartesian space to TP-space PTG coordinates are specified in polar coordinates (alpha, d) One of these is needed for each sort of motion that can be done.

func NewCCPTG

func NewCCPTG(turnRadius float64) PTG

NewCCPTG creates a new PTG of type ptgCC.

func NewCCSPTG

func NewCCSPTG(turnRadius float64) PTG

NewCCSPTG creates a new PTG of type ptgCCS.

func NewCSPTG

func NewCSPTG(turnRadius float64) PTG

NewCSPTG creates a new PTG of type ptgCS.

func NewCirclePTG

func NewCirclePTG(turnRadius float64) PTG

NewCirclePTG creates a new PTG of type ptgC.

func NewDiffDrivePTG added in v0.9.0

func NewDiffDrivePTG(turnRadius float64) PTG

NewDiffDrivePTG creates a new PTG of type ptgDiffDrive.

func NewSideSOverturnPTG added in v0.8.0

func NewSideSOverturnPTG(turnRadius float64) PTG

NewSideSOverturnPTG creates a new PTG of type ptgSideS which overturns. It turns X amount in one direction, then countersteers X*countersteerFactor in the other direction.

func NewSideSPTG added in v0.8.0

func NewSideSPTG(turnRadius float64) PTG

NewSideSPTG creates a new PTG of type ptgSideS.

type PTGCourseCorrection added in v0.25.0

type PTGCourseCorrection interface {
	PTGProvider
	CorrectionSolverIdx() int
}

PTGCourseCorrection offers an interface permitting a PTGSolver to also provide an index pointing to one of their PTGSolvers which may be used for course correction maneuvers. Usually this is the Circle PTG as it will permit the largest success rate for corrections.

type PTGProvider

type PTGProvider interface {
	// PTGs returns the list of PTGs associated with this provider
	PTGSolvers() []PTGSolver
}

PTGProvider is something able to provide a set of PTGs associsated with it. For example, a frame which precomputes a number of PTGs.

type PTGSolver added in v0.9.0

type PTGSolver interface {
	referenceframe.Limited
	PTG

	// Returns the set of trajectory nodes along the given trajectory, out to the requested distance.
	// This will return `TrajNode`s starting at dist=start, and every `resolution` increments thereafter, and finally at `end` exactly.
	Trajectory(alpha, start, end, resolution float64) ([]*TrajNode, error)
	// Solve will return the (alpha, dist) TP-space coordinates whose corresponding relative pose minimizes the given function
	Solve(context.Context, []referenceframe.Input, ik.StateMetric) (*ik.Solution, error)
}

PTGSolver wraps a PTG with the ability to perform Inverse Kinematics.

func NewPTGGridSim

func NewPTGGridSim(simPTG PTG, arcs uint, simDist float64, endsOnly bool) (PTGSolver, error)

NewPTGGridSim creates a new PTG by simulating a PTG for some distance, then cacheing the results in a grid for fast lookup.

func NewPTGIK added in v0.8.0

func NewPTGIK(simPTG PTG, logger logging.Logger, refDistLong, refDistShort float64, randSeed, trajCount int) (PTGSolver, error)

NewPTGIK creates a new ptgIK, which creates a frame using the provided PTG, and wraps it providing functions to fill the PTG interface, allowing inverse kinematics queries to be run against it.

type TrajNode

type TrajNode struct {
	// TODO: cache pose point and orientation so that we don't recompute every time we need it
	Pose   spatialmath.Pose // for 2d, we only use x, y, and OV theta
	Dist   float64          // distance travelled down trajectory
	Alpha  float64          // alpha k-value at this node
	LinVel float64          // Linear velocity as a proportion of maximum at this node [-1, 1]
	AngVel float64          // Angular velocity as a proportion of maximum at this node [-1, 1]
}

TrajNode is a snapshot of a single point in time along a PTG trajectory, including the distance along that trajectory, the elapsed time along the trajectory, and the linear and angular velocity at that point.

Jump to

Keyboard shortcuts

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