oibot

package module
v0.0.0-...-4e98350 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2019 License: MIT Imports: 6 Imported by: 1

README

oibot

A Go library for interacting with iRobot® Create® 2 robots according to the iRobot® Open Interface (OI) specification.

This library was based on the github.com/xa4a/go-roomba project which has not been updated in several years, seemingly abandoned, yet surprisingly still functional. A large portion of that library has been removed so that only essential functionality is implemented.

That project was "remotely inspired" by the pyrobot library by damonkohler@gmail.com (Damon Kohler).

I've removed the simulator and Go test harness capabilities of the previous project for the sake of simplicity, as it wasn't immediately apparent how to use them or how complete their test coverage actually was.

Serial support is implemented with github.com/tarm/serial.

Dependencies

License

This software is licensed to you under the terms of the MIT license

Usage

  • TBD!

Documentation

Index

Constants

View Source
const (
	MaxDriveVelocityMMPS   int16 = 500
	MinDriveVelocityMMPS   int16 = -500
	MaxDriveRadiusMM       int16 = 2000
	MinDriveRadiusMM       int16 = -2000
	StraightDriveRadiusMM  int16 = 0x7FFF
	DriveWheelSeparationMM int16 = 298
)
View Source
const (
	DefaultBaudRateBPS    int           = 115200
	SerialTransferDelayMS time.Duration = 50 * time.Millisecond
	SensorUpdateDelayMS   time.Duration = 15 * time.Millisecond // from OI spec
	DefaultReadTimeoutMS  time.Duration = 500 * time.Millisecond
	NeverReadTimeoutMS    time.Duration = 0
)
View Source
const (
	AngleRuneWeightMax = byte(4)
	AngleRuneUnknown   = '⮔'
)
View Source
const (
	BootupTimeMS time.Duration = 5000 * time.Millisecond
)

Variables

This section is empty.

Functions

func OIModeStr

func OIModeStr(mode OpenInterfaceMode) (string, bool)

Types

type BatteryStatus

type BatteryStatus struct {
	ChargingState      byte
	VoltagemV          uint16
	CurrentmA          int16
	BatteryChargemAh   uint16
	BatteryCapacitymAh uint16
	ChargerAvailable   byte
}

type BaudRateCode

type BaudRateCode byte

=====================================================================================================================

type ChargingStateCode

type ChargingStateCode byte

=====================================================================================================================

type Direction

type Direction uint

=====================================================================================================================

const (
	DirStop Direction = iota
	DirLeft
	DirLeftFwd
	DirFwd
	DirRightFwd
	DirRight
	DirRightAft
	DirAft
	DirLeftAft
)

func AngleRune

func AngleRune(angle int16, weight byte) (rune, Direction)

type InfoStatus

type InfoStatus struct {
	Mode    OpenInterfaceMode
	Battery *BatteryStatus
}

type OIBot

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

func MakeOIBot

func MakeOIBot(infoLog *log.Logger, errorLog *log.Logger, init bool, path string, baud int, rtime time.Duration) *OIBot

func (*OIBot) Battery

func (o *OIBot) Battery() (*BatteryStatus, bool)

func (*OIBot) Baud

func (o *OIBot) Baud(baud int)

func (*OIBot) Clean

func (o *OIBot) Clean()

func (*OIBot) Close

func (o *OIBot) Close()

func (*OIBot) Control

func (o *OIBot) Control()

func (*OIBot) Drive

func (o *OIBot) Drive(velocity int16, radius int16)

func (*OIBot) DriveStop

func (o *OIBot) DriveStop()

func (*OIBot) DriveWheels

func (o *OIBot) DriveWheels(rightVelocity int16, leftVelocity int16)

func (*OIBot) Flush

func (o *OIBot) Flush()

func (*OIBot) Full

func (o *OIBot) Full()

func (*OIBot) Info

func (o *OIBot) Info() (*InfoStatus, bool)

func (*OIBot) MaxClean

func (o *OIBot) MaxClean()

func (*OIBot) Mode

func (o *OIBot) Mode() OpenInterfaceMode

func (*OIBot) Pack

func (o *OIBot) Pack(data ...interface{}) []byte

func (*OIBot) Passive

func (o *OIBot) Passive()

func (*OIBot) Power

func (o *OIBot) Power()

func (*OIBot) Read

func (o *OIBot) Read(buf []byte) int

func (*OIBot) Reset

func (o *OIBot) Reset()

func (*OIBot) Safe

func (o *OIBot) Safe()

func (*OIBot) SeekDock

func (o *OIBot) SeekDock()

func (*OIBot) Sensor

func (o *OIBot) Sensor(packet *SensorPacket) []byte

func (*OIBot) SensorList

func (o *OIBot) SensorList(packet ...*SensorPacket) [][]byte

func (*OIBot) Spot

func (o *OIBot) Spot()

func (*OIBot) Start

func (o *OIBot) Start()

func (*OIBot) Stop

func (o *OIBot) Stop()

func (*OIBot) Write

func (o *OIBot) Write(code OpCode, buf ...interface{}) int

func (*OIBot) WriteCode

func (o *OIBot) WriteCode(code OpCode)

type OpCode

type OpCode byte

=====================================================================================================================

type OpenInterfaceMode

type OpenInterfaceMode byte

=====================================================================================================================

const (
	OIMOff     OpenInterfaceMode = 0
	OIMPassive OpenInterfaceMode = 1
	OIMSafe    OpenInterfaceMode = 2
	OIMFull    OpenInterfaceMode = 3
)

type SensorGroup

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

=====================================================================================================================

type SensorPacket

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

=====================================================================================================================

Jump to

Keyboard shortcuts

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