Documentation ¶
Overview ¶
Package state provides apis for motion builtin plan executions and manages the state of those executions
Index ¶
- func StartExecution[R any](ctx context.Context, s *State, componentName resource.Name, req R, ...) (motion.ExecutionID, error)
- type ExecuteResponse
- type PlannerExecutor
- type PlannerExecutorConstructor
- type State
- func (s *State) ListPlanStatuses(req motion.ListPlanStatusesReq) ([]motion.PlanStatusWithID, error)
- func (s *State) PlanHistory(req motion.PlanHistoryReq) ([]motion.PlanWithStatus, error)
- func (s *State) Stop()
- func (s *State) StopExecutionByResource(componentName resource.Name) error
- func (s *State) ValidateNoActiveExecutionID(name resource.Name) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StartExecution ¶ added in v0.16.0
func StartExecution[R any]( ctx context.Context, s *State, componentName resource.Name, req R, plannerExecutorConstructor PlannerExecutorConstructor[R], ) (motion.ExecutionID, error)
StartExecution creates a new execution from a state.
Types ¶
type ExecuteResponse ¶
type ExecuteResponse struct { // If true, the Execute function didn't reach the goal & the caller should replan Replan bool // Set if Replan is true, describes why replanning was triggered ReplanReason string }
ExecuteResponse is the response from Execute.
type PlannerExecutor ¶
type PlannerExecutor interface { Plan(ctx context.Context) (motionplan.Plan, error) Execute(context.Context, motionplan.Plan) (ExecuteResponse, error) AnchorGeoPose() *spatialmath.GeoPose }
PlannerExecutor implements Plan and Execute.
type PlannerExecutorConstructor ¶ added in v0.19.0
type PlannerExecutorConstructor[R any] func( ctx context.Context, req R, seedPlan motionplan.Plan, replanCount int, ) (PlannerExecutor, error)
PlannerExecutorConstructor creates a PlannerExecutor if ctx is cancelled then all PlannerExecutor interface methods must terminate & return errors req is the request that will be used during planning & execution seedPlan (nil during the first plan) is the previous plan if replanning has occurred replanCount is the number of times replanning has occurred, zero the first time planning occurs. R is a genric type which is able to be used to create a PlannerExecutor.
type State ¶
type State struct {
// contains filtered or unexported fields
}
State is the state of the builtin motion service It keeps track of the builtin motion service's executions.
func NewState ¶
func NewState( ttl time.Duration, ttlCheckInterval time.Duration, logger logging.Logger, ) (*State, error)
NewState creates a new state. Takes a [TTL](https://en.wikipedia.org/wiki/Time_to_live) and an interval to delete any State data that is older than the TTL.
func (*State) ListPlanStatuses ¶ added in v0.16.0
func (s *State) ListPlanStatuses(req motion.ListPlanStatusesReq) ([]motion.PlanStatusWithID, error)
ListPlanStatuses returns the status of plans created by MoveOnGlobe requests that are executing OR are part of an execution which changed it state within the a 24HR TTL OR until the robot reinitializes. If OnlyActivePlans is provided, only returns plans which are in non terminal states.
func (*State) PlanHistory ¶ added in v0.16.0
func (s *State) PlanHistory(req motion.PlanHistoryReq) ([]motion.PlanWithStatus, error)
PlanHistory returns the plans with statuses of the resource By default returns all plans from the most recent execution of the resoure If the ExecutionID is provided, returns the plans of the ExecutionID rather than the most recent execution If LastPlanOnly is provided then only the last plan is returned for the execution with the ExecutionID if it is provided, or the last execution for that component otherwise.
func (*State) StopExecutionByResource ¶ added in v0.16.0
StopExecutionByResource stops the active execution with a given resource name in the State.