base

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: AGPL-3.0 Imports: 13 Imported by: 6

Documentation

Overview

Package base defines the base that a robot uses to move around.

Package base contains a gRPC based base client

Package base contains an enum representing optional base features

Package base contains a gRPC based arm service server.

Index

Constants

View Source
const SubtypeName = "base"

SubtypeName is a constant that identifies the component resource API string "base".

Variables

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

API is a variable that identifies the component resource API.

Functions

func CreateStatus

func CreateStatus(ctx context.Context, b Base) (*commonpb.ActuatorStatus, error)

CreateStatus creates a status from the base.

func Named

func Named(name string) resource.Name

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

func NamesFromRobot

func NamesFromRobot(r robot.Robot) []string

NamesFromRobot is a helper for getting all base names from the given Robot.

func NewRPCServiceServer added in v0.2.36

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

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

func PropertiesToProtoResponse added in v0.2.50

func PropertiesToProtoResponse(
	features Properties,
) (*pb.GetPropertiesResponse, error)

PropertiesToProtoResponse takes a map of features to struct and converts it to a GetPropertiesResponse.

Types

type Base

type Base interface {
	resource.Resource
	resource.Actuator
	resource.Shaped

	// MoveStraight moves the robot straight a given distance at a given speed.
	// If a distance or speed of zero is given, the base will stop.
	// This method blocks until completed or cancelled
	//
	//    myBase, err := base.FromRobot(machine, "my_base")
	//    // Move the base forward 40 mm at a velocity of 90 mm/s.
	//    myBase.MoveStraight(context.Background(), 40, 90, nil)
	//
	//    // Move the base backward 40 mm at a velocity of -90 mm/s.
	//    myBase.MoveStraight(context.Background(), 40, -90, nil)
	MoveStraight(ctx context.Context, distanceMm int, mmPerSec float64, extra map[string]interface{}) error

	// Spin spins the robot by a given angle in degrees at a given speed.
	// If a speed of 0 the base will stop.
	// Given a positive speed and a positive angle, the base turns to the left (for built-in RDK drivers)
	// This method blocks until completed or cancelled
	//
	//    myBase, err := base.FromRobot(machine, "my_base")
	//
	//    // Spin the base 10 degrees at an angular velocity of 15 deg/sec.
	//    myBase.Spin(context.Background(), 10, 15, nil)
	Spin(ctx context.Context, angleDeg, degsPerSec float64, extra map[string]interface{}) error

	// For linear power, positive Y moves forwards for built-in RDK drivers
	// For angular power, positive Z turns to the left for built-in RDK drivers
	//    myBase, err := base.FromRobot(machine, "my_base")
	//
	//    // Make your wheeled base move forward. Set linear power to 75%.
	//    logger.Info("move forward")
	//    err = myBase.SetPower(context.Background(), r3.Vector{Y: .75}, r3.Vector{}, nil)
	//
	//    // Make your wheeled base move backward. Set linear power to -100%.
	//    logger.Info("move backward")
	//    err = myBase.SetPower(context.Background(), r3.Vector{Y: -1}, r3.Vector{}, nil)
	//
	//    // Make your wheeled base spin left. Set angular power to 100%.
	//    logger.Info("spin left")
	//    err = myBase.SetPower(context.Background(), r3.Vector{}, r3.Vector{Z: 1}, nil)
	//
	//    // Make your wheeled base spin right. Set angular power to -75%.
	//    logger.Info("spin right")
	//    err = mybase.SetPower(context.Background(), r3.Vector{}, r3.Vector{Z: -.75}, nil)
	SetPower(ctx context.Context, linear, angular r3.Vector, extra map[string]interface{}) error

	// linear is in mmPerSec (positive Y moves forwards for built-in RDK drivers)
	// angular is in degsPerSec (positive Z turns to the left for built-in RDK drivers)
	//
	//    myBase, err := base.FromRobot(machine, "my_base")
	//
	//    // Set the linear velocity to 50 mm/sec and the angular velocity to 15 deg/sec.
	//    myBase.SetVelocity(context.Background(), r3.Vector{Y: 50}, r3.Vector{Z: 15}, nil)
	SetVelocity(ctx context.Context, linear, angular r3.Vector, extra map[string]interface{}) error

	// Properties returns the width, turning radius, and wheel circumference of the physical base in meters.
	//
	//    myBase, err := base.FromRobot(machine, "my_base")
	//
	//    // Get the width and turning radius of the base
	//    properties, err := myBase.Properties(context.Background(), nil)
	//
	//    // Get the width
	//    myBaseWidth := properties.WidthMeters
	//
	//    // Get the turning radius
	//    myBaseTurningRadius := properties.TurningRadiusMeters
	//
	//    // Get the wheel circumference
	//    myBaseWheelCircumference := properties.WheelCircumferenceMeters
	Properties(ctx context.Context, extra map[string]interface{}) (Properties, error)
}

A Base represents a physical base of a robot.

func FromDependencies

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

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

func FromRobot

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

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

func NewClientFromConn

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

NewClientFromConn constructs a new Client from connection passed in.

type Properties added in v0.2.50

type Properties struct {
	TurningRadiusMeters      float64
	WidthMeters              float64
	WheelCircumferenceMeters float64
}

Properties is a structure representing features of a base.

func ProtoFeaturesToProperties added in v0.2.50

func ProtoFeaturesToProperties(resp *pb.GetPropertiesResponse) Properties

ProtoFeaturesToProperties takes a GetPropertiesResponse and returns an equivalent Properties struct.

Directories

Path Synopsis
Package fake implements a fake base.
Package fake implements a fake base.
Package kinematicbase contains wrappers that augment bases with information needed for higher level control over the base
Package kinematicbase contains wrappers that augment bases with information needed for higher level control over the base
Package register registers all relevant bases
Package register registers all relevant bases
Package sensorcontrolled base implements a base with feedback control from a movement sensor
Package sensorcontrolled base implements a base with feedback control from a movement sensor
Package wheeled implements some bases, like a wheeled base.
Package wheeled implements some bases, like a wheeled base.

Jump to

Keyboard shortcuts

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