goroslib

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2023 License: MIT Imports: 27 Imported by: 18

README

goroslib

Test Lint Go Report Card CodeCov PkgGoDev

goroslib is a library in pure Go that allows to build clients (nodes) for the Robot Operating System (ROS).

The Robot Operating System (ROS) is a project that provides a specification to make multiple programs communicate with each other over time, exchanging structured data with topics, services, actions and parameters. It was conceived to link sensors, algorithms and actuators in unmanned ground vehicles (UGVs) and robots, but it is not bounded to the robot world and can be used anywhere there's the need of building streams of data (for example in video processing).

Features:

  • publish and subscribe to topics with TCP or UDP
  • provide and call services
  • provide and call actions
  • provide and call simple actions
  • get and set parameters
  • support namespaces and relative topics
  • support IPv6 (stateful addresses only)
  • support time API
  • compilation of .msg files is not necessary, message definitions are extracted from code
  • compile or cross-compile for all Go supported OSs (Linux, Windows, Mac OS X) and architectures
  • examples provided for every feature, comprehensive test suite, continuous integration

Important announcement

my main open source projects are being transferred to the bluenviron organization, in order to allow the community to maintain and evolve the code regardless of my personal availability.

In the next months, the repository name will be changed accordingly.

Table of contents

Installation

  1. Install Go ≥ 1.18.

  2. Create an empty folder, open a terminal in it and initialize the Go modules system:

    go mod init main
    
  3. Download one of the example files and place it in the folder:

  4. Compile and run (a ROS master must be already running in the background)

    go run name-of-the-go-file.go
    

API Documentation

https://pkg.go.dev/github.com/aler9/goroslib#pkg-index

FAQs

Comparison with other libraries
goroslib vs official C++/Python libraries

The official project provides libraries to write nodes in C++ and Python, but they require the download of over 1GB of data and work only with a fixed buildchain. This library allows to write lightweight nodes that can be built with the standard Go compiler, do not need any runtime library and have a size of some megabytes. Another advantage lies in the possibility of compiling nodes for all the Golang supported operating systems (Linux, Windows, Mac OS X, etc) and architectures.

goroslib vs rosgo

rosgo is currently unmaintained; furthermore, it requires compilation of .msg files, doesn't support UDP, doesn't support actions, doesn't support simulated clocks.

Full list of features

Current and missing features are described in the FEATURES document.

Use standard messages, services and actions

This library provides most of the standard messages, services and actions in the folder pkg/msgs:

package documentation repository
ackermann_msgs link link
actionlib link link
actionlib_msgs link link
audio_common_msgs link link
control_msgs link link
diagnostic_msgs link link
geometry_msgs link link
geographic_msgs link link
mavros_msgs link link
nav_msgs link link
rosgraph_msgs link link
sensor_msgs link link
shape_msgs link link
sound_play link link
std_msgs link link
std_srvs link link
stereo_msgs link link
tf link link
tf2_msgs link link
trajectory_msgs link link
uuid_msgs link link
velodyne_msgs link link
vision_msgs link link
visualization_msgs link link
Define custom messages, services and actions

To define custom messages, the standard ROS C++/Python libraries require .msg files in this format:

bool field1
int32 field2

This library doesn't require any .msg file, it is enough to write Go structures in this format:

import (
    "github.com/aler9/goroslib/pkg/msgs"
)

type MessageName struct {
    msg.Package `ros:"my_package"`
    Field1 bool
    Field2 int32
}

The type of a field can be one of the following:

  • one of the primitive field types:

    • bool
    • int8
    • uint8
    • int16
    • uint16
    • int32
    • uint32
    • int64
    • uint64
    • float32
    • float64
    • string
    • time.Time
    • time.Duration
  • another standard or custom message

The name of a field must be in CamelCase, and is converted to snake_case when interacting with C++/Python nodes. If this conversion is not possible, the tag rosname can be used to override the field name:

type MessageName struct {
    msg.Package `ros:"my_package"`
    Field bool  `rosname:"FIELD"`
}

Services in this format:

uint32 input
---
uint32 output

Are equivalent to Go structures in this format:

type ServiceNameReq struct {
    Input uint32
}

type ServiceNameRes struct {
	Output uint32
}

type ServiceName struct {
	msg.Package `ros:"my_package"`
	ServiceNameReq
	ServiceNameRes
}

Actions in this format:

uint32 goal
---
uint32 result
---
uint32 feedback

Are equivalent to Go structures in this format:

type ActionNameGoal struct {
	Goal uint32
}

type ActionNameResult struct {
	Result uint32
}

type ActionNameFeedback struct {
	Feedback uint32
}

type ActionName struct {
	msg.Package `ros:"my_package"`
	ActionNameGoal
	ActionNameResult
	ActionNameFeedback
}
Import existing messages, services and actions

You can convert existing .msg files into their equivalent Go structures by using the msg-import tool:

go get github.com/aler9/goroslib/cmd/msg-import
msg-import --rospackage=my_package mymessage.msg > mymessage.go

You can convert existing .srv files into their equivalent Go structures by using the srv-import tool:

go get github.com/aler9/goroslib/cmd/srv-import
srv-import --rospackage=my_package myservice.srv > myservice.go

You can convert existing .action files into their equivalent Go structures by using the action-import tool:

go get github.com/aler9/goroslib/cmd/action-import
action-import --rospackage=my_package myaction.action > myaction.go

To convert a whole ROS package to Go, you can use the package-import tool:

go get github.com/aler9/goroslib/cmd/package-import
package-import <path-to-ros-package> --rospackage=my_package --gopackage=/pkg/msgs
Compile a node for another operating system

To compile a node for another OS, it's enough to follow the standard Golang procedure to cross-compile, that consists in setting the GOOS and GOARCH environment variables according to the target machine. For instance, to build a node for Windows from another OS, run:

GOOS=windows GOARCH=amd64 go build -o node.exe name-of-source-file.go
Edit the library

If you want to hack the library and test the results, unit tests can be launched with:

make test

Standards

Other Go libraries

Other non-Go libraries

Documentation

Overview

Package goroslib is a library in pure Go that allows to build clients (nodes) for the Robot Operating System (ROS).

Examples are available at https://github.com/aler9/goroslib/tree/master/examples

Index

Constants

This section is empty.

Variables

View Source
var ErrNodeTerminated = fmt.Errorf("node terminated")

ErrNodeTerminated is the error when the node has been terminated.

View Source
var ErrProviderTerminated = fmt.Errorf("service provider terminated")

ErrProviderTerminated is the error when the service provider has been terminated.

Functions

This section is empty.

Types

type ActionClient

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

ActionClient is a ROS action client, an entity that can call actions.

func NewActionClient

func NewActionClient(conf ActionClientConf) (*ActionClient, error)

NewActionClient allocates an ActionClient. See ActionClientConf for the options.

func (*ActionClient) CancelAllGoals

func (ac *ActionClient) CancelAllGoals()

CancelAllGoals cancels all goals running on the server.

func (*ActionClient) Close

func (ac *ActionClient) Close() error

Close closes an ActionClient and shuts down all its operations.

func (*ActionClient) SendGoal

SendGoal sends a goal.

func (*ActionClient) WaitForServer

func (ac *ActionClient) WaitForServer()

WaitForServer waits for the action server to start.

type ActionClientCommState

type ActionClientCommState int

ActionClientCommState is the communication state of the goal of an action client.

const (
	ActionClientCommStateWaitingForGoalAck ActionClientCommState = iota
	ActionClientCommStatePending
	ActionClientCommStateActive
	ActionClientCommStateWaitingForResult
	ActionClientCommStateWaitingForCancelAck
	ActionClientCommStateRecalling
	ActionClientCommStatePreempting
	ActionClientCommStateDone
	ActionClientCommStateLost
)

standard goal communication states.

func (ActionClientCommState) String

func (s ActionClientCommState) String() string

String implements fmt.Stringer.

type ActionClientConf

type ActionClientConf struct {
	// parent node.
	Node *Node

	// name of the action.
	Name string

	// an instance of the action type.
	Action interface{}
}

ActionClientConf is the configuration of an ActionClient.

type ActionClientGoalConf

type ActionClientGoalConf struct {
	// the goal to send.
	Goal interface{}

	// (optional) function in the form func(*ActionClientGoalHandler, *ActionResult)
	// that will be called when a status transition happens.
	OnTransition interface{}

	// (optional) function in the form func(*ActionFeedback) that will be called
	// when a feedback is received.
	OnFeedback interface{}
}

ActionClientGoalConf is the configuration of SendGoal().

type ActionClientGoalHandler

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

ActionClientGoalHandler is a goal handler of an ActionClient.

func (*ActionClientGoalHandler) Cancel

func (gh *ActionClientGoalHandler) Cancel()

Cancel cancels the goal.

func (*ActionClientGoalHandler) CommState

CommState returns the communication state of the goal handler.

func (*ActionClientGoalHandler) TerminalState

TerminalState returns the terminal state of the goal handler.

type ActionClientTerminalState

type ActionClientTerminalState int

ActionClientTerminalState is the terminal state of the goal of an action client.

func (ActionClientTerminalState) String

func (s ActionClientTerminalState) String() string

String implements fmt.Stringer.

type ActionServer

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

ActionServer is a ROS action server, an entity that can provide actions.

func NewActionServer

func NewActionServer(conf ActionServerConf) (*ActionServer, error)

NewActionServer allocates an ActionServer. See ActionServerConf for the options.

func (*ActionServer) Close

func (as *ActionServer) Close() error

Close closes an ActionServer and shuts down all its operations.

type ActionServerConf

type ActionServerConf struct {
	// parent node.
	Node *Node

	// name of the action.
	Name string

	// an instance of the action type.
	Action interface{}

	// (optional) status messages are published with this period.
	// It defaults to 200 ms.
	StatusPeriod time.Duration

	// (optional) goals are deleted after they are finished and
	// after this duration.
	// It defaults to 5 secs.
	DeleteFinishedGoalAfter time.Duration

	// (optional) function in the form func(*ActionServerGoalHandler, *ActionGoal)
	// that will be called when a goal arrives.
	OnGoal interface{}

	// (optional) function in the form func(*ActionServerGoalHandler)
	// that will be called when a goal cancellation request arrives.
	OnCancel func(gh *ActionServerGoalHandler)
}

ActionServerConf is the configuration of an ActionServer.

type ActionServerGoalHandler

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

ActionServerGoalHandler is a goal handler of an ActionServer.

func (*ActionServerGoalHandler) PublishFeedback

func (gh *ActionServerGoalHandler) PublishFeedback(fb interface{})

PublishFeedback publishes a feedback about the goal,

func (*ActionServerGoalHandler) SetAborted

func (gh *ActionServerGoalHandler) SetAborted(res interface{})

SetAborted sets the goal as aborted.

func (*ActionServerGoalHandler) SetAccepted

func (gh *ActionServerGoalHandler) SetAccepted()

SetAccepted sets the goal as accepted.

func (*ActionServerGoalHandler) SetCanceled

func (gh *ActionServerGoalHandler) SetCanceled(res interface{})

SetCanceled sets the goal as canceled.

func (*ActionServerGoalHandler) SetRejected

func (gh *ActionServerGoalHandler) SetRejected(res interface{})

SetRejected sets the goal as rejected.

func (*ActionServerGoalHandler) SetSucceeded

func (gh *ActionServerGoalHandler) SetSucceeded(res interface{})

SetSucceeded sets the goal as succeeded.

type ActionServerGoalState

type ActionServerGoalState int

ActionServerGoalState is the state of the goal of an action server.

func (ActionServerGoalState) String

func (s ActionServerGoalState) String() string

String implements fmt.Stringer.

type InfoConnection

type InfoConnection struct {
	ID        int
	To        string
	Direction byte
	Transport string
	Topic     string
	Connected bool
}

InfoConnection contains information about a connection.

type InfoNode

type InfoNode struct {
	PublishedTopics  map[string]struct{}
	SubscribedTopics map[string]struct{}
	ProvidedServices map[string]struct{}
	Address          string
}

InfoNode contains informations about a node.

type InfoService

type InfoService struct {
	Providers map[string]struct{}
	Address   string
}

InfoService contains informations about a service.

type InfoTopic

type InfoTopic struct {
	Type        string
	Publishers  map[string]struct{}
	Subscribers map[string]struct{}
}

InfoTopic contains informations about a topic.

type LogDestination

type LogDestination int

LogDestination is the destination of a log message.

const (
	LogDestinationConsole  LogDestination = 0x01
	LogDestinationRosout   LogDestination = 0x02
	LogDestinationCallback LogDestination = 0x04
)

available destinations.

type LogLevel

type LogLevel int

LogLevel is the level of a log message.

const (
	LogLevelDebug LogLevel = iota + 1
	LogLevelInfo
	LogLevelWarn
	LogLevelError
	LogLevelFatal
)

standard log levels (http://wiki.ros.org/roscpp/Overview/Logging)

type Node

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

Node is a ROS Node, an entity that can create subscribers, publishers, service providers, service clients, action servers and action clients.

func NewNode

func NewNode(conf NodeConf) (*Node, error)

NewNode allocates a Node. See NodeConf for the options.

func (*Node) Close

func (n *Node) Close() error

Close closes a Node and all its resources.

func (*Node) Log

func (n *Node) Log(level LogLevel, format string, args ...interface{})

Log writes a log message. This is implemented like the reference C++ implementation, except for the log file. (http://wiki.ros.org/roscpp/Overview/Logging)

func (*Node) MasterGetMachines

func (n *Node) MasterGetMachines() (map[string]struct{}, error)

MasterGetMachines returns all the machines connected to the master with a node.

func (*Node) MasterGetNodes

func (n *Node) MasterGetNodes() (map[string]*InfoNode, error)

MasterGetNodes returns all the nodes connected to the master.

func (*Node) MasterGetServices

func (n *Node) MasterGetServices() (map[string]*InfoService, error)

MasterGetServices returns all the services provided by nodes connected to the server.

func (*Node) MasterGetTopics

func (n *Node) MasterGetTopics() (map[string]*InfoTopic, error)

MasterGetTopics returns all the topics published by nodes connected to the master.

func (*Node) NodeGetConns

func (n *Node) NodeGetConns(nodeName string) ([]InfoConnection, error)

NodeGetConns returns infos about connections of a node.

func (*Node) NodeKill

func (n *Node) NodeKill(nodeName string) error

NodeKill sends a kill request to a given node.

func (*Node) NodePing

func (n *Node) NodePing(nodeName string) (time.Duration, error)

NodePing sends a ping request to a given node, wait for the response and returns the elapsed time.

func (*Node) ParamGetBool

func (n *Node) ParamGetBool(key string) (bool, error)

ParamGetBool returns a bool parameter from the master.

func (*Node) ParamGetFloat64

func (n *Node) ParamGetFloat64(key string) (float64, error)

ParamGetFloat64 returns a float64 parameter from the master.

func (*Node) ParamGetInt

func (n *Node) ParamGetInt(key string) (int, error)

ParamGetInt returns an int parameter from the master.

func (*Node) ParamGetString

func (n *Node) ParamGetString(key string) (string, error)

ParamGetString returns a string parameter from the master.

func (*Node) ParamIsSet

func (n *Node) ParamIsSet(key string) (bool, error)

ParamIsSet returns whether a parameter is set into the master.

func (*Node) ParamSetBool

func (n *Node) ParamSetBool(key string, val bool) error

ParamSetBool sets a bool parameter into the master.

func (*Node) ParamSetFloat64

func (n *Node) ParamSetFloat64(key string, val float64) error

ParamSetFloat64 sets a float64 parameter into the master.

func (*Node) ParamSetInt

func (n *Node) ParamSetInt(key string, val int) error

ParamSetInt sets an int parameter into the master.

func (*Node) ParamSetString

func (n *Node) ParamSetString(key string, val string) error

ParamSetString sets a string parameter into the master.

func (*Node) TimeNow

func (n *Node) TimeNow() time.Time

TimeNow returns the current time. It supports simulated clocks provided by ROS clock servers.

func (*Node) TimeRate

func (n *Node) TimeRate(d time.Duration) *NodeRate

TimeRate returns an object that can be used to sleep periodically. It supports simulated clocks provided by ROS clock servers.

func (*Node) TimeSleep

func (n *Node) TimeSleep(d time.Duration)

TimeSleep sleeps for the given amount of time. It supports simulated clocks provided by ROS clock servers.

func (*Node) TimeSleepChan

func (n *Node) TimeSleepChan(d time.Duration) <-chan time.Time

TimeSleepChan returns a channel that allows to sleeps for the given amount of time. It supports simulated clocks provided by ROS clock servers.

type NodeConf

type NodeConf struct {
	// (optional) hostname (or ip) and port of the master node.
	// It defaults to 127.0.0.1:11311
	MasterAddress string

	// (optional) namespace of this node.
	// It defaults to '/' (global namespace).
	Namespace string

	// name of this node.
	Name string

	// (optional) hostname or ip of this node, needed by other nodes
	// in order to communicate with it.
	// It defaults to an automatic IP.
	Host string

	// (optional) port of the Slave API server of this node.
	// It defaults to a random port.
	ApislavePort int

	// (optional) port of the TCPROS server of this node.
	// It defaults to a random port.
	TcprosPort int

	// (optional) port of the UDPROS server of this node.
	// It defaults to a random port.
	UdprosPort int

	// (optional) minimum severity level of log messages that will be
	// written to stdout/stderr or sent to /rosout.
	// It defaults to LogLevelInfo.
	LogLevel LogLevel

	// (optional) destinations of log messages.
	// It defaults to LogDestinationConsole | LogDestinationRosout | LogDestinationCallback
	LogDestinations LogDestination

	// (optional) a function that will be called for every log message.
	// It defaults to nil.
	OnLog func(LogLevel, string)

	// (optional) read timeout.
	// It defaults to 10 seconds.
	ReadTimeout time.Duration

	// (optional) write timeout.
	// It defaults to 5 seconds.
	WriteTimeout time.Duration
	// contains filtered or unexported fields
}

NodeConf is the configuration of a Node.

type NodeRate

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

NodeRate allows to sleep with a given period.

func (*NodeRate) Sleep

func (nr *NodeRate) Sleep()

Sleep sleeps with a given period. It supports simulated clocks provided by ROS clock servers.

func (*NodeRate) SleepChan

func (nr *NodeRate) SleepChan() <-chan time.Time

SleepChan returns a channel that allows to sleep with a given period. It supports simulated clocks provided by ROS clock servers.

type Protocol

type Protocol int

Protocol is a ROS stream protocol.

const (
	// TCP is the TCPROS protocol.
	TCP Protocol = iota

	// UDP is the UDPROS protocol.
	UDP
)

type Publisher

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

Publisher is a ROS publisher, an entity that can publish messages in a named channel.

func NewPublisher

func NewPublisher(conf PublisherConf) (*Publisher, error)

NewPublisher allocates a Publisher. See PublisherConf for the options.

func (*Publisher) Close

func (p *Publisher) Close() error

Close closes a Publisher and shuts down all its operations.

func (*Publisher) Write

func (p *Publisher) Write(msg interface{})

Write writes a message into the publisher.

type PublisherConf

type PublisherConf struct {
	// parent node.
	Node *Node

	// name of the topic in which messages will be written
	Topic string

	// an instance of the message that will be published
	Msg interface{}

	// (optional) whether to enable latching, that consists in saving the last
	// published message and send it to any new subscriber that connects to
	// this publisher
	Latch bool
	// contains filtered or unexported fields
}

PublisherConf is the configuration of a Publisher.

type ServiceClient

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

ServiceClient is a ROS service client, an entity that can send requests to service providers and receive responses.

func NewServiceClient

func NewServiceClient(conf ServiceClientConf) (*ServiceClient, error)

NewServiceClient allocates a ServiceClient. See ServiceClientConf for the options.

func (*ServiceClient) Call

func (sc *ServiceClient) Call(req interface{}, res interface{}) error

Call sends a request to a service provider and reads a response.

func (*ServiceClient) CallContext

func (sc *ServiceClient) CallContext(ctx context.Context, req interface{}, res interface{}) error

CallContext sends a request to a service provider and reads a response. It allows to set a context that can be used to terminate the function.

func (*ServiceClient) Close

func (sc *ServiceClient) Close() error

Close closes a ServiceClient and shuts down all its operations.

type ServiceClientConf

type ServiceClientConf struct {
	// parent node.
	Node *Node

	// name of the service from which providers will be obtained.
	Name string

	// an instance of the service type.
	Srv interface{}

	// (optional) enable keep-alive packets, that are
	// useful when there's a firewall between nodes.
	EnableKeepAlive bool
}

ServiceClientConf is the configuration of a ServiceClient.

type ServiceProvider

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

ServiceProvider is a ROS service provider, an entity that can receive requests and send back responses.

func NewServiceProvider

func NewServiceProvider(conf ServiceProviderConf) (*ServiceProvider, error)

NewServiceProvider allocates a ServiceProvider. See ServiceProviderConf for the options.

func (*ServiceProvider) Close

func (sp *ServiceProvider) Close() error

Close closes a ServiceProvider and shuts down all its operations.

type ServiceProviderConf

type ServiceProviderConf struct {
	// parent node.
	Node *Node

	// name of the service.
	Name string

	// an instance of the service type.
	Srv interface{}

	// function in the form func(*NameOfRequest) (*NameOfReply{}, bool)
	// that will be called when a request arrives.
	Callback interface{}
	// contains filtered or unexported fields
}

ServiceProviderConf is the configuration of a ServiceProvider.

type SimpleActionClient

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

SimpleActionClient is a ROS simple action client, an entity that can call simple actions.

func NewSimpleActionClient

func NewSimpleActionClient(conf SimpleActionClientConf) (*SimpleActionClient, error)

NewSimpleActionClient allocates a SimpleActionClient.

func (*SimpleActionClient) CancelAllGoals

func (sac *SimpleActionClient) CancelAllGoals()

CancelAllGoals cancels all goals running on the server.

func (*SimpleActionClient) CancelGoal

func (sac *SimpleActionClient) CancelGoal()

CancelGoal cancels the current goal.

func (*SimpleActionClient) Close

func (sac *SimpleActionClient) Close() error

Close closes a SimpleActionClient.

func (*SimpleActionClient) SendGoal

SendGoal sends a goal.

func (*SimpleActionClient) WaitForServer

func (sac *SimpleActionClient) WaitForServer()

WaitForServer waits for the action server to start.

type SimpleActionClientConf

type SimpleActionClientConf struct {
	// parent node.
	Node *Node

	// name of the action.
	Name string

	// an instance of the action type.
	Action interface{}
}

SimpleActionClientConf is the configuration of a SimpleActionClient.

type SimpleActionClientGoalConf

type SimpleActionClientGoalConf struct {
	// the goal to send.
	Goal interface{}

	// (optional) function in the form func(*ActionResult) that will be called
	// when the goal is done.
	OnDone interface{}

	// (optional) function that will be called when the goal becomes active.
	OnActive func()

	// (optional) function in the form func(*ActionFeedbacK) that will be
	// called when a feedback arrives.
	OnFeedback interface{}
}

SimpleActionClientGoalConf is the configuration of SendGoal().

type SimpleActionClientGoalState

type SimpleActionClientGoalState int

SimpleActionClientGoalState is the state of a goal of a simple action client.

const (
	SimpleActionClientGoalStatePending SimpleActionClientGoalState = iota
	SimpleActionClientGoalStateActive
	SimpleActionClientGoalStateRecalled
	SimpleActionClientGoalStateRejected
	SimpleActionClientGoalStatePreempted
	SimpleActionClientGoalStateAborted
	SimpleActionClientGoalStateSucceeded
	SimpleActionClientGoalStateLost
)

standard goal states.

type SimpleActionServer

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

SimpleActionServer is a ROS simple action server, an entity that can provide actions.

func NewSimpleActionServer

func NewSimpleActionServer(conf SimpleActionServerConf) (*SimpleActionServer, error)

NewSimpleActionServer allocates a SimpleActionServer.

func (*SimpleActionServer) Close

func (sas *SimpleActionServer) Close() error

Close closes a SimpleActionServer.

func (*SimpleActionServer) IsPreemptRequested

func (sas *SimpleActionServer) IsPreemptRequested() bool

IsPreemptRequested checks whether the goal has been canceled.

func (*SimpleActionServer) PublishFeedback

func (sas *SimpleActionServer) PublishFeedback(fb interface{})

PublishFeedback publishes a feedback about the current goal. This can be called only from an OnExecute callback.

func (*SimpleActionServer) SetAborted

func (sas *SimpleActionServer) SetAborted(res interface{})

SetAborted sets the current goal as aborted. This can be called only from an OnExecute callback.

func (*SimpleActionServer) SetSucceeded

func (sas *SimpleActionServer) SetSucceeded(res interface{})

SetSucceeded sets the current goal as succeeded. This can be called only from an OnExecute callback.

type SimpleActionServerConf

type SimpleActionServerConf struct {
	// parent node.
	Node *Node

	// name of the action.
	Name string

	// an instance of the action type.
	Action interface{}

	// (optional) function in the form func(*ActionGoal) that will be
	// called when a goal arrives.
	OnExecute interface{}
}

SimpleActionServerConf is the configuration of a SimpleActionServer.

type Subscriber

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

Subscriber is a ROS subscriber, an entity that can receive messages from a named channel.

func NewSubscriber

func NewSubscriber(conf SubscriberConf) (*Subscriber, error)

NewSubscriber allocates a Subscriber. See SubscriberConf for the options.

func (*Subscriber) Close

func (s *Subscriber) Close() error

Close closes a Subscriber and shuts down all its operations.

type SubscriberConf

type SubscriberConf struct {
	// parent node.
	Node *Node

	// name of the topic from which messages will be read.
	Topic string

	// function in the form func(msg *NameOfMessage)
	// that will be called when a message arrives.
	Callback interface{}

	// (optional) protocol that will be used to receive messages
	// it defaults to TCP.
	Protocol Protocol

	// (optional) queue size. If the Callback is too slow, the queue fills up,
	// and newer messages are discarded.
	// It defaults to zero (wait the Callback synchronously).
	QueueSize uint

	// (optional) enable keep-alive packets, that are
	// useful when there's a firewall between nodes.
	EnableKeepAlive bool

	// (optional) if protocol is TCP, disables the TCP_NODELAY flag, which
	// is enabled by default.
	// It defaults to false.
	DisableNoDelay bool
	// contains filtered or unexported fields
}

SubscriberConf is the configuration of a Subscriber.

Directories

Path Synopsis
cmd
Package cmd contains the support code for commands.
Package cmd contains the support code for commands.
action-import
main package.
main package.
msg-import
main package.
main package.
msgs-gen
main package.
main package.
package-import
main package.
main package.
srv-import
main package.
main package.
examples
pkg
actionproc
Package actionproc contains functions to process actions.
Package actionproc contains functions to process actions.
apimaster
Package apimaster implements the Master API.
Package apimaster implements the Master API.
apiparam
Package apiparam implements the Parameter API.
Package apiparam implements the Parameter API.
apislave
Package apislave implements the Slave API.
Package apislave implements the Slave API.
msg
Package msg contains elements that are used to define messages.
Package msg contains elements that are used to define messages.
msgconv
Package msgconv contains functions to convert messages from ROS definitions to Golang.
Package msgconv contains functions to convert messages from ROS definitions to Golang.
msgproc
Package msgproc contains functions to process messages.
Package msgproc contains functions to process messages.
msgs
Package msgs contains the autogenerated standard messages.
Package msgs contains the autogenerated standard messages.
msgs/ackermann_msgs
Package ackermann_msgs contains message definitions.
Package ackermann_msgs contains message definitions.
msgs/actionlib
Package actionlib contains message definitions.
Package actionlib contains message definitions.
msgs/actionlib_msgs
Package actionlib_msgs contains message definitions.
Package actionlib_msgs contains message definitions.
msgs/audio_common_msgs
Package audio_common_msgs contains message definitions.
Package audio_common_msgs contains message definitions.
msgs/control_msgs
Package control_msgs contains message definitions.
Package control_msgs contains message definitions.
msgs/diagnostic_msgs
Package diagnostic_msgs contains message definitions.
Package diagnostic_msgs contains message definitions.
msgs/geographic_msgs
Package geographic_msgs contains message definitions.
Package geographic_msgs contains message definitions.
msgs/geometry_msgs
Package geometry_msgs contains message definitions.
Package geometry_msgs contains message definitions.
msgs/mavros_msgs
Package mavros_msgs contains message definitions.
Package mavros_msgs contains message definitions.
msgs/nav_msgs
Package nav_msgs contains message definitions.
Package nav_msgs contains message definitions.
msgs/rosgraph_msgs
Package rosgraph_msgs contains message definitions.
Package rosgraph_msgs contains message definitions.
msgs/sensor_msgs
Package sensor_msgs contains message definitions.
Package sensor_msgs contains message definitions.
msgs/shape_msgs
Package shape_msgs contains message definitions.
Package shape_msgs contains message definitions.
msgs/sound_play
Package sound_play contains message definitions.
Package sound_play contains message definitions.
msgs/std_msgs
Package std_msgs contains message definitions.
Package std_msgs contains message definitions.
msgs/std_srvs
Package std_srvs contains message definitions.
Package std_srvs contains message definitions.
msgs/stereo_msgs
Package stereo_msgs contains message definitions.
Package stereo_msgs contains message definitions.
msgs/tf
Package tf contains message definitions.
Package tf contains message definitions.
msgs/tf2_msgs
Package tf2_msgs contains message definitions.
Package tf2_msgs contains message definitions.
msgs/trajectory_msgs
Package trajectory_msgs contains message definitions.
Package trajectory_msgs contains message definitions.
msgs/uuid_msgs
Package uuid_msgs contains message definitions.
Package uuid_msgs contains message definitions.
msgs/velodyne_msgs
Package velodyne_msgs contains message definitions.
Package velodyne_msgs contains message definitions.
msgs/vision_msgs
Package vision_msgs contains message definitions.
Package vision_msgs contains message definitions.
msgs/visualization_msgs
Package visualization_msgs contains message definitions.
Package visualization_msgs contains message definitions.
protocommon
Package protocommon contains functions and definitions for both TCPROS and UDPROS.
Package protocommon contains functions and definitions for both TCPROS and UDPROS.
prototcp
Package prototcp implements the TCPROS protocol.
Package prototcp implements the TCPROS protocol.
protoudp
Package protoudp implements the UDPROS protocol.
Package protoudp implements the UDPROS protocol.
serviceproc
Package serviceproc contains functions to process services.
Package serviceproc contains functions to process services.
xmlrpc
Package xmlrpc implements the XML-RPC protocol, in a variant fit for ROS.
Package xmlrpc implements the XML-RPC protocol, in a variant fit for ROS.

Jump to

Keyboard shortcuts

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