Dev tips

gRPC API for flexible automotive development

Get to know the RemotiveBroker’s gRPC API and how it simplifies prototyping, building & testing automotive software. Build software the way you want and in the programming language of your choice. We make things easier with a Python wrapper and the gRPC stubs available in a public repo on our GitHub.

gRPC API automotive RemotiveLabs
February 8, 2024
RemotiveLabs
Feature Update

Share

Get stuff done with our gRPC API

Want to make a quick prototype using Python? Interested in Rust? The RemotiveBroker gRPC API can be used to read and write vehicle signal data in your language of choice. This means that you can use the tools you prefer to quickly build applications that depend on real vehicle signal data. Given a simple configuration and a signal database file you can get to work right away with recorded data or inside a physical vehicle with live data. 

Use the same API regardless if you are working with recorded or live data, write your application once and test it on your desktop and inside a vehicle! You can reuse previously recorded drive cycles, e.g. in a deterministic ECU testing setup or when prototyping graphical user interfaces. Once you are satisfied with your work you can, in a true shift-left spirit, bring it to a test rig or physical vehicle knowing that the code has been tested.

Paired with our collaboration platform RemotiveCloud you can quickly scale up your development efforts with multiple virtualized RemotiveBrokers!

Get started with three lines of code

Start a RemotiveBroker with three lines of code:

$ git clone https://github.com/remotivelabs/remotivebroker-bootstrap.git
$ cd remotivebroker-bootstrap
$ docker-compose up -d

Try our free 3-minute demo or check out some of our stuff on Github, e.g the APIs, simple samples, ProtoPie integration) and go to the repo for running the bootstrap RemotiveBroker on your desktop.

What is a RemotiveBroker?

The RemotiveBroker is a flexible developer tool that fit into most setups. it exposes vehicle signal data via a pub/sub gRPC API. We support the most common vehicle networks like CAN, Flexray, LIN and Automotive Ethernet – enabled by .dbx, .xml (fibex), .ldf and .arxml. We also proved E2E Protection – read more here.

Make it even easier with API wrappers and gRPC stubs

We have a public repo for our wrappers and stubs. Anyone is welcome to submit a pull request with a wrapper in their favourite language, get started with our gRPC proto files. Our ambition is to have wrappers and stubs/clients available for everyone.

Advantages with gRPC

Given a simple configuration, the RemotiveBroker will expose a gRPC API that puts you in control. With the broad language support that gRPC has you can use what you prefer, e.g Node.js, Ruby, C# or Kotlin. gRPC leverages HTTP/2 and a binary message format, this helps to reduce network bandwidth and decrease latency. This allows our RemotiveBroker to send large amounts of data in real time, like in the case of high-speed CAN & CAN-FD or Flexray. Read more about gRPC here and about our RemotiveBroker here.

Python wrapper

We have a Python wrapper API for a subset of the RemotiveBroker API to make it even easier to build applications. It is also available for easy installation through Python Package Index. This wrapper API makes it easier to perform common operations like connecting to a RemotiveBroker and setting up vehicle signal data subscriptions.

Connect to a RemotiveBroker and set up a signal subscription:

# Connect to RemotiveBroker
 client = Client()
 client.on_connect = lambda c: print(f"Yay! - connected as {c.client_id} to {c.url}")
 client.on_signals = lambda signals: print(signals.to_json())
 client.connect(url="http://localhost:50051")

# Subscribe to signals
 subscription = client.subscribe(
      signal_names=["Vehicle.Speed"],
      namespaces=["vss"],
      changed_values_only=False)

Try our demo or check out our Github page for more simple runnable examples!

Typescript and Javascript stubs/clients

Since we are working with gRPC-web in our web clients, we have both Typescript and Javascript stubs/clients available for grpc-web here. It is also available via npm/yarn. While not as useful as a proper wrapper API, the stubs/clients are required when working with gRPC. However, just looking at the stubs are helpful when exploring the API.

Subscribe to frame frequency distribution:

// Setup request
const config = new FramesDistributionConfig()
const namespace = new NameSpace()      
namespace.setName(namespaceName)
config.setNamespace(namespace)

// Subscribe
this._frameDistributionStream =  this._networkServiceClient.subscribeToFramesDistribution(config)

Our tooling and APIs are constantly evolving. Follow us on GitHub and LinkedIn to not miss out on more helpful developer content. If you have wishes or thoughts for what we should develop next don’t be a stranger!