This article focuses on the basic example tutorial on how to use HornedSungem in ROS.

This document is only available for the multi-model version. If HornedSungem hardware version is too low, please update the firmware of the corresponding version.

1 Environment

The operating system selected for our documentation is Ubuntu 16.04

ROS Kinetic ONLY supports Wily (Ubuntu 15.10), Xenial (Ubuntu 16.04) and Jessie (Debian 8) for debian packages.

  • Setup your computer to accept software from packages.ros.org,and set up your keys.

    sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
    sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
    
  • First, make sure your Debian package index is up-to-date,recommended to install the full version

    sudo apt-get update
    sudo apt-get install ros-kinetic-desktop-full    
    
  • Before you can use ROS, you will need to initialize rosdep. rosdep enables you to easily install system dependencies for source you want to compile and is required to run some core components in ROS.

    sudo rosdep init
    rosdep update
    
  • It’s convenient if the ROS environment variables are automatically added to your bash session every time a new shell is launched:

    echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
    source ~/.bashrc
    
  • To install this tool and other dependencies for building ROS packages, run:

    sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential
    

LinkUbuntu install of ROS Kinetic

Configure the SungemSDK-ROS environment and resources

  • Download SungemSDK-ROS

    git clone --recursive https://github.com/HornedSungem/SungemSDK-ROS.git
    
  • If the install.sh script file has not been executed, cd to the directory and execute the script file.

    cd SungemSDK-ROS/src/SungemSDK/installer/Linux/
    ./install.sh
    
  • Prepare the required resource files, model and data files, git latest SungemSDK-GraphModels, or download from Baidu cloud disk, and link the directory to the system. If you don’t want to put it under the system, you can modify the model in the horned_sungem_launch/config directory. The graph_file_path and category_file_path parameters of the configuration file ensure that the file can be found under the path.

    git clone https://github.com/HornedSungem/SungemSDK-GraphModels.git
    sudo cp -r <workspace>/SungemSDK-GraphModels /opt/SungemSDK-GraphModels
    

2 How to use

  • We can now build that package using catkin_make:

    cd SungemSDK-ROS
    catkin_make
    
  • Before continuing remember to source your environment setup file if you have not already. On Ubuntu it would be something like this:

    source devel/setup.bash
    
  • Check the ROS package path is correct

    echo $ROS_PACKAGE_PATH
    /home/<user_name>/SungemSDK-ROS/src:/opt/ros/kinetic/share
    

hint:

If you just want to run tests on your remote machine , set these environment variables:

Find the host IP address:

  ifconfig

For example, the host ip is 192.168.50.201, and the following commands are executed on the current terminal:

  export ROS_MASTER_URI=http://192.168.50.201:11311
  export ROS_IP=192.168.50.201

How to use SungemSDK-ROS

After configuring the above environment, let me introduce how to use SungemSDK-ROS. According to the demand, we provide two modes:

  1. Standard USB camera:

    • Involved parameters:
      • camera:=usb
      • cnn_type :=googlenet (The default is googlenet) :Model type
    • If you do not configure the ROS camera package, you need to install the environment first.

      sudo apt-get install ros-kinetic-usb-cam
      
    • Example:use mobilenetssd model for detection

      Open the terminal and load the nodelet:

      roslaunch horned_sungem_launch hs_camera.launch cnn_type:=mobilenetssd camera:=usb
      

      Open a new terminal and load the image:

      roslaunch horned_sungem_launch hs_detection_example.launch camera_topic:="/usb_cam/image_raw"
      

      Node: camera_topic is fixed

  2. Bring your own camera:

    • Involved parameters:
      • camera:=hs: If you do not specify this parameter, use the HornedSungem camera
      • pixels:=1080 (The default is 360): we offer two camera resolution options, 1920*1080 and 640*360, you can choose the resolution that works for you according to the project.
    • Example: The following describes the detection using the yolo model

      Open the terminal and load the nodelet,Accepte 360P

      roslaunch horned_sungem_launch hs_camera.launch cnn_type:=yolo camera:=hs pixels:=360:
      

      Open a new terminal and load the image:

      roslaunch horned_sungem_launch hs_detection_example.launch camera_topic:="/hs/camera/image_raw"
      

3 Parameter Description

In the horned_sungem_launch folder, you can view all the launch files, which are used to start multiple nodes to complete complex requirements. You can modify them according to your project requirements. Now let me introduce the parameters included in the launch file.

  • Common parameters:
    • cnn_type: neural network type, default is googlenet, the main models are classified as tensorflow and caffe.
      • MobileNetSSD
      • Yolo
      • AlexNet
      • GoogLeNet
      • SqueezeNet
      • Inception_v1,Inception_v2,Inception_v3,Inception_v4
      • MobileNet
    • camera:the default is hs.
      • hs
      • usb
    • pixels:默认为360
      • 360
      • 1080
      • As stated other values ​​are now only rated as 1080P
  • Other parameters:
    • device_index: If multiple devices are executing at the same time, specify the index of the device.
    • log_level: Display log level, 0 is not displayed, 1 is to display error log, 2 is to display detailed log.
    • video_device: The default is /dev/video0. When using the usb camera, if there are too many connected devices, you need to find the device you want to use.

Node: Parameters should be in lowercase.

4 Showing Results

The current screenshot is in ubuntu16.0.4 environment, camera is hs, pixels is 1080, cnn_type is yolo.

result

5 FAQ

  1. Opencv conflict error:

    error1 If you want to keep the ROS and Python environment coexisting, you need to comment out the source /opt/ros/kinetic/setup.bash line of the .bashrc file. Otherwise, calling the python example will report the opencv reference type error. Solution:

    solve1

  2. Import library error:

    error2 Solution: The problem is libhs.so is not loaded, first make sure that the file exists, and then execute sudo ldconfig in the terminal. The other solution is to update the latest version of ROS library, no need to copy the library file to the system directory.

  3. Launch file error: error3 Solution: The terminal executes source SungemSDK-ROS/devel/setup.bash.

  4. Compile Error: error4 Solution: The Raspberry Pi may have a parameter error. Delete the corresponding parameter in the corresponding CMakeLists.txt.