Skip to the main content.

Did you know?

 

RTI is the world’s largest DDS supplier and Connext is the most trusted software framework for critical systems.

Tiered-Support-Plan-DatasheetTiered Support Plans

Our Professional Services team brings extensive experience to train, problem-solve, mentor, and accelerate customer success.

Learn more

Developers

From downloads to Hello World, we've got you covered. Find all of the tutorials, documentation, peer conversations and inspiration you need to get started using Connext today.

Resources

RTI provides a broad range of technical and high-level resources designed to assist in understanding industry applications, the RTI Connext product line and its underlying data-centric technology.

Company

RTI is the largest software framework company for autonomous systems. The company’s RTI Connext product enables intelligent architecture by sharing information in real time, making large applications work together as one.

News & Events
Cooperation

2 min read

Developing Connext DDS in Golang in 4 Simple Steps

Developing Connext DDS in Golang in 4 Simple Steps

Let’s get Go’ing with DDS in 2019! I am so excited to share that there is a new and quick way to develop a DDS application in Go! RTI Go Connector now provides a simplified API for easy DDS development as we’ve done with Connectors for Python and Javascript. If you have already used RTI Connector, you can quickly ramp up as it follows the same convention. If you haven’t used RTI Connector, please check out how-to tips in this blog

Before jumping into RTI Go Connector, I would like to talk a little bit about the Go programming language. Go is an open source programming language designed for building simple, fast, and reliable software. While the syntax of Go is similar to dynamically-typed languages for ease of use, it is a statically-typed, compiled language for high performance, efficiency and safety. Go also supports built-in concurrency features to easily maximize the capabilities of multi-core networked computers. Although Go is relatively young (created in 2009), there are already many frameworks, libraries and software developed. You can find a curated project list for Go here.

With RTI Go Connector, you can easily integrate RTI Connext DDS with lots of other technologies already developed and available in Go.

The motivation for us to develop Go Connector was to integrate RTI Connext DDS with InfluxDB (the time-series database for monitoring). We could quickly develop DDS plugins for Telegraf (a plugin-driven monitoring agent for InfluxDB) using Go Connector. The size of plugin code is roughly a mere 100 lines.

To give you an idea how Go Connector API works, I would like to go over a simple writer example.

The first thing you need to do is to import the Connector package.

import "github.com/rticommunity/rticonnextdds-connector-go"

After that, you can create a connector object by calling the “NewConnector” function. To create a connector object, you have to provide an XML-Based App Creation configuration file and the name of a DDS Participant defined in the XML configuration file. Go provides an interesting primitive called defer. As it is named, a defer statement delays the execution of a function until the surrounding function returns. You can then call “Delete” function to delete the created connector object right after the NewConnector function.

connector, err := rti.NewConnector("MyParticipantLibrary::Zero", filepath)

defer connector.Delete()

You need a connector output object to write a sample. To get an output object, you need to pass the name of a DDS DataWriter defined in the XML configuration file. 

output, err := connector.GetOutput("MyPublisher::MySquareWriter")

Next, you can set fields in a sample instance. Connector provides set functions for all primitives types supported in Go.

output.Instance.SetInt("x", 1)

output.Instance.SetInt("y", 2)

output.Instance.SetInt("shapesize", 30)

output.Instance.SetString("color", "BLUE")

Finally, you can write the sample.

output.Write();

This describes a simple example of how to publish DDS data with Go Connector. Basically, you need four steps:

  1. Create a connector object
  2. Get an output object
  3. Set values to a sample
  4. Write the sample

You can also set values directly to Go structs. Go offers built-in support for JSON encoding and decoding, and Go Connector utilizes functions provided by Connext API for converting DDS to JSON vice versa to do this.

type Shape struct {

     Color string `json:"color"`

     X int `json:"x"`

     Y int `json:"y"`

     Shapesize int `json:"shapesize"`

}

 

var shape Shape

shape.Y = 2

output.Instance.Set(&shape)

If you are interested in learning more about the new Go Connector, please refer to the following GitHub. It describes how to get started and provides simple examples.

 https://github.com/rticommunity/rticonnextdds-connector-go

Let us know on our RTI Community forum if you have any questions. Happy coding!

Navigating IIoT Protocols: Comparing DDS and MQTT

Navigating IIoT Protocols: Comparing DDS and MQTT

The convergence of Operational Technology (OT) and Informational Technology (IT) has become a strategic imperative for organizations aiming to unlock...

Read More ⇢
Optimizing Medical Device Security

Optimizing Medical Device Security

A Comparison of DDS, TLS and DTLS Security Standards

Read More ⇢
Can an RTI Engineering Intern Work Fully Remote and Still Succeed?

Can an RTI Engineering Intern Work Fully Remote and Still Succeed?

Meet New RTI Team Member Marcos Rivera! Work environments around the globe have changed as a result of the recent pandemic, and the structure of...

Read More ⇢