robot

package
v0.15.0 Latest Latest
Warning

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

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

Documentation

Overview

Package robot defines the robot which is the root of all robotic parts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllResourcesByName

func AllResourcesByName(r Robot, name string) []resource.Resource

AllResourcesByName returns an array of all resources that have this short name. NOTE: this function queries by the shortname rather than the fully qualified resource name which is not recommended practice and may become deprecated in the future.

func NamesByAPI added in v0.2.36

func NamesByAPI(r Robot, api resource.API) []string

NamesByAPI is a helper for getting all names from the given Robot given the API.

func ResourceFromProtoMessage added in v0.2.5

func ResourceFromProtoMessage(
	robot Robot,
	msg *dynamic.Message,
	api resource.API,
) (interface{}, resource.Name, error)

ResourceFromProtoMessage attempts to find out the name/resource associated with a gRPC message.

func ResourceFromRobot added in v0.2.20

func ResourceFromRobot[T resource.Resource](robot Robot, name resource.Name) (T, error)

ResourceFromRobot returns a resource from a robot.

func TypeAndMethodDescFromMethod added in v0.2.5

func TypeAndMethodDescFromMethod(r Robot, method string) (*resource.RPCAPI, *desc.MethodDescriptor, error)

TypeAndMethodDescFromMethod attempts to determine the resource API and its respective gRPC method information from the given robot and method path. If nothing can be found, grpc.UnimplementedError is returned.

Types

type LocalRobot

type LocalRobot interface {
	Robot

	// Config returns a config representing the current state of the robot.
	Config() *config.Config

	// Reconfigure instructs the robot to safely reconfigure itself based
	// on the given new config.
	Reconfigure(ctx context.Context, newConfig *config.Config)

	// StartWeb starts the web server, will return an error if server is already up.
	StartWeb(ctx context.Context, o weboptions.Options) error

	// StopWeb stops the web server, will be a noop if server is not up.
	StopWeb()

	// WebAddress returns the address of the web service.
	WebAddress() (string, error)

	// ModuleAddress returns the address (path) of the unix socket modules use to contact the parent.
	ModuleAddress() (string, error)
}

A LocalRobot is a Robot that can have its parts modified.

type RemoteRobot

type RemoteRobot interface {
	Robot

	// Connected returns whether the remote is connected or not.
	Connected() bool
}

A RemoteRobot is a Robot that was created through a connection.

type Robot

type Robot interface {
	// DiscoverComponents returns discovered component configurations.
	DiscoverComponents(ctx context.Context, qs []resource.DiscoveryQuery) ([]resource.Discovery, error)

	// RemoteByName returns a remote robot by name.
	RemoteByName(name string) (Robot, bool)

	// ResourceByName returns a resource by name
	ResourceByName(name resource.Name) (resource.Resource, error)

	// RemoteNames returns the names of all known remote robots.
	RemoteNames() []string

	// ResourceNames returns a list of all known resource names.
	ResourceNames() []resource.Name

	// ResourceRPCAPIs returns a list of all known resource RPC APIs.
	ResourceRPCAPIs() []resource.RPCAPI

	// ProcessManager returns the process manager for the robot.
	ProcessManager() pexec.ProcessManager

	// OperationManager returns the operation manager the robot is using.
	OperationManager() *operation.Manager

	// SessionManager returns the session manager the robot is using.
	SessionManager() session.Manager

	// PackageManager returns the package manager the robot is using.
	PackageManager() packages.Manager

	// Logger returns the logger the robot is using.
	Logger() logging.Logger

	// FrameSystemConfig returns the individual parts that make up a robot's frame system
	FrameSystemConfig(ctx context.Context) (*framesystem.Config, error)

	// TransformPose will transform the pose of the requested poseInFrame to the desired frame in the robot's frame system.
	TransformPose(
		ctx context.Context,
		pose *referenceframe.PoseInFrame,
		dst string,
		additionalTransforms []*referenceframe.LinkInFrame,
	) (*referenceframe.PoseInFrame, error)

	// TransformPointCloud will transform the pointcloud to the desired frame in the robot's frame system.
	// Do not move the robot between the generation of the initial pointcloud and the receipt
	// of the transformed pointcloud because that will make the transformations inaccurate.
	TransformPointCloud(ctx context.Context, srcpc pointcloud.PointCloud, srcName, dstName string) (pointcloud.PointCloud, error)

	// Status takes a list of resource names and returns their corresponding statuses. If no names are passed in, return all statuses.
	Status(ctx context.Context, resourceNames []resource.Name) ([]Status, error)

	// Close attempts to cleanly close down all constituent parts of the robot.
	Close(ctx context.Context) error

	// StopAll cancels all current and outstanding operations for the robot and stops all actuators and movement
	StopAll(ctx context.Context, extra map[resource.Name]map[string]interface{}) error
}

A Robot encompasses all functionality of some robot comprised of parts, local and remote.

type SessionManager added in v0.2.5

type SessionManager struct {
	// contains filtered or unexported fields
}

SessionManager holds sessions for a particular robot and manages their lifetime.

func NewSessionManager added in v0.2.5

func NewSessionManager(robot Robot, heartbeatWindow time.Duration) *SessionManager

NewSessionManager creates a new manager for holding sessions.

func (*SessionManager) All added in v0.2.5

func (m *SessionManager) All() []*session.Session

All returns all active sessions.

func (*SessionManager) AssociateResource added in v0.2.5

func (m *SessionManager) AssociateResource(id uuid.UUID, resourceName resource.Name)

AssociateResource associates a session ID to a monitored resource such that when a session expires, if a resource is currently associated with that ID based on the order of AssociateResource calls, then it will have its resourc stopped. If id is uuid.Nil, this has no effect other than disassociation with a session. Be sure to include any remote information in the name.

func (*SessionManager) Close added in v0.2.5

func (m *SessionManager) Close()

Close stops the session manager but will not explicitly expire any sessions.

func (*SessionManager) FindByID added in v0.2.5

func (m *SessionManager) FindByID(ctx context.Context, id uuid.UUID, ownerID string) (*session.Session, error)

FindByID finds a session by the given ID. If found, a heartbeat is triggered, extending the lifetime of the session. If ownerID is in use but the session in question has a different owner, this is a security violation and we report back no session found.

func (*SessionManager) ServerInterceptors added in v0.2.5

func (m *SessionManager) ServerInterceptors() session.ServerInterceptors

ServerInterceptors returns gRPC interceptors to work with sessions.

func (*SessionManager) Start added in v0.2.5

func (m *SessionManager) Start(ctx context.Context, ownerID string) (*session.Session, error)

Start creates a new session that expects at least one heartbeat within the configured window.

func (*SessionManager) StreamServerInterceptor added in v0.2.5

func (m *SessionManager) StreamServerInterceptor(
	srv interface{},
	ss grpc.ServerStream,
	info *grpc.StreamServerInfo,
	handler grpc.StreamHandler,
) error

StreamServerInterceptor associates the current session (if present) in the current context before passing it to the stream response handler.

func (*SessionManager) UnaryServerInterceptor added in v0.2.5

func (m *SessionManager) UnaryServerInterceptor(
	ctx context.Context,
	req interface{},
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (interface{}, error)

UnaryServerInterceptor associates the current session (if present) in the current context before passing it to the unary response handler.

type Status

type Status struct {
	Name             resource.Name
	LastReconfigured time.Time
	Status           interface{}
}

Status holds a resource name, the time that resource was last reconfigured (or built), and its corresponding status. Status.Status is expected to be comprised of string keys and values comprised of primitives, list of primitives, maps with string keys (or at least can be decomposed into one), or lists of the forementioned type of maps. Results with other types of data are not guaranteed.

Directories

Path Synopsis
Package client contains a gRPC based robot.Robot client.
Package client contains a gRPC based robot.Robot client.
Package framesystem defines the frame system service which is responsible for managing a stateful frame system
Package framesystem defines the frame system service which is responsible for managing a stateful frame system
Package robotimpl defines implementations of robot.Robot and robot.LocalRobot.
Package robotimpl defines implementations of robot.Robot and robot.LocalRobot.
Package packages contains utilities and manager to sync Viam packages defined in the RDK config from the Viam app to the local robot.
Package packages contains utilities and manager to sync Viam packages defined in the RDK config from the Viam app to the local robot.
testutils
Package testutils is test helpers for packages.
Package testutils is test helpers for packages.
Package server contains a gRPC based robot.Robot server implementation.
Package server contains a gRPC based robot.Robot server implementation.
web
Package web provides gRPC/REST/GUI APIs to control and monitor a robot.
Package web provides gRPC/REST/GUI APIs to control and monitor a robot.
options
Package weboptions provides Options for configuring a web server
Package weboptions provides Options for configuring a web server
stream
Package webstream provides controls for streaming from the web server.
Package webstream provides controls for streaming from the web server.

Jump to

Keyboard shortcuts

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