cartofacade

package
v0.3.44 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package cartofacade contains the api to call into CGO

Package cartofacade is used to mock the CGo API.

Package cartofacade contains the api to call into CGO

Package cartofacade is used to mock a cartofacade.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnableToAcquireLock = errors.New("VIAM_CARTO_UNABLE_TO_ACQUIRE_LOCK")

ErrUnableToAcquireLock is the error returned from AddLidarReading, AddIMUReading, and/or AddOdometerReading when lock can't be acquired.

Functions

This section is empty.

Types

type Carto

type Carto struct {
	SlamMode
	// contains filtered or unexported fields
}

Carto holds the c type viam_carto

func NewCarto added in v0.3.19

func NewCarto(cfg CartoConfig, acfg CartoAlgoConfig, vcl CartoLibInterface) (Carto, error)

NewCarto calls viam_carto_init and returns a pointer to a viam carto object. vcl is only an interface to facilitate testing. The only type vcl is expected to have is a CartoLib.

type CartoAlgoConfig

type CartoAlgoConfig struct {
	OptimizeOnStart      bool
	OptimizeEveryNNodes  int
	NumRangeData         int
	MissingDataRayLength float32
	MaxRange             float32
	MinRange             float32
	UseIMUData           bool
	MaxSubmapsToKeep     int
	FreshSubmapsCount    int
	MinCoveredArea       float64
	MinAddedSubmapsCount int
	OccupiedSpaceWeight  float64
	TranslationWeight    float64
	RotationWeight       float64

	HasInitialTrajectoryPose   bool
	InitialTrajectoryPoseX     float64
	InitialTrajectoryPoseY     float64
	InitialTrajectoryPoseTheta float64
}

CartoAlgoConfig contains config values from app

func GetTestAlgoConfig added in v0.3.19

func GetTestAlgoConfig(useImuData bool) CartoAlgoConfig

GetTestAlgoConfig gets a sample algo config for testing purposes.

type CartoConfig

type CartoConfig struct {
	Camera             string
	MovementSensor     string
	ComponentReference string
	LidarConfig        LidarConfig

	EnableMapping bool
	ExistingMap   string
}

CartoConfig contains config values from app

func GetBadTestConfig added in v0.3.19

func GetBadTestConfig() CartoConfig

GetBadTestConfig gets a sample config for testing purposes that will cause a failure.

func GetTestConfig added in v0.3.19

func GetTestConfig(cameraName, movementSensorName, filename string, enableMapping bool) CartoConfig

GetTestConfig gets a sample config for testing purposes.

type CartoFacade added in v0.3.19

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

CartoFacade exists to ensure that only one go routine is calling into the CGO api at a time to ensure the go runtime doesn't spawn multiple OS threads, which would harm performance.

func New

func New(cartoLib CartoLibInterface, cartoCfg CartoConfig, cartoAlgoCfg CartoAlgoConfig) CartoFacade

New instantiates the Cartofacade struct which limits calls into C.

func (*CartoFacade) AddIMUReading added in v0.3.26

func (cf *CartoFacade) AddIMUReading(
	ctx context.Context,
	timeout time.Duration,
	movementSensorName string,
	currentReading s.TimedIMUReadingResponse,
) error

AddIMUReading calls into the cartofacade C code.

func (*CartoFacade) AddLidarReading added in v0.3.25

func (cf *CartoFacade) AddLidarReading(
	ctx context.Context,
	timeout time.Duration,
	lidarName string,
	currentReading s.TimedLidarReadingResponse,
) error

AddLidarReading calls into the cartofacade C code.

func (*CartoFacade) AddOdometerReading added in v0.3.41

func (cf *CartoFacade) AddOdometerReading(
	ctx context.Context,
	timeout time.Duration,
	movementSensorName string,
	currentReading s.TimedOdometerReadingResponse,
) error

AddOdometerReading calls into the cartofacade C code.

func (*CartoFacade) Initialize added in v0.3.19

func (cf *CartoFacade) Initialize(ctx context.Context, timeout time.Duration, activeBackgroundWorkers *sync.WaitGroup) (SlamMode, error)

Initialize calls into the cartofacade C code.

func (*CartoFacade) InternalState added in v0.3.27

func (cf *CartoFacade) InternalState(ctx context.Context, timeout time.Duration) ([]byte, error)

InternalState calls into the cartofacade C code.

func (*CartoFacade) PointCloudMap added in v0.3.27

func (cf *CartoFacade) PointCloudMap(ctx context.Context, timeout time.Duration) ([]byte, error)

PointCloudMap calls into the cartofacade C code.

func (*CartoFacade) Position added in v0.3.27

func (cf *CartoFacade) Position(ctx context.Context, timeout time.Duration) (Position, error)

Position calls into the cartofacade C code.

func (*CartoFacade) RunFinalOptimization added in v0.3.26

func (cf *CartoFacade) RunFinalOptimization(ctx context.Context, timeout time.Duration) error

RunFinalOptimization calls into the cartofacade C code.

func (*CartoFacade) Start added in v0.3.19

func (cf *CartoFacade) Start(ctx context.Context, timeout time.Duration) error

Start calls into the cartofacade C code.

func (*CartoFacade) Stop added in v0.3.19

func (cf *CartoFacade) Stop(ctx context.Context, timeout time.Duration) error

Stop calls into the cartofacade C code.

func (*CartoFacade) Terminate added in v0.3.19

func (cf *CartoFacade) Terminate(ctx context.Context, timeout time.Duration) error

Terminate calls into the cartofacade C code.

type CartoInterface added in v0.3.19

type CartoInterface interface {
	// contains filtered or unexported methods
}

CartoInterface describes the method signatures that Carto must implement

type CartoLib

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

CartoLib holds the c type viam_carto_lib

func NewLib

func NewLib(miniloglevel, verbose int) (CartoLib, error)

NewLib calls viam_carto_lib_init and returns a pointer to a viam carto lib object.

func (*CartoLib) Terminate

func (vcl *CartoLib) Terminate() error

Terminate calls viam_carto_lib_terminate to clean up memory for viam carto lib.

type CartoLibInterface added in v0.3.19

type CartoLibInterface interface {
	Terminate() error
}

CartoLibInterface describes the method signatures that CartoLib must implement

type CartoLibMock added in v0.3.19

type CartoLibMock struct {
	CartoLib
	TerminateFunc func() error
}

CartoLibMock represents a fake instance of cartofacade.

func (*CartoLibMock) Terminate added in v0.3.19

func (cf *CartoLibMock) Terminate() error

Terminate calls the injected TerminateFunc or the real version.

type CartoMock added in v0.3.19

type CartoMock struct {
	Carto
	StartFunc                func() error
	StopFunc                 func() error
	TerminateFunc            func() error
	AddLidarReadingFunc      func(string, s.TimedLidarReadingResponse) error
	AddIMUReadingFunc        func(string, s.TimedIMUReadingResponse) error
	AddOdometerReadingFunc   func(string, s.TimedOdometerReadingResponse) error
	PositionFunc             func() (Position, error)
	PointCloudMapFunc        func() ([]byte, error)
	InternalStateFunc        func() ([]byte, error)
	RunFinalOptimizationFunc func() error
}

CartoMock represents a fake instance of cartofacade.

type Interface added in v0.3.22

type Interface interface {
	Initialize(
		ctx context.Context,
		timeout time.Duration,
		activeBackgroundWorkers *sync.WaitGroup,
	) (SlamMode, error)
	Start(
		ctx context.Context,
		timeout time.Duration,
	) error
	Stop(
		ctx context.Context,
		timeout time.Duration,
	) error
	Terminate(
		ctx context.Context,
		timeout time.Duration,
	) error
	AddLidarReading(
		ctx context.Context,
		timeout time.Duration,
		lidarName string,
		currentReading s.TimedLidarReadingResponse,
	) error
	AddIMUReading(
		ctx context.Context,
		timeout time.Duration,
		movementSensorName string,
		currentReading s.TimedIMUReadingResponse,
	) error
	AddOdometerReading(
		ctx context.Context,
		timeout time.Duration,
		movementSensorName string,
		currentReading s.TimedOdometerReadingResponse,
	) error
	Position(
		ctx context.Context,
		timeout time.Duration,
	) (Position, error)
	InternalState(
		ctx context.Context,
		timeout time.Duration,
	) ([]byte, error)
	PointCloudMap(
		ctx context.Context,
		timeout time.Duration,
	) ([]byte, error)
	RunFinalOptimization(
		ctx context.Context,
		timeout time.Duration,
	) error
	// contains filtered or unexported methods
}

Interface defines the functionality of a CartoFacade instance. It should not be used outside of this package but needs to be public for testing purposes.

type LidarConfig

type LidarConfig int64

LidarConfig represents the lidar configuration

const (
	// TwoD LidarConfig denotes a 2d lidar
	TwoD LidarConfig = iota
	// ThreeD LidarConfig denotes a 3d lidar
	ThreeD
)

type Mock added in v0.3.22

type Mock struct {
	CartoFacade

	InitializeFunc func(
		ctx context.Context,
		timeout time.Duration, activeBackgroundWorkers *sync.WaitGroup,
	) (SlamMode, error)
	StartFunc func(
		ctx context.Context,
		timeout time.Duration,
	) error
	StopFunc func(
		ctx context.Context,
		timeout time.Duration,
	) error
	TerminateFunc func(
		ctx context.Context,
		timeout time.Duration,
	) error
	AddLidarReadingFunc func(
		ctx context.Context,
		timeout time.Duration,
		lidarName string,
		currentReading s.TimedLidarReadingResponse,
	) error
	AddIMUReadingFunc func(
		ctx context.Context,
		timeout time.Duration,
		movementSensorName string,
		currentReading s.TimedIMUReadingResponse,
	) error
	AddOdometerReadingFunc func(
		ctx context.Context,
		timeout time.Duration,
		movementSensorName string,
		currentReading s.TimedOdometerReadingResponse,
	) error
	PositionFunc func(
		ctx context.Context,
		timeout time.Duration,
	) (Position, error)
	InternalStateFunc func(
		ctx context.Context,
		timeout time.Duration,
	) ([]byte, error)
	PointCloudMapFunc func(
		ctx context.Context,
		timeout time.Duration,
	) ([]byte, error)
	RunFinalOptimizationFunc func(
		ctx context.Context,
		timeout time.Duration,
	) error
	// contains filtered or unexported fields
}

Mock represents a fake instance of cartofacade.

func (*Mock) AddIMUReading added in v0.3.26

func (cf *Mock) AddIMUReading(
	ctx context.Context,
	timeout time.Duration,
	movementSensorName string,
	currentReading s.TimedIMUReadingResponse,
) error

AddIMUReading calls the injected AddIMUReadingFunc or the real version.

func (*Mock) AddLidarReading added in v0.3.25

func (cf *Mock) AddLidarReading(
	ctx context.Context,
	timeout time.Duration,
	lidarName string,
	currentReading s.TimedLidarReadingResponse,
) error

AddLidarReading calls the injected AddLidarReadingFunc or the real version.

func (*Mock) AddOdometerReading added in v0.3.41

func (cf *Mock) AddOdometerReading(
	ctx context.Context,
	timeout time.Duration,
	movementSensorName string,
	currentReading s.TimedOdometerReadingResponse,
) error

AddOdometerReading calls the injected AddOdometerReadingFunc or the real version.

func (*Mock) Initialize added in v0.3.22

func (cf *Mock) Initialize(
	ctx context.Context,
	timeout time.Duration,
	activeBackgroundWorkers *sync.WaitGroup,
) (SlamMode, error)

Initialize calls the injected InitializeFunc or the real version.

func (*Mock) InternalState added in v0.3.27

func (cf *Mock) InternalState(
	ctx context.Context,
	timeout time.Duration,
) ([]byte, error)

InternalState calls the injected InternalStateFunc or the real version.

func (*Mock) PointCloudMap added in v0.3.27

func (cf *Mock) PointCloudMap(
	ctx context.Context,
	timeout time.Duration,
) ([]byte, error)

PointCloudMap calls the injected PointCloudMapFunc or the real version.

func (*Mock) Position added in v0.3.27

func (cf *Mock) Position(
	ctx context.Context,
	timeout time.Duration,
) (Position, error)

Position calls the injected PositionFunc or the real version.

func (*Mock) RunFinalOptimization added in v0.3.41

func (cf *Mock) RunFinalOptimization(
	ctx context.Context,
	timeout time.Duration,
) error

RunFinalOptimization calls the injected RunFinalOptimizationFunc or the real version.

func (*Mock) Start added in v0.3.22

func (cf *Mock) Start(
	ctx context.Context,
	timeout time.Duration,
) error

Start calls the injected StartFunc or the real version.

func (*Mock) Stop added in v0.3.22

func (cf *Mock) Stop(
	ctx context.Context,
	timeout time.Duration,
) error

Stop calls the Stop StopFunc or the real version.

func (*Mock) Terminate added in v0.3.22

func (cf *Mock) Terminate(
	ctx context.Context,
	timeout time.Duration,
) error

Terminate calls the injected TerminateFunc or the real version.

type Position added in v0.3.27

type Position struct {
	X float64
	Y float64
	Z float64

	Real float64
	Imag float64
	Jmag float64
	Kmag float64

	ComponentReference string
}

Position holds values returned from c to be processed later

type Request added in v0.3.19

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

Request defines all of the necessary pieces to call into the CGo API.

type RequestInterface added in v0.3.19

type RequestInterface interface {
	// contains filtered or unexported methods
}

RequestInterface defines the functionality of a Request. It should not be used outside of this package but needs to be public for testing purposes.

type RequestMock added in v0.3.19

type RequestMock struct {
	Request
	// contains filtered or unexported fields
}

RequestMock represents a fake instance of a request.

type RequestParamType added in v0.3.19

type RequestParamType int64

RequestParamType defines the type being provided as input to the work.

type RequestType added in v0.3.19

type RequestType int64

RequestType defines the carto C API call that is being made.

type Response added in v0.3.19

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

Response defines the result of one piece of work that can be put on the result channel.

type SlamMode added in v0.3.22

type SlamMode int64

SlamMode represents the lidar configuration

const (
	// UnknownMode denotes an unknown slam mode
	UnknownMode SlamMode = iota
	// MappingMode denotes the slam algo is in mapping mode
	MappingMode
	// LocalizingMode denotes the slam algo is in localizing only mode
	LocalizingMode
	// UpdatingMode denotes the slam algo is in updating mode
	UpdatingMode
)

Jump to

Keyboard shortcuts

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