Skip to content

REBOTNIX SDK

Welcome to the REBOTNIX RB-SDK | Software Development Kit

You can use our SDK to build your own custom AI pipelines, communicate with our hardware modules like GPS, Lidar, Modbus, MPU or ToF sensors. The SDK includes different camera types, frame grabbing, extraction of GPS-Coordinates and Object-Detection-Inference on images.

The SDK is simple to use and ready-to-go on our REBOTNIX GUSTAV edge devices which all run on NVIDIA GPUs.

OPENCV – CUDA FOR JETPACK´S: 4.6.1 – 5.x or Higher.

Currently we offer bindings in C,Python 3.7 or higher.

RB_CAM_BASLER

The REBOTNIX RB_CAMERA_BASLER AND RB_CAMERA_AV is a tool to grab frames from a Basler and Allied VISION cameras. Please note that this only works on preflashed devices from us.

Requirements for python 3.7:
numpy
opencv-python
pycrypto
pypylon

Get camera list

The camera class can be used to list all available cameras that are connected to the machine.

We do support USB- as well as IP-cameras, e.g GigE.

import sys
import os

#check for ROOT_PATH variable
try:
  sys.path.append(os.environ['ROOT_PATH'])
except:
  print("Please set the variable ROOT_PATH.")
  sys.exit(0)

# import rb_camera
import rb_camera_basler as rb_c

#get list of available cameras
available_cameras = rb_c.listCameras()

print(available_cameras)
The above command returns a list structured like this:

[
  {
    "class": "BaslerUsb",
    "modelname": "a2A1920-160ucBAS",
    "serial": "40087915",
    "ip": None
  }
]

Initialization

import sys
import os

#check for ROOT_PATH variable
try:
  sys.path.append(os.environ['ROOT_PATH'])
except:
  print("Please set the variable ROOT_PATH.")
  sys.exit(0)

# import rb_camera
import rb_camera_basler as rb_c

# initialize rb_camera module
rb_cam = rb_c.rb_camera(serial="40087915")

#stop frame grabbing.
rb_cam.stop()

Parameters

Parameter Default Description
serial the camera serial number.
overwrite True If set to true, the configurations will be overwritten.
width 1920 Pixel-width of camera.
height 1080 Pixel-height of camera.
exposureTime 1000 Exposure time in milliseconds.
GainAuto "Once" Auto-Gain mode for Basler camera.
pixelFormat "BayerRG8" The pixel color format of the grabbed frame.
fps 25 Frames per second.
exposureMin 27 Lower limit for exposure time.
exposureMax 35000 Upper limit for exposure time.
lightarget 0.35 Target brightness value you want to keep.
gpioreset False Do a gpio reset.
usbreset False Do an USB reset.

Grab new frame

Once you have the camera serial you can initialize the camera to be ready for frame grabbing.

import sys
import os

#check for ROOT_PATH variable
try:
  sys.path.append(os.environ['ROOT_PATH'])
except:
  print("Please set the variable ROOT_PATH.")
  sys.exit(0)

#REBOTNIX Camera SDK
import libs.rb_camera_basler as rb_c

#get a vailable cameras
available_cameras = rb_c.listCameras()
print(available_cameras)

#set serial of basler camera
rb_cam = rb_c.rb_camera(available_cameras[0]["serial"], usbreset=False)

while True:
  # read current frame
  flag, frame = rb_cam.getFlagAndFrame()
  if flag:
    print(frame.shape)

rb_cam.stop()
Outputs

Output Type Description
flag Boolean Flag is true if a frame was grabbed succesfully, false if not.
frame numpy.ndarray The grabbed frame as a numpy array.

Download

Download rb_camera_basler

RB_CAM_AV

The REBOTNIX RB_CAMERA_ALLIEDVISION is a tool to grab frames from a Alliedvision camera.

Requirements for python 3.7:
vimba
numpy

Get camera list

The camera class can be used to list all available cameras that are connected to the machine.

We do support USB- as well as IP-cameras, e.g GigE.

import sys
import os

#check for ROOT_PATH variable
try:
  sys.path.append(os.environ['ROOT_PATH'])
except:
  print("Please set the variable ROOT_PATH.")
  sys.exit(0)

# import rb_camera
import rb_camera_alliedvision as rb_c

#get list of available cameras
available_cameras = rb_c.listCameras()

print(available_cameras)

The above command returns a list structured like this:

[
  {
    "class": "AlliedvisionUsb",
    "modelname": "Alvium 1500 C-050",
    "serial": "0266J",
    "ip": None
  }
]

Initialization

import sys
import os

#check for ROOT_PATH variable
try:
  sys.path.append(os.environ['ROOT_PATH'])
except:
  print("Please set the variable ROOT_PATH.")
  sys.exit(0)

# import rb_camera
import rb_camera_alliedvision as rb_c

# initialize rb_camera module
rb_cam = rb_c.rb_camera(serial="0266J")

#stop frame grabbing.
rb_cam.stop()

Parameters

Parameter Default Description
serial The camera serial number.
exposureMin 27 Lower limit for exposure time.
exposureMax 35000 Upper limit for exposure time.
gpioreset False Do a gpio reset.
usbreset False Do an USB reset.
xml_config Path to an xml-config file

Grab new Frame

Once you have the camera serial you can initialize the camera to be ready for frame grabbing.

import sys
import os

#check for ROOT_PATH variable
try:
  sys.path.append(os.environ['ROOT_PATH'])
except:
  print("Please set the variable ROOT_PATH.")
  sys.exit(0)

#os.environ["GENICAM_GENTL64_PATH"] = ":/opt/pylon/lib/gentlproducer/gtl:/opt/ssd/install_vimba/VimbaGigETL/CTI/arm_64bit:/opt/ssd/install_vimba/VimbaUSBTL/CTI/arm_64bit"

#REBOTNIX Camera SDK
import libs.rb_camera_alliedvision as rb_c

#get a vailable cameras
available_cameras = rb_c.listCameras()
print(available_cameras)
rb_cam = rb_c.rb_camera(available_cameras[0]["serial"], usbreset=False)

while True:
  # read current frame
  flag, frame = rb_cam.getFlagAndFrame()
  if flag:
    print(frame.shape)

rb_cam.stop()

Outputs

Output Type Description
flag Boolean Flag is true if a frame was grabbed succesfully, false if not.
frame numpy.ndarray The grabbed frame as a numpy array.

Download

Download rb_camera_alliedvision

RB_GPS

The REBOTNIX RB_GPS is a tool to extract raw data from a UBLOX-GPS or other compatible module.

Initialization

import sys
import os

#check for ROOT_PATH variable
try:
  sys.path.append(os.environ['ROOT_PATH'])
except:
  print("Please set the variable ROOT_PATH.")
  sys.exit(0)

#import rb_gps
from libs.rb_gps import rb_gps 

# initialize and start rb_gps module
mygps = rb_gps()

#check if valid gps
print(mygps.flag)

# stop rb_gps module
mygps.stop()

The above commands start and stop the rb_gps module. If you want to set the GPS Module starting with non root, you have to set some flags.

a) sudo chmod a+rw /dev/ttyACM0

b) sudo usermod -a -G dialout rebotnix

c) reboot.

Now the GPS module can be accessed with another user as root.

Get GPS meta data

import sys
import os

#check for ROOT_PATH variable
try:
  sys.path.append(os.environ['ROOT_PATH'])
except:
  print("Please set the variable ROOT_PATH.")
  sys.exit(0)

import time

#REBOTNIX GPS SDK
from libs.rb_gps import rb_gps
#initialize gps
mygps = rb_gps()

while True:
    if mygps.flag:
        lon, lat, gps_acc, sat, speed, headAcc, headMot = mygps.getgps()
        print(lon, lat, gps_acc, sat, speed, headAcc, headMot)
        time.sleep(0.1)

mygps.stop()

Outputs | Output | Type | Description | | ------------ | ------------- | ------------ | |lat | float | The current latitude as a float. | | lon| float | The current longitude as a float. | |gps_acc | float | The accuracy of the signal. | |sat | float | The number of satelites.| |speed | float | Speed information.| |headAcc | float | Accuracy of heading. | |headMot | float | Mot of heading. |

Download

Download rb_gps

RB_KINEMATICS

The REBOTNIX RB_KINEMATICS is a tool to extract raw data from a RTK-GPS or other compatible module.

Initialization

import sys
import os

#check for ROOT_PATH variable
try:
  sys.path.append(os.environ['ROOT_PATH'])
except:
  print("Please set the variable ROOT_PATH.")
  sys.exit(0)

#import rb_kinematics
from libs.rb_kinematics import rb_kinematics

# initialize and start rb_kinematics module
mykinematics = rb_kinematics(port="/dev/ttyACM1")

#check if valid information
print(mykinematics.flag)

# stop rb_gps module
mykinematics.stop()

Get Kinematics meta data

import sys
import os

#check for ROOT_PATH variable
try:
  sys.path.append(os.environ['ROOT_PATH'])
except:
  print("Please set the variable ROOT_PATH.")
  sys.exit(0)

import time

#import rb_kinematics
from libs.rb_kinematics import rb_kinematics

# initialize and start rb_kinematics module
mykinematics = rb_kinematics(port="/dev/ttyACM1")

while True:
    if mykinematics.flag:
        lon, lat, gps_acc, sat, speed, headAcc, headMot = mykinematics.getgps()
        print(lon, lat, gps_acc, sat, speed, headAcc, headMot)
        time.sleep(0.1)

mykinematics.stop()
Outputs

Output Type Description
lat float The current latitude as a float.
lon float The current longitude as a float.
gps_acc float The accuracy of the signal.
sat float The number of satelites.
speed float Speed information.

Download

RB_VISIONTOOLS

The REBOTNIX RB_VISIONTOOLS is a tool to detect objects using a custom trained Object Detection Model.

Since it natevily runs on TRT it offers a very high frames-per-second (FPS) rate. It therefore enables you to build real-time applications. This module runs only on a NVIDIA embedded GPU.

Load Model

import sys
import os

#check for root_path variable
try:
  sys.path.append(os.environ['ROOT_PATH'])
except:
  print("Please set the variable ROOT_PATH.")
  sys.exit(0)

#import rb_visiontools
import libs.rb_visiontools as rb_visiontools

model_path = "./rebotnix_model.rvt"
# load rebotnix model
network, class_names, class_colors, width, height = rb_visiontools.load_model_rb(model_path)
|Parameter |Type | Description| | ------------ | ------------- | ------------ | |model_path|String|Path to model container (rvt file).|

The above command returns the rb_model as well as the class-names, the class-colors and the rb_model width and height.

Inference

import sys
import os

#check for root_path variable
try:
  sys.path.append(os.environ['ROOT_PATH'])
except:
  print("Please set the variable ROOT_PATH.")
  sys.exit(0)

#import rb_visiontools
import libs.rb_visiontools as rb_visiontools
import cv2

model_path = "./models/rebotnix_model.rvt"
# load rebotnix model
network, class_names, class_colors, width, height = rb_visiontools.load_model_rb(model_path)
# set detection threshold
threshold = 0.75

frame_path = "demo.jpg"
frame = cv2.imread(frame_path)

# run detection on input frame
detections, scale_x, scale_y = rb_visiontools.do_detection_rb(network, class_names, frame, width, height, threshold)#

print(detections)

#Output: 
#[('206', '99.1', (289.4804382324219, 107.32664489746094, 107.9014663696289, 171.51626586914062))]

Inputs

Parameter Type Description
network rb_network Loaded model.
class_names list List of detection classes.
frame numpy.ndarray Input frame to run inference on.
width int Width of rb_model.
height int Height of rb_model.
threshold float Threshold for inference. Between 0 and 1.

Download

RB_MODBUS

The REBOTNIX RB_MODBUS is a tool to connect to a modbus server. It enables you to read and process machine data in real time.

Reading Data

import sys
import os

#check for root_path variable
try:
  sys.path.append(os.environ['ROOT_PATH'])
except:
  print("Please set the variable ROOT_PATH.")
  sys.exit(0)

#import rb_modbus
import libs.rb_modbusClass as rb_modbus

#connect to modbus with host ip and port 
host = "192.168.1.1"
port = 1502
modbus_connection = rb_modbus.rb_modbusClass(host=host,port=port)

#start connection to modbus
modbus_connection.start()

while True:

  if modbus_connection.error == True:
    break

  #check if new signal is coming in
  if modbus_connection.rb_lock:

    #read signal
    message = modbus_connection.rb_words

    print(message)

#stop connection to modbus
modbus_connection.stop()

Parameters

Parameter Type Description
host String IP address of your modbus server.
port int Port number.

Download

Download rb_modbus

RB_COMPRESS

REBOTNIX RB_COMPRESS is a tool for compressing relevant information for transferring images to the smallest possible file size. By reducing the file size, you save data volume, time and cost in applications such as smart city applications, robotics or any other IoT without losing information.

Requirements for python 3.7:
opencv-python

Compressing an image

import os
import sys

#check for root_path variable
try:
  sys.path.append(os.environ['ROOT_PATH'])
except:
  print("Please set the variable ROOT_PATH.")
  sys.exit(0)

import cv2
import libs.rb_compressClass as rb_comp

licpath = "./rb_compress.lic"

# input image
img = cv2.imread("./demo.jpg")

# if you want, you can do a resize as well
# aspect ratio

#ar = 1920 / img.shape[1]
#dim = (1920, int(img.shape[0] *ar))
#img = cv2.resize(img,dim, interpolation = cv2.INTER_AREA)

bitrate="45000k"
speed='high'
out_name="./demo.avif"

#init compress module
compressor = rb_comp.rb_compress(licpath=licpath)

#run compression
compressor.compress(img, bitrate, speed, out_name)

Parameters

Parameter Type Description
licpath String Path of your license file.
img Image Image object.
quality String quality parameter, [“low”,”mid”,”high”].
output_name String Path of your desired output file.

Download

Download rb_compress

GPIO RESET

Here is shell code to reset the gpio.

echo 442 > /sys/class/gpio/export
sleep 1

echo 444 > /sys/class/gpio/export
sleep 1

echo out > /sys/class/gpio/gpio442/direction
sleep 1

echo out > /sys/class/gpio/gpio444/direction

# turn off
sleep 3
echo 1 > /sys/class/gpio/gpio442/value
echo 1 > /sys/class/gpio/gpio444/value

sleep 3

# turn on
echo 0 > /sys/class/gpio/gpio442/value
echo 0 > /sys/class/gpio/gpio444/value