Skip to content

RTI Connector for Connext DDS is a lightweight technology that enables DDS data to be accessed with Go.

License

Notifications You must be signed in to change notification settings

rticommunity/rticonnextdds-connector-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

RTI Connector for Connext DDS - Go

Coverage Go Report Card Build and Test Go Version Go Documentation

A lightweight, easy-to-use Go binding for RTI Connext DDS that enables rapid development of distributed applications.

Table of Contents

Overview

RTI Connector for Connext DDS is a lightweight, easy-to-use API that provides access to the power and functionality of RTI Connext DDS. Built on XML-Based Application Creation and Dynamic Data, it enables rapid prototyping and development of distributed applications.

Originally created by the RTI Research Group for demos and proof-of-concepts, RTI Connector is perfect for developers who need to quickly integrate DDS communication into their Go applications without the complexity of the full RTI Connext DDS Professional SDK.

Key Features

✨ Simple API - Easy-to-use Go interface that hides DDS complexity
πŸš€ Rapid Development - Get up and running with DDS in minutes
πŸ”„ Dynamic Data - No need to generate code from type definitions
πŸ“„ XML Configuration - Define data types and QoS policies declaratively in XML
🌐 Cross-Platform - Supports Linux x64, macOS, and Windows x64

Quick Start

Prerequisites

  • Go 1.21 or later
  • Supported platform (Linux x64, macOS, Windows x64)

Installation

  1. Create a new project directory and initialize a Go module:
mkdir my-rti-project
cd my-rti-project
go mod init my-rti-project
  1. Get the Go package:
go get github.com/rticommunity/rticonnextdds-connector-go
  1. Download RTI Connector libraries:
go run github.com/rticommunity/rticonnextdds-connector-go/cmd/download-libs@latest
  1. Set library path (for runtime):
# macOS (Apple Silicon/ARM64)
export DYLD_LIBRARY_PATH=$(pwd)/rticonnextdds-connector/lib/osx-arm64:$DYLD_LIBRARY_PATH

# macOS (Intel/x86_64)  
export DYLD_LIBRARY_PATH=$(pwd)/rticonnextdds-connector/lib/osx-x64:$DYLD_LIBRARY_PATH

# Linux  
export LD_LIBRARY_PATH=$(pwd)/rticonnextdds-connector/lib/linux-x64:$LD_LIBRARY_PATH

# Windows (PowerShell)
$env:PATH = "$(pwd)\rticonnextdds-connector\lib\win-x64;$env:PATH"

πŸ’‘ macOS Users: Use osx-arm64 for Apple Silicon Macs (M1/M2/M3) and osx-x64 for Intel Macs. You can check your architecture with uname -m (arm64 = Apple Silicon, x86_64 = Intel).

πŸ’‘ New to RTI Connector Go? Try the go-get-example first - it provides a complete walkthrough of this installation process with a simple working example.

Your First DDS Application

  1. Create an XML configuration file (ShapeExample.xml):
<dds>
  <qos_library name="QosLibrary">
    <qos_profile name="DefaultProfile" base_name="BuiltinQosLibExp::Generic.StrictReliable" is_default_qos="true"/>
  </qos_library>
  
  <types>
    <struct name="ShapeType">
      <member name="color" type="string" key="true" stringMaxLength="128"/>
      <member name="x" type="long"/>
      <member name="y" type="long"/>
      <member name="shapesize" type="long"/>
    </struct>
  </types>
  
  <domain_library name="MyDomainLibrary">
    <domain name="MyDomain" domain_id="0">
      <register_type name="ShapeType" type_ref="ShapeType"/>
      <topic name="Square" register_type_ref="ShapeType"/>
    </domain>
  </domain_library>
  
  <domain_participant_library name="MyParticipantLibrary">
    <domain_participant name="Zero" domain_ref="MyDomainLibrary::MyDomain">
      <publisher name="MyPublisher">
        <data_writer name="MySquareWriter" topic_ref="Square"/>
      </publisher>
      <subscriber name="MySubscriber">
        <data_reader name="MySquareReader" topic_ref="Square"/>
      </subscriber>
    </domain_participant>
  </domain_participant_library>
</dds>
  1. Create a publisher (publisher.go):
package main

import (
    "log"
    "time"
    
    rti "github.com/rticommunity/rticonnextdds-connector-go"
)

func main() {
    // Create connector
    connector, err := rti.NewConnector("MyParticipantLibrary::Zero", "./ShapeExample.xml")
    if err != nil {
        log.Fatal(err)
    }
    defer connector.Delete()

    // Get output (writer)
    output, err := connector.GetOutput("MyPublisher::MySquareWriter")
    if err != nil {
        log.Fatal(err)
    }

    // Publish data
    for i := 0; i < 10; i++ {
        output.Instance.SetString("color", "BLUE")
        output.Instance.SetInt("x", i*10)
        output.Instance.SetInt("y", i*20)
        output.Instance.SetInt("shapesize", 30)
        
        output.Write()
        log.Printf("Published sample %d", i)
        time.Sleep(time.Second)
    }
}
  1. Create a subscriber (subscriber.go):
package main

import (
    "log"
    
    rti "github.com/rticommunity/rticonnextdds-connector-go"
)

func main() {
    // Create connector
    connector, err := rti.NewConnector("MyParticipantLibrary::Zero", "./ShapeExample.xml")
    if err != nil {
        log.Fatal(err)
    }
    defer connector.Delete()

    // Get input (reader)
    input, err := connector.GetInput("MySubscriber::MySquareReader")
    if err != nil {
        log.Fatal(err)
    }

    // Read data
    log.Println("Waiting for data...")
    for {
        connector.Wait(-1) // Wait indefinitely for data
        input.Take()
        
        numSamples, _ := input.Samples.GetLength()
        for i := 0; i < numSamples; i++ {
            if valid, _ := input.Infos.IsValid(i); valid {
                color, _ := input.Samples.GetString(i, "color")
                x, _ := input.Samples.GetInt(i, "x")
                y, _ := input.Samples.GetInt(i, "y")
                shapesize, _ := input.Samples.GetInt(i, "shapesize")
                
                log.Printf("Received: color=%s, x=%d, y=%d, size=%d", color, x, y, shapesize)
            }
        }
    }
}
  1. Run your application:

Make sure you've completed the installation steps above (including library download and path setup), then:

# Terminal 1 - Start subscriber
go run subscriber.go

# Terminal 2 - Start publisher  
go run publisher.go

You should see the subscriber receiving data published by the publisher!

Library Management

The installation above uses our automated library download tool. For advanced scenarios, see our comprehensive guides:

Library Download Tool Options

# Download specific version
go run github.com/rticommunity/rticonnextdds-connector-go/cmd/download-libs@latest -version v1.3.1

# Check what's currently installed
go run github.com/rticommunity/rticonnextdds-connector-go/cmd/download-libs@latest -current

# List available versions
go run github.com/rticommunity/rticonnextdds-connector-go/cmd/download-libs@latest -list

Usage Examples

Explore our comprehensive examples to learn different patterns and use cases:

Example Description Key Features
Simple Basic publisher/subscriber Getting started, basic data flow
Go Get Example For go get users Inline XML, library download workflow
Shapes Demo Array data handling Complex data types, arrays
JSON Integration Go struct mapping JSON serialization, struct binding
Request-Reply RPC pattern Synchronous communication
Security Secure communication Authentication, encryption
Multiple Files Modular configuration XML organization, reusability

πŸ“ Browse all examples β†’

Platform Support

RTI Connector supports the following platforms with automated CI testing:

Platform Architecture CI Status
Linux x86_64 βœ… Tested on Ubuntu 22.04 (ubuntu-latest)
Linux ARM64 βœ… Supported (libraries included)
macOS Apple Silicon (ARM64) βœ… Supported
macOS Intel (x86_64) βœ… Tested on macOS 13 (macos-13)
Windows x86_64 βœ… Tested on Windows Server 2022 (windows-latest)

πŸ“ Note: Linux x64, macOS x64, and Windows x64 are continuously tested via GitHub Actions CI. If you need support for additional architectures, please contact your RTI account manager or [email protected].

Version Information

To check the version of your installed RTI libraries:

go run github.com/rticommunity/rticonnextdds-connector-go/cmd/download-libs@latest -current

Development

Building and Testing

For contributors and developers working with the source code:

# Clone and setup
git clone https://github.com/rticommunity/rticonnextdds-connector-go.git
cd rticonnextdds-connector-go
make download-libs

# Run all tests with coverage
make test-local

# Run comprehensive test suite with quality checks
./test_improvements.sh

# Build all packages
go build ./...

# Run static analysis
go vet ./...

# Format code
go fmt ./...

Threading Model

⚠️ Important: The Connector Native API does not implement thread safety. You are responsible for protecting calls to Connector in multi-threaded applications.

The native code was originally designed for single-threaded environments (RTI Prototyper and Lua). While we've added support for Go, Python, and JavaScript, thread safety remains the developer's responsibility.

Documentation

Additional Resources

Contributing

We welcome contributions! Here's how to get started:

  1. πŸ“ Sign the CLA - Required for all contributions
  2. 🍴 Fork and clone the repository
  3. πŸ”§ Make your changes with tests
  4. βœ… Run quality checks: make test-local or ./test_improvements.sh
  5. πŸ“€ Submit a pull request

All contributions are automatically tested for quality, including:

  • Build verification across platforms
  • Code linting and formatting
  • Comprehensive test suite validation
  • Coverage analysis

Support

Getting Help


Ready to get started? Check out our Quick Start guide or explore the examples!

About

RTI Connector for Connext DDS is a lightweight technology that enables DDS data to be accessed with Go.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 8