motion

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: AGPL-3.0 Imports: 20 Imported by: 3

Documentation

Overview

Package motion is the service that allows you to plan and execute movements.

Index

Constants

View Source
const (
	// PlanStateUnspecified denotes an the Plan is in an unspecified state. This should never happen.
	PlanStateUnspecified = iota

	// PlanStateInProgress denotes an the Plan is in an in progress state. It is a temporary state.
	PlanStateInProgress

	// PlanStateStopped denotes an the Plan is in a stopped state. It is a terminal state.
	PlanStateStopped

	// PlanStateSucceeded denotes an the Plan is in a succeeded state. It is a terminal state.
	PlanStateSucceeded

	// PlanStateFailed denotes an the Plan is in a failed state. It is a terminal state.
	PlanStateFailed
)
View Source
const SubtypeName = "motion"

SubtypeName is the name of the type of service.

Variables

View Source
var API = resource.APINamespaceRDK.WithServiceType(SubtypeName)

API is a variable that identifies the motion service resource API.

View Source
var SLAMOrientationAdjustment = spatialmath.NewPoseFromOrientation(&spatialmath.OrientationVectorDegrees{OZ: 1, Theta: -90})

SLAMOrientationAdjustment is needed because a SLAM map pose has orientation of OZ=1, Theta=0 when the rover is intended to be pointing at the +X axis of the SLAM map. However, for a rover's relative planning frame, driving forwards increments +Y. Thus we must adjust where the rover thinks it is.

Functions

func Named added in v0.0.8

func Named(name string) resource.Name

Named is a helper for getting the named motion service's typed resource name.

func NewRPCServiceServer added in v0.2.36

func NewRPCServiceServer(coll resource.APIResourceCollection[Service]) interface{}

NewRPCServiceServer constructs a motion gRPC service server. It is intentionally untyped to prevent use outside of tests.

Types

type ListPlanStatusesReq added in v0.11.0

type ListPlanStatusesReq struct {
	OnlyActivePlans bool
	Extra           map[string]interface{}
}

ListPlanStatusesReq describes the request to the ListPlanStatuses interface method. If OnlyActivePlans is true then only active plans will be returned. Also contains an Extra parameter.

type Localizer added in v0.3.0

type Localizer interface {
	CurrentPosition(context.Context) (*referenceframe.PoseInFrame, error)
}

Localizer is an interface which both slam and movementsensor can satisfy when wrapped respectively.

func NewMovementSensorLocalizer added in v0.6.0

func NewMovementSensorLocalizer(ms movementsensor.MovementSensor, origin *geo.Point, calibration spatialmath.Pose) Localizer

NewMovementSensorLocalizer creates a Localizer from a MovementSensor. An origin point must be specified and the localizer will return Poses relative to this point. A calibration pose can also be specified, which will adjust the location after it is calculated relative to the origin.

func NewSLAMLocalizer added in v0.6.0

func NewSLAMLocalizer(slam slam.Service) Localizer

NewSLAMLocalizer creates a new Localizer that relies on a slam service to report Pose.

type MotionConfiguration added in v0.7.3

type MotionConfiguration struct {
	ObstacleDetectors     []ObstacleDetectorName
	PositionPollingFreqHz float64
	ObstaclePollingFreqHz float64
	PlanDeviationMM       float64
	LinearMPerSec         float64
	AngularDegsPerSec     float64
}

MotionConfiguration specifies how to configure a call

type MoveOnGlobeReq added in v0.11.0

type MoveOnGlobeReq struct {
	ComponentName      resource.Name
	Destination        *geo.Point
	Heading            float64
	MovementSensorName resource.Name
	Obstacles          []*spatialmath.GeoObstacle
	MotionCfg          *MotionConfiguration
	Extra              map[string]interface{}
}

MoveOnGlobeReq describes the request to the GetPlan interface method. Contains the ComponentName the returned plan(s) should be associated with, an optional ExecutionID and an Extra parameter.

type ObstacleDetectorName added in v0.11.0

type ObstacleDetectorName struct {
	VisionServiceName resource.Name
	CameraName        resource.Name
}

ObstacleDetectorName pairs a vision service name with a camera name.

type Plan added in v0.11.0

type Plan struct {
	ID            uuid.UUID
	ComponentName resource.Name
	ExecutionID   uuid.UUID
	Steps         []PlanStep
}

Plan represnts a motion plan. Has a unique ID, ComponentName, ExecutionID and a sequence of Steps which can be executed to follow the plan.

func (Plan) ToProto added in v0.11.0

func (p Plan) ToProto() *pb.Plan

ToProto converts a Plan to a *pb.Plan.

type PlanHistoryReq added in v0.11.0

type PlanHistoryReq struct {
	ComponentName resource.Name
	LastPlanOnly  bool
	ExecutionID   uuid.UUID
	Extra         map[string]interface{}
}

PlanHistoryReq describes the request to the PlanHistory interface method. Contains the ComponentName the returned plan(s) should be associated with, an optional ExecutionID and an Extra parameter. If LastPlanOnly is set to true then only the most recent plan for the component & execution in question is returned.

type PlanState added in v0.11.0

type PlanState uint8

PlanState denotes the state a Plan is in.

func (PlanState) String added in v0.11.0

func (ps PlanState) String() string

func (PlanState) ToProto added in v0.11.0

func (ps PlanState) ToProto() pb.PlanState

ToProto converts a PlanState to a pb.PlanState.

type PlanStatus added in v0.11.0

type PlanStatus struct {
	State     PlanState
	Timestamp time.Time
	Reason    *string
}

PlanStatus describes the state of a given plan at a point in time allong with an optional reason why the PlanStatus transitioned to that state.

func (PlanStatus) ToProto added in v0.11.0

func (ps PlanStatus) ToProto() *pb.PlanStatus

ToProto converts a PlanStatus to a *pb.PlanStatus.

type PlanStatusWithID added in v0.11.0

type PlanStatusWithID struct {
	PlanID        uuid.UUID
	ComponentName resource.Name
	ExecutionID   uuid.UUID
	Status        PlanStatus
}

PlanStatusWithID describes the state of a given plan at a point in time plus the PlanId, ComponentName and ExecutionID the status is associated with.

func (PlanStatusWithID) ToProto added in v0.11.0

func (ps PlanStatusWithID) ToProto() *pb.PlanStatusWithID

ToProto converts a PlanStatusWithID to a *pb.PlanStatusWithID.

type PlanStep added in v0.11.0

type PlanStep map[resource.Name]spatialmath.Pose

PlanStep represents a single step of the plan Describes the pose each resource described by the plan should move to at that step.

func (PlanStep) ToProto added in v0.11.0

func (s PlanStep) ToProto() *pb.PlanStep

ToProto converts a Step to a *pb.PlanStep.

type PlanWithStatus added in v0.11.0

type PlanWithStatus struct {
	Plan          Plan
	StatusHistory []PlanStatus
}

PlanWithStatus contains a plan, its current status, and all state changes that came prior sorted by ascending timestamp.

func (PlanWithStatus) ToProto added in v0.11.0

func (pws PlanWithStatus) ToProto() *pb.PlanWithStatus

ToProto converts a PlanWithStatus to a *pb.PlanWithStatus.

type Service

type Service interface {
	resource.Resource
	Move(
		ctx context.Context,
		componentName resource.Name,
		destination *referenceframe.PoseInFrame,
		worldState *referenceframe.WorldState,
		constraints *pb.Constraints,
		extra map[string]interface{},
	) (bool, error)
	MoveOnMap(
		ctx context.Context,
		componentName resource.Name,
		destination spatialmath.Pose,
		slamName resource.Name,
		extra map[string]interface{},
	) (bool, error)
	MoveOnGlobe(
		ctx context.Context,
		componentName resource.Name,
		destination *geo.Point,
		heading float64,
		movementSensorName resource.Name,
		obstacles []*spatialmath.GeoObstacle,
		motionConfig *MotionConfiguration,
		extra map[string]interface{},
	) (bool, error)
	MoveOnGlobeNew(
		ctx context.Context,
		req MoveOnGlobeReq,
	) (string, error)
	GetPose(
		ctx context.Context,
		componentName resource.Name,
		destinationFrame string,
		supplementalTransforms []*referenceframe.LinkInFrame,
		extra map[string]interface{},
	) (*referenceframe.PoseInFrame, error)
	StopPlan(
		ctx context.Context,
		req StopPlanReq,
	) error
	ListPlanStatuses(
		ctx context.Context,
		req ListPlanStatusesReq,
	) ([]PlanStatusWithID, error)
	PlanHistory(
		ctx context.Context,
		req PlanHistoryReq,
	) ([]PlanWithStatus, error)
}

A Service controls the flow of moving components.

func FromDependencies added in v0.2.47

func FromDependencies(deps resource.Dependencies, name string) (Service, error)

FromDependencies is a helper for getting the named motion service from a collection of dependencies.

func FromRobot

func FromRobot(r robot.Robot, name string) (Service, error)

FromRobot is a helper for getting the named motion service from the given Robot.

func NewClientFromConn

func NewClientFromConn(
	ctx context.Context,
	conn rpc.ClientConn,
	remoteName string,
	name resource.Name,
	logger logging.Logger,
) (Service, error)

NewClientFromConn constructs a new Client from connection passed in.

type StopPlanReq added in v0.11.0

type StopPlanReq struct {
	ComponentName resource.Name
	Extra         map[string]interface{}
}

StopPlanReq describes the request to the StopPlan interface method. Contains the ComponentName of the plan which should be stopped & an Extra parameter.

Directories

Path Synopsis
Package builtin implements a motion service.
Package builtin implements a motion service.
Package explore implements a motion service for exploration.
Package explore implements a motion service for exploration.
Package register registers all relevant motion services and API specific functions.
Package register registers all relevant motion services and API specific functions.

Jump to

Keyboard shortcuts

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