Special Software Package

Docker Software Package

TB-RK3588SD pre-installed debian11 image supports the Docker function.

Install Software Package

sudo apt -y install toybrick-server

Install Docker

Execute the following script to install docker:

toybrick-install.sh docker

Open Docker Configuration

Docker configuration need to open docker related configuration in kernel first.

More detail please refer to: Compiling Source code> Compiling Configuration > Setting Configuration Information, and open the Docker configuration according to the configuration information description.

Docker Usage

Image Download

Execute the following command to download image from https://hub.docker.com/

docker pull $IMAGE

Load the Existing Container or Image

Execute the following command to load the existing container or image.

docker load < $IMAGE.tar

Container Usage

Execute the following command to create a new container and enter the container in command line mode:

doocker run -it $IMAGE bash

Execute the following command to create a new container and map local ports/paths into the container:

docker run -d -v $LOCAL_PATH:$DOCKER_PATH -p $LOCAL_PORT:$DOCKER_PORT $IMAGE

Execute the following command to start up the existing container:

docker start $IMAGE

Execute the following command to enter the existing container in command line mode:

docker exec -it $IMAGE bash

Execute the following command to view the container/image.

docker ps -a  #view all containers
docker images #view all images

Execute the following command to stop the running container.

docker stop $IMAGE

For other usages refer to :Docker

Description:

$IMAGE:image name

$LOCAL_PATH:local path

$DOCKER_PATH:docker container local path

$LOCAL_PORT:local port

$DOCKER_PORT:docker local port

ROS1/ROS2 Software Package

TB-RK3588SD pre-installed debian11 image supports ROS1/ROS2 function.

Install Software Package

ROS1 install command

#Install ros1
toybrick-install.sh ros1
#help command
toybrick-install.sh --help

ROS2 install command

#Install ros2-foxy
sudo apt -y install ros2-foxy
#Install auxiliary Software Packages
ros2.sh prebuild

ROS2 Communication Test

  • Open two new terminals in turn and run the following command

    #terminal 1 listener
    ros2 run demo_nodes_cpp listener
    #terminal 2 talker
    ros2 run demo_nodes_py talker
    
  • If the two terminals can communicate with each other and display the following logs, the compilation is successful:

    #terminal 1 listener
    [INFO] [1642061058.658442093] [listener]: I heard: [Hello World: 1]
    [INFO] [1642061059.638045379] [listener]: I heard: [Hello World: 2]
    [INFO] [1642061060.638299705] [listener]: I heard: [Hello World: 3]
    [INFO] [1642061061.638672438] [listener]: I heard: [Hello World: 4]
    [INFO] [1642061062.639527715] [listener]: I heard: [Hello World: 5]
    [INFO] [1642061063.639907756] [listener]: I heard: [Hello World: 6]
    [INFO] [1642061064.640647545] [listener]: I heard: [Hello World: 7]
    [INFO] [1642061065.640954641] [listener]: I heard: [Hello World: 8]
    [INFO] [1642061066.641028633] [listener]: I heard: [Hello World: 9]
    #terminal 2 talker
    [INFO] [1642061058.636212156] [talker]: Publishing: 'Hello World: 1'
    [INFO] [1642061059.635725887] [talker]: Publishing: 'Hello World: 2'
    [INFO] [1642061060.635657118] [talker]: Publishing: 'Hello World: 3'
    [INFO] [1642061061.635704049] [talker]: Publishing: 'Hello World: 4'
    [INFO] [1642061062.635686631] [talker]: Publishing: 'Hello World: 5'
    [INFO] [1642061063.635791621] [talker]: Publishing: 'Hello World: 6'
    [INFO] [1642061064.635742135] [talker]: Publishing: 'Hello World: 7'
    [INFO] [1642061065.635865475] [talker]: Publishing: 'Hello World: 8'
    [INFO] [1642061066.635945009] [talker]: Publishing: 'Hello World: 9'
    

Note: The generated software package is installed in /opt/ros2_foxy directory.

C++ Demo of Volume Control

  • Download sample:

    sudo apt -y install ros2-foxy-sample
    
  • Copy the sample to home directory:

    sudo cp /opt/ros2-foxy/sample ~/sample
    chown -R toybrick:toybrick  ~/sample/
    
  • Compile service, source code saved in sample/src/volume_control directory:

    cd ~/sample
    colcon build --packages-select volume_control
    
  • Test service, if the correct volume control icon can display in screen, it indicates that the program is running properly.

    #terminal 1:server
    source /opt/ros2-foxy/envsetup
    source ~/sample/install/setup.sh
    #terminal server
    ros2 run volume_control server
    #terminal 2:client
    source /opt/ros2-foxy/envsetup
    source ~/sample/install/setup.sh
    #volume+
    ros2 run volume_control client 1
    #volume-
    ros2 run volume_control client 0
    

Python Demo of Volume Control

  • Download sample:

    sudo apt -y install ros2-foxy-sample
    
  • Copy the sample to home directory:

    sudo cp /opt/ros2-foxy/sample ~/sample
    chown -R toybrick:toybrick  ~/sample/
    
  • Compile service, source code saved in sample/src/py_volume_control directory:

    cd ~/sample
    colcon build --packages-select py_volume_control
    
  • Open the two terminal running nodes respectively, and you can see the successful volume control icon on the desktop:

    #terminal 1:server
    source /opt/ros2-foxy/envsetup
    source ~/sample/install/setup.sh
    #running server
    ros2 run py_volume_control server
    #terminal 2:client
    source /opt/ros2-foxy/envsetup
    source ~/sample/install/setup.sh
    #volume+
    ros2 run py_volume_control client 1
    #volume-
    ros2 run py_volume_control client 0
    

Python Software Package

The Toybrick Python SDK is a rapid development interface for Python specifically designed for EDGE SDK. The interface design follows Python’s compact philosophy and familiar CV naming, and fully integrates the Rockchip hardware acceleration module, operates with physical buffer and zero copy within the interface. Compatible with Numpy, Opencv and other common operation modules, convenient for users to develop and evaluate quickly.

How to Use

  • Install (Firmware is preinstalled by default)

sudo apt install python3-toybrick
  • Import package into python

import toybrick as toy

Support Platform

  • RK3588

  • Toybrick other chip platforms will be supported later

Accelerate Unit

  • GPU: Mali graphic processing unit

  • RGA: RK 2D graphic auxiliary computing unit

  • VPU:RK video hardware codec unit

Module

Global Utility Function: Utils

function name description
toy.version Check the current version
frame = toy.copy_from(nparray) Copy the numpy array and create a local physical buffer

Input Stream: Capture

Function Name Description
stream = toy.RtspCapture(url, usr, pwd, isTCP) Create Rtsp input stream
stream = toy.HdmiCapture(path) Create Hdmi-In input stream
stream = toy.PipeCapture() Create process pipeline input stream
ret, frame = stream.read(width, height, format) Read a frame of image

Output Stream: Writer

function name description
stream = toy.RtspWriter(path, encoder, port) Create Rtsp local service output stream
stream.write(frame, width ,height) Output a frame of image

Display

Function Name Description
disp = toy.Display(name, width, height, displayport) New a display device
w = disp.width() Get the display Buffer width
h = disp.height() Get the display Buffer height
view = disp.addview(x, y, w, h) New display area
disp.mvview(view, x, y, w, h) Move display area
disp.rmview(view) Delete display area
disp.imshow(frame, view) display a frame of image

Graphic Operation: Graphic

Function Name Description
dst = frame.rotate(degree) image rotate
dst = frame.resize(width, height) image resize
dst = frame.crop(x, y, w, h) image crop
nparr = frame.asarray() Convert to numpy array, can be used for cv, numpy

Detail Document

Click here to link