ros

package
v0.0.0-...-5ec6080 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2022 License: Apache-2.0 Imports: 29 Imported by: 0

README

actionlib [WIP]

Package Summary

A pure go implementation for ROS action library built on top of ROSGO. This package is unstable and the API can change in future.

Prerequisites

This library uses messages GoalID, GoalStatus and GoalStatusArray from actionlib_msgs package. Please generate Go code for the messages in actionlib_msgs package and place them in your $GOPATH/src.

Use the following commands after install gengo.

gengo -out=$GOPATH/src msg actionlib_msgs/GoalID
gengo -out=$GOPATH/src msg actionlib_msgs/GoalStatus
gengo -out=$GOPATH/src msg actionlib_msgs/GoalStatusArray

Status

This package implements all the features of actionlib library but is still very unstable and is still a work in progress to fix known issues and make this packge more robust. Following are the features that are implemented and what's to be added in the future.

Implemented
  • Action Client
  • Action Server
  • Simple Action Client
  • Simple Action Server
  • Client Goal Handler
  • Server Goal Handler
  • Go code generation from action definitons
To Be Added
  • Tests
  • Documentation
  • Fix for golint issues
  • Go mod

How To Use

Examples of client and server usage can be found in rosgo/test folder.

Documentation

Index

Constants

View Source
const (
	//Sep is a namespace separator string
	Sep = "/"
	//GlobalNS is the global namespace initial separator string
	GlobalNS = "/"
	//PrivateNS is private namespace initial separator string
	PrivateNS = "~"
)
View Source
const (
	//APIStatusError is an API call which returned an Error
	APIStatusError = -1
	//APIStatusFailure is a failed API call
	APIStatusFailure = 0
	//APIStatusSuccess is a successful API call
	APIStatusSuccess = 1
	//Remap string constant for splitting components
	Remap = ":="
)
View Source
const (
	SimpleStatePending uint8 = 0
	SimpleStateActive  uint8 = 1
	SimpleStateDone    uint8 = 2
)

Variables

This section is empty.

Functions

func CheckSize

func CheckSize(buf *bytes.Reader, size int) error

func GetRuntimePackagePath

func GetRuntimePackagePath() string

GetRuntimePackagePath returns the ROS package search path which will be used by DynamicMessage to look up ROS message definitions at runtime. By default, this will be equivalent to the ${ROS_PACKAGE_PATH} environment variable.

func PingMasterURI

func PingMasterURI(calleeURI string) bool

PingMasterURI is intended to return true if a dial to the ros master URI returns successfully

func ResetContext

func ResetContext()

ResetContext resets the package path context so that a new one will be generated

func SetRuntimePackagePath

func SetRuntimePackagePath(path string)

SetRuntimePackagePath sets the ROS package search path which will be used by DynamicMessage to look up ROS message definitions at runtime.

Types

type Action

type Action interface {
	GetActionGoal() ActionGoal
	GetActionFeedback() ActionFeedback
	GetActionResult() ActionResult
}

type ActionClient

type ActionClient interface {
	WaitForServer(timeout Duration) bool
	SendGoal(goal Message, transitionCallback interface{}, feedbackCallback interface{}, goalID string) (ClientGoalHandler, error)
	CancelAllGoals()
	CancelAllGoalsBeforeTime(stamp Time)
}

func NewActionClient

func NewActionClient(node Node, action string, actionType ActionType) (ActionClient, error)

type ActionFeedback

type ActionFeedback interface {
	Message
	GetHeader() Message
	GetStatus() ActionStatus
	GetFeedback() Message
	SetHeader(Message)
	SetStatus(ActionStatus)
	SetFeedback(Message)
}

* ActionFeedback interface

type ActionFeedbackType

type ActionFeedbackType interface {
	MessageType
	NewFeedbackMessage() ActionFeedback
}

type ActionGoal

type ActionGoal interface {
	Message
	GetHeader() (Message, error)
	GetGoalId() (ActionGoalID, error)
	GetGoal() (Message, error)
	SetHeader(Message)
	SetGoalId(ActionGoalID)
	SetGoal(Message)
}

type ActionGoalID

type ActionGoalID interface {
	Message
	GetID() string
	SetID(string)
	GetStamp() Time
	SetStamp(Time)
}

type ActionGoalIDType

type ActionGoalIDType interface {
	MessageType
	NewGoalIDMessage() ActionGoalID
}

func NewActionGoalIDType

func NewActionGoalIDType() ActionGoalIDType

DynamicActionGoalID Type and New Message instantiators

type ActionGoalType

type ActionGoalType interface {
	MessageType
	NewGoalMessage() ActionGoal
}

type ActionHeader

type ActionHeader interface {
	Message
	GetStamp() Time
	SetStamp(Time)
	GetFrameID() string
	SetFrameID(string)
}

*** Shared ActionHeader interface

type ActionResult

type ActionResult interface {
	Message
	GetHeader() Message
	GetStatus() ActionStatus
	GetResult() Message
	SetHeader(Message)
	SetStatus(ActionStatus)
	SetResult(Message)
}

* ActionResult interface

type ActionResultType

type ActionResultType interface {
	MessageType
	NewResultMessage() ActionResult
}

type ActionServer

type ActionServer interface {
	Start()
	Shutdown()
	PublishResult(status ActionStatus, result Message)
	PublishFeedback(status ActionStatus, feedback Message)
	PublishStatus()
	RegisterGoalCallback(interface{})
	RegisterCancelCallback(interface{})
}

func NewActionServer

func NewActionServer(node Node, action string, actionType ActionType, goalCb, cancelCb interface{}, autoStart bool) ActionServer

type ActionStatus

type ActionStatus interface {
	Message
	GetGoalID() ActionGoalID
	SetGoalID(ActionGoalID)
	GetStatus() uint8
	SetStatus(uint8)
	GetStatusText() string
	SetStatusText(string)
}

*** Shared ActionStatus interface

type ActionStatusArray

type ActionStatusArray interface {
	Message
	GetHeader() Message
	SetHeader(Message)
	GetStatusArray() []ActionStatus
	SetStatusArray([]ActionStatus)
}

*** Shared ActionStatusArray interface

type ActionStatusArrayType

type ActionStatusArrayType interface {
	MessageType
	NewStatusArrayMessage() ActionStatusArray
}

func NewActionStatusArrayType

func NewActionStatusArrayType() ActionStatusArrayType

DynamicActionStatusArray Type and New Message instantiators

type ActionStatusType

type ActionStatusType interface {
	MessageType
	NewStatusMessage() ActionStatus
}

func NewActionStatusType

func NewActionStatusType() ActionStatusType

DynamicActionStatus Type and New Message instantiators

type ActionType

type ActionType interface {
	MD5Sum() string
	Name() string
	GoalType() ActionGoalType
	FeedbackType() ActionFeedbackType
	ResultType() ActionResultType
	NewAction() Action
}

type ByteDecoder

type ByteDecoder interface {
	DecodeBoolArray(buf *bytes.Reader, size int) ([]bool, error)
	DecodeInt8Array(buf *bytes.Reader, size int) ([]int8, error)
	DecodeInt16Array(buf *bytes.Reader, size int) ([]int16, error)
	DecodeInt32Array(buf *bytes.Reader, size int) ([]int32, error)
	DecodeInt64Array(buf *bytes.Reader, size int) ([]int64, error)
	DecodeUint8Array(buf *bytes.Reader, size int) ([]uint8, error)
	DecodeUint16Array(buf *bytes.Reader, size int) ([]uint16, error)
	DecodeUint32Array(buf *bytes.Reader, size int) ([]uint32, error)
	DecodeUint64Array(buf *bytes.Reader, size int) ([]uint64, error)
	DecodeFloat32Array(buf *bytes.Reader, size int) ([]JsonFloat32, error)
	DecodeFloat64Array(buf *bytes.Reader, size int) ([]JsonFloat64, error)
	DecodeStringArray(buf *bytes.Reader, size int) ([]string, error)
	DecodeTimeArray(buf *bytes.Reader, size int) ([]Time, error)
	DecodeDurationArray(buf *bytes.Reader, size int) ([]Duration, error)
	DecodeMessageArray(buf *bytes.Reader, size int, msgType *DynamicMessageType) ([]Message, error)

	DecodeBool(buf *bytes.Reader) (bool, error)
	DecodeInt8(buf *bytes.Reader) (int8, error)
	DecodeInt16(buf *bytes.Reader) (int16, error)
	DecodeInt32(buf *bytes.Reader) (int32, error)
	DecodeInt64(buf *bytes.Reader) (int64, error)
	DecodeUint8(buf *bytes.Reader) (uint8, error)
	DecodeUint16(buf *bytes.Reader) (uint16, error)
	DecodeUint32(buf *bytes.Reader) (uint32, error)
	DecodeUint64(buf *bytes.Reader) (uint64, error)
	DecodeFloat32(buf *bytes.Reader) (JsonFloat32, error)
	DecodeFloat64(buf *bytes.Reader) (JsonFloat64, error)
	DecodeString(buf *bytes.Reader) (string, error)
	DecodeTime(buf *bytes.Reader) (Time, error)
	DecodeDuration(buf *bytes.Reader) (Duration, error)
	DecodeMessage(buf *bytes.Reader, msgType *DynamicMessageType) (Message, error)
}

ByteDecoder provides an interface that dynamic message deserialization expects for decoding ROS messages.

type ClientGoalHandler

type ClientGoalHandler interface {
	IsExpired() bool
	GetCommState() (CommState, error)
	GetGoalStatus() (uint8, error)
	GetGoalStatusText() (string, error)
	GetTerminalState() (uint8, error)
	GetResult() (Message, error)
	Resend() error
	Cancel() error
}

type CommState

type CommState uint8
const (
	WaitingForGoalAck CommState = iota
	Pending
	Active
	WaitingForResult
	WaitingForCancelAck
	Recalling
	Preempting
	Done
	Lost
)

func (CommState) String

func (cs CommState) String() string

type Duration

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

Duration type which is a wrapper for a temporal value of {sec,nsec}

func NewDuration

func NewDuration(sec uint32, nsec uint32) Duration

NewDuration instantiates a new Duration item with given sec and nsec integers

func (*Duration) Add

func (d *Duration) Add(other Duration) Duration

Add function for adding two durations together

func (*Duration) Cmp

func (d *Duration) Cmp(other Duration) int

Cmp function to compare two durations

func (*Duration) FromNSec

func (t *Duration) FromNSec(nsec uint64)

func (*Duration) FromSec

func (t *Duration) FromSec(sec float64)

func (*Duration) IsZero

func (t *Duration) IsZero() bool

func (*Duration) Normalize

func (t *Duration) Normalize()

func (*Duration) Sleep

func (d *Duration) Sleep() error

Sleep function pauses go routine for duration d

func (*Duration) Sub

func (d *Duration) Sub(other Duration) Duration

Sub function for subtracting a duration from another

func (*Duration) ToNSec

func (t *Duration) ToNSec() uint64

func (*Duration) ToSec

func (t *Duration) ToSec() float64

type DynamicAction

type DynamicAction struct {
	Goal     ActionGoal
	Feedback ActionFeedback
	Result   ActionResult
	// contains filtered or unexported fields
}

DynamicAction abstracts an instance of a ROS Action whose type is only known at runtime. The schema of the action is denoted by the referenced DynamicActionType, while the Goal, Feedback and Result references the rosgo Messages it implements. DynamicAction implements the rosgo actionlib.Action interface, allowing it to be used throughout rosgo in the same manner as action types generated at compiletime by gengo.

func (*DynamicAction) GetActionFeedback

func (a *DynamicAction) GetActionFeedback() ActionFeedback

GetActionFeedback returns the actionlib.ActionFeedback of the DynamicAction; required for actionlib.Action.

func (*DynamicAction) GetActionGoal

func (a *DynamicAction) GetActionGoal() ActionGoal

GetActionGoal returns the actionlib.ActionGoal of the DynamicAction; required for actionlib.Action.

func (*DynamicAction) GetActionResult

func (a *DynamicAction) GetActionResult() ActionResult

GetActionResult returns the actionlib.ActionResult of the DynamicAction; required for actionlib.Action.

type DynamicActionFeedback

type DynamicActionFeedback struct{ DynamicMessage }

func (*DynamicActionFeedback) GetFeedback

func (m *DynamicActionFeedback) GetFeedback() Message

func (*DynamicActionFeedback) GetHeader

func (m *DynamicActionFeedback) GetHeader() Message

func (*DynamicActionFeedback) GetStatus

func (m *DynamicActionFeedback) GetStatus() ActionStatus

func (*DynamicActionFeedback) SetFeedback

func (m *DynamicActionFeedback) SetFeedback(goal Message)

Dynamic Action Feedback Interface Get and set functions of DynamicActionFeedback interface

func (*DynamicActionFeedback) SetHeader

func (m *DynamicActionFeedback) SetHeader(header Message)

func (*DynamicActionFeedback) SetStatus

func (m *DynamicActionFeedback) SetStatus(status ActionStatus)

type DynamicActionFeedbackType

type DynamicActionFeedbackType struct{ DynamicMessageType }

func (*DynamicActionFeedbackType) NewFeedbackMessage

func (a *DynamicActionFeedbackType) NewFeedbackMessage() ActionFeedback

Create a new Feedback message from DynamicActionFeedbackType

func (*DynamicActionFeedbackType) NewFeedbackMessageFromInterface

func (a *DynamicActionFeedbackType) NewFeedbackMessageFromInterface(feedback interface{}) ActionFeedback

NewFeedbackMessageFromInterface creates an ActionFeedback provided an interface. Used where serialization/deserialization removes traces of action interface types from a message

type DynamicActionGoal

type DynamicActionGoal struct{ DynamicMessage }

DynamicAction* interfaces.

func (*DynamicActionGoal) GetGoal

func (m *DynamicActionGoal) GetGoal() (Message, error)

func (*DynamicActionGoal) GetGoalId

func (m *DynamicActionGoal) GetGoalId() (ActionGoalID, error)

func (*DynamicActionGoal) GetHeader

func (m *DynamicActionGoal) GetHeader() (Message, error)

func (*DynamicActionGoal) SetGoal

func (m *DynamicActionGoal) SetGoal(goal Message)

Dynamic Action Goal Interface Get and set functions of DynamicActionGoal interface

func (*DynamicActionGoal) SetGoalId

func (m *DynamicActionGoal) SetGoalId(goalid ActionGoalID)

func (*DynamicActionGoal) SetHeader

func (m *DynamicActionGoal) SetHeader(header Message)

type DynamicActionGoalID

type DynamicActionGoalID struct{ DynamicMessage }

DynamicAction** shared interfaces.

func (*DynamicActionGoalID) GetID

func (m *DynamicActionGoalID) GetID() string

Get and Set Functions of DynamicActionGoalID

func (*DynamicActionGoalID) GetStamp

func (m *DynamicActionGoalID) GetStamp() Time

func (*DynamicActionGoalID) SetID

func (m *DynamicActionGoalID) SetID(id string)

func (*DynamicActionGoalID) SetStamp

func (m *DynamicActionGoalID) SetStamp(stamp Time)

type DynamicActionGoalIDType

type DynamicActionGoalIDType struct{ DynamicMessageType }

DynamicActionType** shared type interfaces

func (*DynamicActionGoalIDType) NewGoalIDMessage

func (a *DynamicActionGoalIDType) NewGoalIDMessage() ActionGoalID

func (*DynamicActionGoalIDType) NewGoalIDMessageFromInterface

func (a *DynamicActionGoalIDType) NewGoalIDMessageFromInterface(goalID interface{}) ActionGoalID

NewGoalIDMessageFromInterface create an ActionGoalID provided an interface Used where serialization/deserialization removes traces of action interface types from a message

type DynamicActionGoalType

type DynamicActionGoalType struct{ DynamicMessageType }

DynamicActionType* type interfaces

func (*DynamicActionGoalType) NewGoalMessage

func (a *DynamicActionGoalType) NewGoalMessage() ActionGoal

Instnatiators for main Action message types. These functions copy dynamic messages into the dynamic action message type. Create a new Goal message from DynamicActionGoalType

func (*DynamicActionGoalType) NewGoalMessageFromInterface

func (a *DynamicActionGoalType) NewGoalMessageFromInterface(goal interface{}) ActionGoal

NewGoalMessageFromInterface creates an ActionGoal provided an interface. Used where serialization/deserialization removes traces of action interface types from a message

type DynamicActionResult

type DynamicActionResult struct{ DynamicMessage }

func (*DynamicActionResult) GetHeader

func (m *DynamicActionResult) GetHeader() Message

func (*DynamicActionResult) GetResult

func (m *DynamicActionResult) GetResult() Message

func (*DynamicActionResult) GetStatus

func (m *DynamicActionResult) GetStatus() ActionStatus

func (*DynamicActionResult) SetHeader

func (m *DynamicActionResult) SetHeader(header Message)

func (*DynamicActionResult) SetResult

func (m *DynamicActionResult) SetResult(result Message)

Dynamic Action Feedback Interface Get and set functions of DynamicActionFeedback interface

func (*DynamicActionResult) SetStatus

func (m *DynamicActionResult) SetStatus(status ActionStatus)

type DynamicActionResultType

type DynamicActionResultType struct{ DynamicMessageType }

func (*DynamicActionResultType) NewResultMessage

func (a *DynamicActionResultType) NewResultMessage() ActionResult

Create a new Result message from DynamicActionResultType

func (*DynamicActionResultType) NewResultMessageFromInterface

func (a *DynamicActionResultType) NewResultMessageFromInterface(result interface{}) ActionResult

NewResultMessageFromInterface creates an ActionResult provided an interface. Used where serialization/deserialization removes traces of action interface types from a message

type DynamicActionStatus

type DynamicActionStatus struct{ DynamicMessage }

func (*DynamicActionStatus) GetGoalID

func (m *DynamicActionStatus) GetGoalID() ActionGoalID

Get and Set Functions of shared type DynamicActionStatus

func (*DynamicActionStatus) GetStatus

func (m *DynamicActionStatus) GetStatus() uint8

func (*DynamicActionStatus) GetStatusText

func (m *DynamicActionStatus) GetStatusText() string

func (*DynamicActionStatus) SetGoalID

func (m *DynamicActionStatus) SetGoalID(id ActionGoalID)

func (*DynamicActionStatus) SetStatus

func (m *DynamicActionStatus) SetStatus(status uint8)

func (*DynamicActionStatus) SetStatusText

func (m *DynamicActionStatus) SetStatusText(text string)

type DynamicActionStatusArray

type DynamicActionStatusArray struct{ DynamicMessage }

func (*DynamicActionStatusArray) GetHeader

func (m *DynamicActionStatusArray) GetHeader() Message

func (*DynamicActionStatusArray) GetStatusArray

func (m *DynamicActionStatusArray) GetStatusArray() []ActionStatus

Get and set functions of the shared type DynamicActionStatusArray

func (*DynamicActionStatusArray) SetHeader

func (m *DynamicActionStatusArray) SetHeader(header Message)

func (*DynamicActionStatusArray) SetStatusArray

func (m *DynamicActionStatusArray) SetStatusArray(statusArray []ActionStatus)

type DynamicActionStatusArrayType

type DynamicActionStatusArrayType struct{ DynamicMessageType }

func (*DynamicActionStatusArrayType) NewStatusArrayFromInterface

func (a *DynamicActionStatusArrayType) NewStatusArrayFromInterface(statusArr interface{}) ActionStatusArray

NewStatusArrayFromInterface creates an ActionStatusArray provided an interface. Used where serialization/deserialization removes traces of action interface types from a message

func (*DynamicActionStatusArrayType) NewStatusArrayMessage

func (a *DynamicActionStatusArrayType) NewStatusArrayMessage() ActionStatusArray

type DynamicActionStatusType

type DynamicActionStatusType struct{ DynamicMessageType }

func (*DynamicActionStatusType) NewStatusMessage

func (a *DynamicActionStatusType) NewStatusMessage() ActionStatus

type DynamicActionType

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

DynamicActionType abstracts the schema of a ROS Action whose schema is only known at runtime. DynamicActionType implements the rosgo actionlib.ActionType interface, allowing it to be used throughout rosgo in the same manner as action schemas generated at compiletime by gengo.

func NewDynamicActionType

func NewDynamicActionType(typeName string) (*DynamicActionType, error)

NewDynamicActionType generates a DynamicActionType corresponding to the specified typeName from the available ROS action definitions; typeName should be a fully-qualified ROS action type name. The first time the function is run, a message/service/action 'context' is created by searching through the available ROS definitions, then the ROS action to be used for the definition is looked up by name. On subsequent calls, the ROS action type is looked up directly from the existing context.

func (*DynamicActionType) FeedbackType

func (t *DynamicActionType) FeedbackType() ActionFeedbackType

FeedbackType returns the full ROS MessageType of the action feedbackType; required for actionlib.ActionType.

func (*DynamicActionType) GoalType

func (t *DynamicActionType) GoalType() ActionGoalType

GoalType returns the full ROS MessageType of the action goalType; required for actionlib.ActionType.

func (*DynamicActionType) MD5Sum

func (t *DynamicActionType) MD5Sum() string

MD5Sum returns the ROS compatible MD5 sum of the action type; required for actionlib.ActionType.

func (*DynamicActionType) Name

func (t *DynamicActionType) Name() string

Name returns the full ROS name of the action type; required for actionlib.ActionType.

func (*DynamicActionType) NewAction

func (t *DynamicActionType) NewAction() Action

NewAction creates a new DynamicAction instantiating the action type; required for actionlib.ActionType.

func (*DynamicActionType) ResultType

func (t *DynamicActionType) ResultType() ActionResultType

ResultType returns the full ROS MessageType of the action resultType; required for actionlib.ActionType.

func (*DynamicActionType) Text

func (t *DynamicActionType) Text() string

Text returns the full ROS text of the action type; required for actionlib.ActionType.

type DynamicMessage

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

DynamicMessage abstracts an instance of a ROS Message whose type is only known at runtime. The schema of the message is denoted by the referenced DynamicMessageType, while the actual payload of the Message is stored in a map[string]interface{} which maps the name of each field to its value. DynamicMessage implements the rosgo Message interface, allowing it to be used throughout rosgo in the same manner as message types generated at compiletime by gengo.

func (*DynamicMessage) Data

func (m *DynamicMessage) Data() map[string]interface{}

Data returns the data map field of the DynamicMessage

func (*DynamicMessage) Deserialize

func (m *DynamicMessage) Deserialize(buf *bytes.Reader) error

Deserialize parses a byte stream into a DynamicMessage, thus reconstructing the fields of a received ROS message; required for ros.Message.

func (*DynamicMessage) GetDynamicType

func (m *DynamicMessage) GetDynamicType() *DynamicMessageType

GetDynamicType returns the DynamicMessageType of a DynamicMessage

func (*DynamicMessage) MarshalJSON

func (m *DynamicMessage) MarshalJSON() ([]byte, error)

MarshalJSON provides a custom implementation of JSON marshalling, only the message payload is represented in compact form. Verification provided in dynamic_message_json_test.go. The marshalled JSON must match the schema generated by GenerateJSONSchema().

func (*DynamicMessage) Serialize

func (m *DynamicMessage) Serialize(buf *bytes.Buffer) error

Serialize converts a DynamicMessage into a TCPROS bytestream allowing it to be published to other nodes; required for ros.Message.

func (*DynamicMessage) String

func (m *DynamicMessage) String() string

String returns a string which represents the encapsulared DynamicMessage data.

func (*DynamicMessage) Type

func (m *DynamicMessage) Type() MessageType

Type returns the ROS type of a dynamic message; required for ros.Message.

func (*DynamicMessage) UnmarshalJSON

func (m *DynamicMessage) UnmarshalJSON(buf []byte) (err error)

UnmarshalJSON provides a custom implementation of JSON unmarshalling. Verification provided in dynamic_message_json_test.go.

type DynamicMessageType

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

DynamicMessageType abstracts the schema of a ROS Message whose schema is only known at runtime. DynamicMessageTypes are created by looking up the relevant schema information from ROS Message definition files. DynamicMessageType implements the rosgo MessageType interface, allowing it to be used throughout rosgo in the same manner as message schemas generated at compiletime by gengo.

func NewDynamicMessageType

func NewDynamicMessageType(typeName string) (*DynamicMessageType, error)

NewDynamicMessageType generates a DynamicMessageType corresponding to the specified typeName from the available ROS message definitions; typeName should be a fully-qualified ROS message type name. The first time the function is run, a message 'context' is created by searching through the available ROS message definitions, then the ROS message to be used for the definition is looked up by name. On subsequent calls, the ROS message type is looked up directly from the existing context.

func NewDynamicMessageTypeFromSpec

func NewDynamicMessageTypeFromSpec(spec *libgengo.MsgSpec) (*DynamicMessageType, error)

NewDynamicMessageTypeFromSpec creates a DynamicMessageType using a preloaded message specification. When loading a service or action, multiple message specs are loaded at once, so `NewDynamicMessageType` is not applicable.

func NewDynamicMessageTypeLiteral

func NewDynamicMessageTypeLiteral(typeName string) (DynamicMessageType, error)

NewDynamicMessageTypeLiteral generates a DynamicMessageType, and returns a copy of the generated type. This is required by DynamicAction.

func (*DynamicMessageType) GenerateJSONSchema

func (t *DynamicMessageType) GenerateJSONSchema(prefix string, topic string) ([]byte, error)

GenerateJSONSchema generates a (primitive) JSON schema for the associated DynamicMessageType; however note that since we are mostly interested in making schema's for particular _topics_, the function takes a string prefix, and string topic name, which are used to id the resulting schema.

func (*DynamicMessageType) MD5Sum

func (t *DynamicMessageType) MD5Sum() string

MD5Sum returns the ROS compatible MD5 sum of the message type; required for ros.MessageType.

func (*DynamicMessageType) Name

func (t *DynamicMessageType) Name() string

Name returns the full ROS name of the message type; required for ros.MessageType.

func (*DynamicMessageType) NewDynamicMessage

func (t *DynamicMessageType) NewDynamicMessage() *DynamicMessage

NewDynamicMessage constructs a DynamicMessage with zeroed fields.

func (*DynamicMessageType) NewMessage

func (t *DynamicMessageType) NewMessage() Message

NewMessage creates a new DynamicMessage instantiating the message type; required for ros.MessageType.

func (*DynamicMessageType) Text

func (t *DynamicMessageType) Text() string

Text returns the full ROS message specification for this message type; required for ros.MessageType.

type DynamicService

type DynamicService struct {
	Request  Message
	Response Message
	// contains filtered or unexported fields
}

DynamicService abstracts an instance of a ROS Service whose type is only known at runtime. The schema of the message is denoted by the referenced DynamicServiceType, while the Request and Response references the rosgo Messages it implements. DynamicService implements the rosgo Service interface, allowing it to be used throughout rosgo in the same manner as service types generated at compiletime by gengo.

func (*DynamicService) ReqMessage

func (s *DynamicService) ReqMessage() Message

ReqMessage returns the request message of the DynamicService; required for ros.Service.

func (*DynamicService) ResMessage

func (s *DynamicService) ResMessage() Message

ResMessage returns the response message of the DynamicService; required for ros.Service.

func (*DynamicService) Type

func (s *DynamicService) Type() ServiceType

Type returns the ROS type of a dynamic service; not required for ros.Service.

type DynamicServiceType

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

DynamicServiceType abstracts the schema of a ROS Service whose schema is only known at runtime. DynamicServiceType implements the rosgo ServiceType interface, allowing it to be used throughout rosgo in the same manner as service schemas generated at compiletime by gengo.

func NewDynamicServiceType

func NewDynamicServiceType(typeName string) (*DynamicServiceType, error)

NewDynamicServiceType generates a DynamicServiceType corresponding to the specified typeName from the available ROS service definitions; typeName should be a fully-qualified ROS service type name. The first time the function is run, a message/service/action 'context' is created by searching through the available ROS definitions, then the ROS service to be used for the definition is looked up by name. On subsequent calls, the ROS service type is looked up directly from the existing context.

func (*DynamicServiceType) MD5Sum

func (t *DynamicServiceType) MD5Sum() string

MD5Sum returns the ROS compatible MD5 sum of the service type; required for ros.ServiceType.

func (*DynamicServiceType) Name

func (t *DynamicServiceType) Name() string

Name returns the full ROS name of the service type; required for ros.ServiceType.

func (*DynamicServiceType) NewService

func (t *DynamicServiceType) NewService() Service

NewService creates a new DynamicService instantiating the service type; required for ros.ServiceType.

func (*DynamicServiceType) RequestType

func (t *DynamicServiceType) RequestType() MessageType

RequestType returns the MessageType of the request message of DynamicServiceType; required for ros.ServiceType.

func (*DynamicServiceType) ResponseType

func (t *DynamicServiceType) ResponseType() MessageType

ResponseType returns the MessageType of the response message of DynamicServiceType; required for ros.ServiceType.

func (*DynamicServiceType) Text

func (t *DynamicServiceType) Text() string

Name returns the full ROS text of the service type; required for ros.ServiceType.

type Event

type Event uint8
const (
	CancelRequest Event = iota + 1
	Cancel
	Reject
	Accept
	Succeed
	Abort
)

func (Event) String

func (e Event) String() string

type JsonFloat32

type JsonFloat32 struct {
	F float32
}

func (JsonFloat32) MarshalJSON

func (f JsonFloat32) MarshalJSON() ([]byte, error)

func (JsonFloat32) String

func (f JsonFloat32) String() string

type JsonFloat64

type JsonFloat64 struct {
	F float64
}

func (JsonFloat64) MarshalJSON

func (f JsonFloat64) MarshalJSON() ([]byte, error)

func (JsonFloat64) String

func (f JsonFloat64) String() string

type LEByteDecoder

type LEByteDecoder struct{}

LEByteDecoder is a little-endian byte decoder, implements the ByteDecoder interface.

func (LEByteDecoder) DecodeBool

func (d LEByteDecoder) DecodeBool(buf *bytes.Reader) (bool, error)

DecodeBool decodes a boolean.

func (LEByteDecoder) DecodeBoolArray

func (d LEByteDecoder) DecodeBoolArray(buf *bytes.Reader, size int) ([]bool, error)

DecodeBoolArray decodes an array of boolean values.

func (LEByteDecoder) DecodeDuration

func (d LEByteDecoder) DecodeDuration(buf *bytes.Reader) (Duration, error)

DecodeDuration decodes a Duraction struct.

func (LEByteDecoder) DecodeDurationArray

func (d LEByteDecoder) DecodeDurationArray(buf *bytes.Reader, size int) ([]Duration, error)

DecodeDurationArray decodes an array of Duration structs.

func (LEByteDecoder) DecodeFloat32

func (d LEByteDecoder) DecodeFloat32(buf *bytes.Reader) (JsonFloat32, error)

DecodeFloat32 decodes a JsonFloat32.

func (LEByteDecoder) DecodeFloat32Array

func (d LEByteDecoder) DecodeFloat32Array(buf *bytes.Reader, size int) ([]JsonFloat32, error)

DecodeFloat32Array decodes an array of float32 values.

func (LEByteDecoder) DecodeFloat64

func (d LEByteDecoder) DecodeFloat64(buf *bytes.Reader) (JsonFloat64, error)

DecodeFloat64 decodes a JsonFloat64.

func (LEByteDecoder) DecodeFloat64Array

func (d LEByteDecoder) DecodeFloat64Array(buf *bytes.Reader, size int) ([]JsonFloat64, error)

DecodeFloat64Array decodes an array of float64 values.

func (LEByteDecoder) DecodeInt16

func (d LEByteDecoder) DecodeInt16(buf *bytes.Reader) (int16, error)

DecodeInt16 decodes a int16.

func (LEByteDecoder) DecodeInt16Array

func (d LEByteDecoder) DecodeInt16Array(buf *bytes.Reader, size int) ([]int16, error)

DecodeInt16Array decodes an array of int16 values.

func (LEByteDecoder) DecodeInt32

func (d LEByteDecoder) DecodeInt32(buf *bytes.Reader) (int32, error)

DecodeInt32 decodes a int32.

func (LEByteDecoder) DecodeInt32Array

func (d LEByteDecoder) DecodeInt32Array(buf *bytes.Reader, size int) ([]int32, error)

DecodeInt32Array decodes an array of int32 values.

func (LEByteDecoder) DecodeInt64

func (d LEByteDecoder) DecodeInt64(buf *bytes.Reader) (int64, error)

DecodeInt64 decodes a int64.

func (LEByteDecoder) DecodeInt64Array

func (d LEByteDecoder) DecodeInt64Array(buf *bytes.Reader, size int) ([]int64, error)

DecodeInt64Array decodes an array of int64 values.

func (LEByteDecoder) DecodeInt8

func (d LEByteDecoder) DecodeInt8(buf *bytes.Reader) (int8, error)

DecodeInt8 decodes a int8.

func (LEByteDecoder) DecodeInt8Array

func (d LEByteDecoder) DecodeInt8Array(buf *bytes.Reader, size int) ([]int8, error)

DecodeInt8Array decodes an array of int8 values.

func (LEByteDecoder) DecodeMessage

func (d LEByteDecoder) DecodeMessage(buf *bytes.Reader, msgType *DynamicMessageType) (Message, error)

DecodeMessage decodes a DynamicMessage.

func (LEByteDecoder) DecodeMessageArray

func (d LEByteDecoder) DecodeMessageArray(buf *bytes.Reader, size int, msgType *DynamicMessageType) ([]Message, error)

DecodeMessageArray decodes an array of DynamicMessages.

func (LEByteDecoder) DecodeString

func (d LEByteDecoder) DecodeString(buf *bytes.Reader) (string, error)

DecodeString decodes a string.

func (LEByteDecoder) DecodeStringArray

func (d LEByteDecoder) DecodeStringArray(buf *bytes.Reader, size int) ([]string, error)

DecodeStringArray decodes an array of strings.

func (LEByteDecoder) DecodeTime

func (d LEByteDecoder) DecodeTime(buf *bytes.Reader) (Time, error)

DecodeTime decodes a Time struct.

func (LEByteDecoder) DecodeTimeArray

func (d LEByteDecoder) DecodeTimeArray(buf *bytes.Reader, size int) ([]Time, error)

DecodeTimeArray decodes an array of Time structs.

func (LEByteDecoder) DecodeUint16

func (d LEByteDecoder) DecodeUint16(buf *bytes.Reader) (uint16, error)

DecodeUint16 decodes a uint16.

func (LEByteDecoder) DecodeUint16Array

func (d LEByteDecoder) DecodeUint16Array(buf *bytes.Reader, size int) ([]uint16, error)

DecodeUint16Array decodes an array of uint16 values.

func (LEByteDecoder) DecodeUint32

func (d LEByteDecoder) DecodeUint32(buf *bytes.Reader) (uint32, error)

DecodeUint32 decodes a uint32.

func (LEByteDecoder) DecodeUint32Array

func (d LEByteDecoder) DecodeUint32Array(buf *bytes.Reader, size int) ([]uint32, error)

DecodeUint32Array decodes an array of uint32 values.

func (LEByteDecoder) DecodeUint64

func (d LEByteDecoder) DecodeUint64(buf *bytes.Reader) (uint64, error)

DecodeUint64 decodes a uint64.

func (LEByteDecoder) DecodeUint64Array

func (d LEByteDecoder) DecodeUint64Array(buf *bytes.Reader, size int) ([]uint64, error)

DecodeUint64Array decodes an array of uint64 values.

func (LEByteDecoder) DecodeUint8

func (d LEByteDecoder) DecodeUint8(buf *bytes.Reader) (uint8, error)

DecodeUint8 decodes a uint8.

func (LEByteDecoder) DecodeUint8Array

func (d LEByteDecoder) DecodeUint8Array(buf *bytes.Reader, size int) ([]uint8, error)

DecodeUint8Array decodes an array of uint8 values.

type Message

type Message interface {
	Type() MessageType
	Serialize(buf *bytes.Buffer) error
	Deserialize(buf *bytes.Reader) error
}

Message struct which contains the message type, serialize and deserialize functions

func NewActionHeader

func NewActionHeader() Message

Create a new standard header message. Convenience function

type MessageEvent

type MessageEvent struct {
	PublisherName    string
	ReceiptTime      time.Time
	ConnectionHeader map[string]string
}

MessageEvent is an optional second argument to a Subscriber callback.

type MessageType

type MessageType interface {
	Text() string
	MD5Sum() string
	Name() string
	NewMessage() Message
}

MessageType struct which contains the interface functions for the important properties of a message Text, Name, and MD5 sum are data used to identify message types while NewMessage instantiates the message fields

type NameMap

type NameMap map[string]string

NameMap is a string to string map of node names and resolved names

type NameResolver

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

NameResolver struct definition for the NameResolver object. Node name is the raw name of the node in question namespace is the directory/qualifier of the node, by default "/" mapping and resolvedMapping are NameMap maps

type Node

type Node interface {
	NewPublisher(topic string, msgType MessageType) (Publisher, error)
	// Create a publisher which gives you callbacks when subscribers
	// connect and disconnect.  The callbacks are called in their own
	// goroutines, so they don't need to return immediately to let the
	// connection proceed.
	NewPublisherWithCallbacks(topic string,
		msgType MessageType,
		connectCallback, disconnectCallback func(SingleSubscriberPublisher)) (Publisher, error)
	// callback should be a function which takes 0, 1, or 2 arguments.
	// If it takes 0 arguments, it will simply be called without the
	// message.  1-argument functions are the normal case, and the
	// argument should be of the generated message type.  If the
	// function takes 2 arguments, the first argument should be of the
	// generated message type and the second argument should be of
	// type MessageEvent.
	NewSubscriber(topic string, msgType MessageType, callback interface{}) (Subscriber, error)
	NewSubscriberWithFlowControl(topic string, msgType MessageType, enable chan bool, callback interface{}) (Subscriber, error)
	NewServiceClient(service string, srvType ServiceType) ServiceClient
	NewServiceServer(service string, srvType ServiceType, callback interface{}) ServiceServer

	RemoveSubscriber(topic string)
	RemovePublisher(topic string)

	OK() bool
	SpinOnce() bool
	Spin()
	Shutdown()
	Namespace() string
	QualifiedName() string

	GetParam(name string) (interface{}, error)
	SetParam(name string, value interface{}) error
	HasParam(name string) (bool, error)
	SearchParam(name string) (string, error)
	DeleteParam(name string) error

	GetSystemState() ([]interface{}, error)
	GetServiceList() ([]string, error)
	GetServiceType(string) (*ServiceHeader, error)
	GetPublishedActions(subgraph string) (map[string]string, error)
	GetPublishedTopics(subgraph string) (map[string]string, error)
	GetTopicTypes() []interface{}

	Logger() zerolog.Logger

	NonRosArgs() []string
	Name() string
}

Node interface which contains functions of a ROS Node

func NewNode

func NewNode(name string, args []string) (Node, error)

NewNode instantiates a newDefaultNode with name and arguments

func NewNodeWithLogs

func NewNodeWithLogs(name string, log zerolog.Logger, args []string) (Node, error)

NewNodeWithLogs instantiates a newDefaultNode with a provided log

type Publisher

type Publisher interface {
	TryPublish(msg Message) error
	Publish(msg Message)
	GetNumSubscribers() int
	Shutdown()
}

Publisher is interface for publisher and shutdown function

type Rate

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

Rate interface is a struct of Durations actual and expected cycle time, and start Time

func CycleTime

func CycleTime(d Duration) Rate

CycleTime returns a new Rate object of expected cycle time of duration given

func NewRate

func NewRate(frequency float64) Rate

NewRate returns a new Rate object of given frequency

func (*Rate) CycleTime

func (r *Rate) CycleTime() Duration

CycleTime returns duration of the Cycle time of a Rate object

func (*Rate) ExpectedCycleTime

func (r *Rate) ExpectedCycleTime() Duration

ExpectedCycleTime returns duration of the Expected Cycle time of a Rate object

func (*Rate) Reset

func (r *Rate) Reset()

Reset sets actual Cycle time and start time of Rate to 0/now

func (*Rate) Sleep

func (r *Rate) Sleep() error

Sleep pauses go routine for time = expectedCycleTime - (Now - Rate start)

type ServerGoalHandler

type ServerGoalHandler interface {
	SetAccepted(string) error
	SetCancelled(Message, string) error
	SetRejected(Message, string) error
	SetAborted(Message, string) error
	SetSucceeded(Message, string) error
	SetCancelRequested() bool
	PublishFeedback(Message)
	GetGoal() (Message, error)
	GetGoalId() (ActionGoalID, error)
	GetGoalStatus() (ActionStatus, error)
	Equal(ServerGoalHandler) bool
	NotEqual(ServerGoalHandler) bool
	Hash() (uint32, error)
	GetHandlerDestructionTime() Time
	SetHandlerDestructionTime(Time)
}

func NewServerGoalHandlerWithGoal

func NewServerGoalHandlerWithGoal(as ActionServer, goal ActionGoal) (ServerGoalHandler, error)

func NewServerGoalHandlerWithGoalId

func NewServerGoalHandlerWithGoalId(as ActionServer, goalID ActionGoalID) ServerGoalHandler

type Service

type Service interface {
	ReqMessage() Message
	ResMessage() Message
}

Service interface contains the Request and Response ROS messages

type ServiceClient

type ServiceClient interface {
	Call(srv Service) error
	Shutdown()
}

ServiceClient is the interface for a service client with service call function

type ServiceFactory

type ServiceFactory interface {
	Name() string
	MD5Sum() string
}

ServiceFactory is an interface for Name and MD5 sum of service

type ServiceHandler

type ServiceHandler interface{}

ServiceHandler is a service handling interface

type ServiceHeader

type ServiceHeader struct {
	Callerid     string
	Md5sum       string
	RequestType  string
	ResponseType string
	ServiceType  string
}

serviceheader is the header returned from probing a ros service, containing all type information

type ServiceServer

type ServiceServer interface {
	Shutdown()
}

ServiceServer is the interface for a service server with shutdown

type ServiceType

type ServiceType interface {
	MD5Sum() string
	Name() string
	RequestType() MessageType
	ResponseType() MessageType
	NewService() Service
}

ServiceType is the interface definition of a ROS Service This contains MD5sum and Name of service and the request and response message types NewService iinstantiates a new Service object

type SimpleActionClient

type SimpleActionClient interface {
	SendGoal(goal Message, doneCb, activeCb, feedbackCb interface{}, goalID string) error
	SendGoalAndWait(goal Message, executeTimeout, preeptTimeout Duration) (uint8, error)
	WaitForServer(timeout Duration) bool
	WaitForResult(timeout Duration) bool
	GetResult() (Message, error)
	GetState() (uint8, error)
	GetGoalStatusText() (string, error)
	CancelAllGoals()
	CancelAllGoalsBeforeTime(stamp Time)
	CancelGoal() error
	ShutdownClient(bool, bool, bool)
	StopTrackingGoal()
}

func NewSimpleActionClient

func NewSimpleActionClient(node Node, action string, actionType ActionType) (SimpleActionClient, error)

type SimpleActionServer

type SimpleActionServer interface {
	Start()
	IsNewGoalAvailable() bool
	IsPreemptRequested() bool
	IsActive() bool
	SetSucceeded(result Message, text string) error
	SetAborted(result Message, text string) error
	SetPreempted(result Message, text string) error
	AcceptNewGoal() (Message, error)
	PublishFeedback(feedback Message)
	GetDefaultResult() Message
	RegisterGoalCallback(callback interface{}) error
	RegisterPreemptCallback(callback interface{})
}

func NewSimpleActionServer

func NewSimpleActionServer(node Node, action string, actionType ActionType, executeCb interface{}, autoStart bool) SimpleActionServer

type SingleSubscriberPublisher

type SingleSubscriberPublisher interface {
	Publish(msg Message)
	GetSubscriberName() string
	GetTopic() string
}

SingleSubscriberPublisher only sends to one specific subscriber. This is sent as an argument to the connect and disconnect callback functions passed to Node.NewPublisherWithCallbacks().

type Subscriber

type Subscriber interface {
	GetNumPublishers() int
	Shutdown()
}

Subscriber is interface for GetNumPublishers function used in callbacks

type SubscriberRos

type SubscriberRos interface {
	RequestTopicURI(pub string) (string, error)
	Unregister() error
}

SubscriberRos interface provides methods to decouple ROS API calls from the subscriber itself.

type SubscriberRosAPI

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

SubscriberRosAPI implements SubscriberRos using callRosAPI rpc calls.

func (*SubscriberRosAPI) RequestTopicURI

func (a *SubscriberRosAPI) RequestTopicURI(pub string) (string, error)

RequestTopicURI requests the URI of a given topic from a publisher.

func (*SubscriberRosAPI) Unregister

func (a *SubscriberRosAPI) Unregister() error

Unregister removes a subscriber from a topic.

type TCPRosDialer

type TCPRosDialer interface {
	Dial(ctx goContext.Context, uri string) (net.Conn, error)
}

TCPRosDialer interface used for connecting to servers.

type TCPRosError

type TCPRosError int

TCPRosError defines custom error types returned by readTCPRosMessage and writeTCPRosMessage. Not all errors returned will be TCPRosErrors.

const (
	TCPRosErrorSizeTooLarge TCPRosError = iota
)

All TCPRosError types.

func (*TCPRosError) Error

func (err *TCPRosError) Error() string

type TCPRosNetDialer

type TCPRosNetDialer struct{}

TCPRosNetDialer implements the TCPRosDialer for net connections.

func (*TCPRosNetDialer) Dial

func (d *TCPRosNetDialer) Dial(ctx goContext.Context, uri string) (net.Conn, error)

Dial will attempt to connect to the specified uri over tcp.

type TCPRosReadResult

type TCPRosReadResult struct {
	Buf []byte
	Err error
}

TCPRosReadResult defines a structure which is delivered via a channel when calling the asynchronous readTCPRosMessage.

type Time

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

Time struct contains a temporal value {sec,nsec}

func NewTime

func NewTime(sec uint32, nsec uint32) Time

NewTime creates a Time object of given integers {sec,nsec}

func Now

func Now() Time

Now creates a Time object of value Now

func (*Time) Add

func (t *Time) Add(d Duration) Time

Add returns sum of Time and Duration given

func (*Time) Cmp

func (t *Time) Cmp(other Time) int

Cmp returns int comparison of two Time objects

func (*Time) Diff

func (t *Time) Diff(from Time) Duration

Diff returns difference of two Time objects as a Duration

func (*Time) FromNSec

func (t *Time) FromNSec(nsec uint64)

func (*Time) FromSec

func (t *Time) FromSec(sec float64)

func (*Time) IsZero

func (t *Time) IsZero() bool

func (*Time) Normalize

func (t *Time) Normalize()

func (*Time) Sub

func (t *Time) Sub(d Duration) Time

Sub returns subtraction of Time and Duration given

func (*Time) ToNSec

func (t *Time) ToNSec() uint64

func (*Time) ToSec

func (t *Time) ToSec() float64

Jump to

Keyboard shortcuts

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