SkillAgentSearch skills...

Goroslib

ROS client library for the Go programming language

Install / Use

/learn @bluenviron/Goroslib
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

goroslib

Deprecation notice

On May 31st 2025, ROS 1, which is the ROS distribution compatible with this library, has reached the end of life. Making this library compatible with ROS 2 would require a significant effort. Therefore, we are forced to archive goroslib.

Info

Test Lint Msgs 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

Table of contents

Installation

  1. Install Go ≥ 1.23.

  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

Click to open the API Documentation

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.

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|

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/bluenviron/goroslib/v2/pkg/msgs"
)

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

The name of the message is taken from the name of the struct (in this case, MessageName), but it can be overridden by adding the msg.Name field:

type MessageName struct {
    msg.Package `ros:"my_package"`
    msg.Name `ros:"my_message_name"`
    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  `

Related Skills

View on GitHub
GitHub Stars368
CategoryDevelopment
Updated1d ago
Forks72

Languages

Go

Security Score

100/100

Audited on Mar 30, 2026

No findings