navigation

package
v0.47.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: AGPL-3.0 Imports: 23 Imported by: 1

Documentation

Overview

Package navigation is the service that allows you to navigate along waypoints. For more information, see the navigation service docs.

Package navigation is the service that allows you to navigate along waypoints.

Index

Constants

View Source
const (
	ModeManual = Mode(iota)
	ModeWaypoint
	ModeExplore

	NoMap = MapType(iota)
	GPSMap
)

The set of known modes.

View Source
const (
	// StoreTypeUnset represents when a store type was not set.
	StoreTypeUnset = ""
	// StoreTypeMemory is the constant for the memory store type.
	StoreTypeMemory = "memory"
	// StoreTypeMongoDB is the constant for the mongodb store type.
	StoreTypeMongoDB = "mongodb"
)
View Source
const SubtypeName = "navigation"

SubtypeName is the name of the type of service.

Variables

View Source
var (
	MongoDBNavStoreDBName            = "navigation"
	MongoDBNavStoreWaypointsCollName = "waypoints"
)

Database and collection names used by the MongoDBNavigationStore.

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

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

Functions

func Named added in v0.0.8

func Named(name string) resource.Name

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

func NewRPCServiceServer added in v0.2.36

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

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

func PathSliceToProto added in v0.12.0

func PathSliceToProto(paths []*Path) ([]*pb.Path, error)

PathSliceToProto converts a slice of Path into an equivalent Protobuf message.

func PathToProto added in v0.12.0

func PathToProto(path *Path) (*pb.Path, error)

PathToProto converts the Path struct into an equivalent Protobuf message.

Types

type MapType added in v0.11.0

type MapType uint8

MapType describes what map the navigation service is operating on.

func StringToMapType added in v0.11.0

func StringToMapType(mapTypeName string) (MapType, error)

StringToMapType converts an input string into one of the valid map type if possible.

func (MapType) String added in v0.11.0

func (m MapType) String() string

type MemoryNavigationStore added in v0.1.0

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

MemoryNavigationStore holds the waypoints for the navigation service.

func NewMemoryNavigationStore added in v0.1.0

func NewMemoryNavigationStore() *MemoryNavigationStore

NewMemoryNavigationStore returns and empty MemoryNavigationStore.

func (*MemoryNavigationStore) AddWaypoint added in v0.1.0

func (store *MemoryNavigationStore) AddWaypoint(ctx context.Context, point *geo.Point) (Waypoint, error)

AddWaypoint adds a waypoint to the MemoryNavigationStore.

func (*MemoryNavigationStore) Close added in v0.2.36

func (store *MemoryNavigationStore) Close(ctx context.Context) error

Close does nothing.

func (*MemoryNavigationStore) NextWaypoint added in v0.1.0

func (store *MemoryNavigationStore) NextWaypoint(ctx context.Context) (Waypoint, error)

NextWaypoint gets the next waypoint that has not been visited.

func (*MemoryNavigationStore) RemoveWaypoint added in v0.1.0

func (store *MemoryNavigationStore) RemoveWaypoint(ctx context.Context, id primitive.ObjectID) error

RemoveWaypoint removes a waypoint from the MemoryNavigationStore.

func (*MemoryNavigationStore) WaypointVisited added in v0.1.0

func (store *MemoryNavigationStore) WaypointVisited(ctx context.Context, id primitive.ObjectID) error

WaypointVisited sets that a waypoint has been visited.

func (*MemoryNavigationStore) Waypoints added in v0.1.0

func (store *MemoryNavigationStore) Waypoints(ctx context.Context) ([]Waypoint, error)

Waypoints returns a copy of all of the waypoints in the MemoryNavigationStore.

type Mode

type Mode uint8

Mode describes what mode to operate the service in.

func (Mode) String added in v0.10.0

func (m Mode) String() string

type MongoDBNavigationStore added in v0.1.0

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

MongoDBNavigationStore holds the mongodb client and waypoints collection.

func NewMongoDBNavigationStore added in v0.1.0

func NewMongoDBNavigationStore(ctx context.Context, config map[string]interface{}) (*MongoDBNavigationStore, error)

NewMongoDBNavigationStore creates a new navigation store using MongoDB.

func (*MongoDBNavigationStore) AddWaypoint added in v0.1.0

func (store *MongoDBNavigationStore) AddWaypoint(ctx context.Context, point *geo.Point) (Waypoint, error)

AddWaypoint adds a waypoint to the MongoDBNavigationStore.

func (*MongoDBNavigationStore) Close added in v0.1.0

func (store *MongoDBNavigationStore) Close(ctx context.Context) error

Close closes the connection with the mongodb client.

func (*MongoDBNavigationStore) NextWaypoint added in v0.1.0

func (store *MongoDBNavigationStore) NextWaypoint(ctx context.Context) (Waypoint, error)

NextWaypoint gets the next waypoint that has not been visited.

func (*MongoDBNavigationStore) RemoveWaypoint added in v0.1.0

func (store *MongoDBNavigationStore) RemoveWaypoint(ctx context.Context, id primitive.ObjectID) error

RemoveWaypoint removes a waypoint from the MongoDBNavigationStore.

func (*MongoDBNavigationStore) WaypointVisited added in v0.1.0

func (store *MongoDBNavigationStore) WaypointVisited(ctx context.Context, id primitive.ObjectID) error

WaypointVisited sets that a waypoint has been visited.

func (*MongoDBNavigationStore) Waypoints added in v0.1.0

func (store *MongoDBNavigationStore) Waypoints(ctx context.Context) ([]Waypoint, error)

Waypoints returns a copy of all the waypoints in the MongoDBNavigationStore.

type NavStore interface {
	Waypoints(ctx context.Context) ([]Waypoint, error)
	AddWaypoint(ctx context.Context, point *geo.Point) (Waypoint, error)
	RemoveWaypoint(ctx context.Context, id primitive.ObjectID) error
	NextWaypoint(ctx context.Context) (Waypoint, error)
	WaypointVisited(ctx context.Context, id primitive.ObjectID) error
	Close(ctx context.Context) error
}

NavStore handles the waypoints for a navigation service.

func NewStoreFromConfig added in v0.10.0

func NewStoreFromConfig(ctx context.Context, conf StoreConfig) (NavStore, error)

NewStoreFromConfig builds a NavStore from the provided StoreConfig and returns it.

type Path added in v0.12.0

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

Path describes a series of geo points the robot will travel through.

func NewPath added in v0.12.0

func NewPath(id primitive.ObjectID, geoPoints []*geo.Point) (*Path, error)

NewPath constructs a Path from a slice of geo.Points and ID.

func ProtoSliceToPaths added in v0.12.0

func ProtoSliceToPaths(pbPaths []*pb.Path) ([]*Path, error)

ProtoSliceToPaths converts a slice of Path Protobuf messages into an equivalent struct.

func ProtoToPath added in v0.12.0

func ProtoToPath(path *pb.Path) (*Path, error)

ProtoToPath converts the Path Protobuf message into an equivalent struct.

func (*Path) DestinationWaypointID added in v0.12.0

func (p *Path) DestinationWaypointID() primitive.ObjectID

DestinationWaypointID returns the ID of the Path.

func (*Path) GeoPoints added in v0.12.0

func (p *Path) GeoPoints() []*geo.Point

GeoPoints returns the slice of geo.Points the Path is comprised of.

type Properties added in v0.18.0

type Properties struct {
	MapType MapType
}

Properties returns information about the MapType that the configured navigation service is using.

type Service

type Service interface {
	resource.Resource

	// Mode returns the Mode the service is operating in.
	Mode(ctx context.Context, extra map[string]interface{}) (Mode, error)

	// SetMode sets the mode the service is operating in.
	SetMode(ctx context.Context, mode Mode, extra map[string]interface{}) error

	// Location returns the current location of the machine in the navigation service.
	Location(ctx context.Context, extra map[string]interface{}) (*spatialmath.GeoPose, error)

	// Waypoints returns an array of waypoints currently in the service's data storage which have not yet been reached.
	// These are locations designated within a path for the machine to navigate to.
	Waypoints(ctx context.Context, extra map[string]interface{}) ([]Waypoint, error)

	// AddWaypoint adds a waypoint to the service's data storage.
	AddWaypoint(ctx context.Context, point *geo.Point, extra map[string]interface{}) error

	// RemoveWaypoint removes a waypoint from the service's data storage.
	// If the machine is currently navigating to this waypoint, the motion will be canceled, and the machine will proceed to the next waypoint.
	RemoveWaypoint(ctx context.Context, id primitive.ObjectID, extra map[string]interface{}) error

	// Obstacles returns a list of obstacles to avoid, both transient and predefined, identified by the vision and navigation services.
	Obstacles(ctx context.Context, extra map[string]interface{}) ([]*spatialmath.GeoGeometry, error)

	// Paths returns each path, which is a series of geo points.
	// These points outline the planned travel route to a destination waypoint in the machine’s motion planning.
	Paths(ctx context.Context, extra map[string]interface{}) ([]*Path, error)

	// Properties returns information about the configured navigation service.
	Properties(ctx context.Context) (Properties, error)
}

A Service controls the navigation for a robot. For more information, see the navigation service docs.

Mode example:

// Get the Mode the service is operating in.
mode, err := myNav.Mode(context.Background(), nil)

SetMode example:

// Set the Mode the service is operating in to ModeWaypoint and begin navigation.
err := myNav.SetMode(context.Background(), navigation.ModeWaypoint, nil)

Location example:

// Get the current location of the robot in the navigation service.
location, err := myNav.Location(context.Background(), nil)

Waypoints example:

waypoints, err := myNav.Waypoints(context.Background(), nil)

AddWaypoint example:

// Create a new waypoint with latitude and longitude values of 0 degrees.
// Assumes you have imported "github.com/kellydunn/golang-geo" as `geo`.
location := geo.NewPoint(0, 0)

// Add your waypoint to the service's data storage.
err := myNav.AddWaypoint(context.Background(), location, nil)

RemoveWaypoint example:

// Assumes you have already called AddWaypoint once and the waypoint has not yet been reached.
waypoints, err := myNav.Waypoints(context.Background(), nil)
if (err != nil || len(waypoints) == 0) {
    return
}

// Remove the first waypoint from the service's data storage.
err = myNav.RemoveWaypoint(context.Background(), waypoints[0].ID, nil)

Obstacles example:

// Get an array containing each obstacle stored by the navigation service.
obstacles, err := myNav.Obstacles(context.Background(), nil)

Paths example:

// Get an array containing each path stored by the navigation service.
paths, err := myNav.Paths(context.Background(), nil)

Properties example:

// Get the properties of the current navigation service.
navProperties, err := myNav.Properties(context.Background())

func FromRobot added in v0.2.8

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

FromRobot is a helper for getting the named navigation 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 StoreConfig

type StoreConfig struct {
	Type   storeType              `json:"type"`
	Config map[string]interface{} `json:"config"`
}

StoreConfig describes how to configure data storage.

func (*StoreConfig) Validate

func (config *StoreConfig) Validate(path string) error

Validate ensures all parts of the config are valid.

type Waypoint

type Waypoint struct {
	ID      primitive.ObjectID `bson:"_id"`
	Visited bool               `bson:"visited"`
	Order   int                `bson:"order"`
	Lat     float64            `bson:"latitude"`
	Long    float64            `bson:"longitude"`
}

A Waypoint designates a location within a path to navigate to.

func (*Waypoint) LatLongApproxEqual added in v0.10.0

func (wp *Waypoint) LatLongApproxEqual(wp2 Waypoint) bool

LatLongApproxEqual returns true if the lat / long of the waypoint is within a small epsilon of the parameter.

func (*Waypoint) ToPoint

func (wp *Waypoint) ToPoint() *geo.Point

ToPoint converts the waypoint to a geo.Point.

Directories

Path Synopsis
Package builtin implements a navigation service.
Package builtin implements a navigation service.
Package register registers all relevant navigation models and API specific functions.
Package register registers all relevant navigation models and API specific functions.

Jump to

Keyboard shortcuts

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