Deploy the SDK
note
To ensure a successful deployment, please follow the instructions in this page step by step.
General installation
The latest release of the SENSR SDK can be found here.
Prerequisites
SENSR SDK is based on Websocket and Protobuf (tested version: 3.11.4).
In a terminal, from the /home/
directory, please follow the steps below to install Protobuf 3.11.4:
sudo apt-get install protobuf-compiler libprotobuf-dev
sudo apt-get install autoconf automake libtool curl make g++ unzip
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.11.4/protobuf-cpp-3.11.4.zip
unzip protobuf-cpp-3.11.4.zip
rm protobuf-cpp-3.11.4.zip
cd protobuf-3.11.4
./autogen.sh
./configure CXXFLAGS=-fPIC
make
make check
sudo make install
sudo ldconfig
Once those steps are completed, please jump to the SDK deployment section.
Deploy the SENSR SDK
The following steps detail how to update the core modules and ensure the right dependencies are installed.
Seoul Robotics recommends installing the SDK at the following location: /home/user/sensr_sdk
Download the SDK from Seoul Robotics Github page:
git clone https://github.com/seoulrobotics/sensr_sdk.git
Update the submodules:
cd sensr_sdk
git submodule update --init --recursive
Install all the listed dependencies:
sudo apt-get install autoconf automake libtool curl make g++ unzip
Now that all modules are ready, language-specific elements can be deployed depending on the language to be used.
Language-specific modules
Python
In the SDK folder, jump to the Python folder and run the configuration file:
cd python
./configure.sh
Once those steps are completed the section here provides some usage examples for python.
Javascript
The following modules are necessary to use SENSR SDK with Javascript:
sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm
If ROS is also installed on the machine, issues can occur while installing npm, in that case please run the following commands:
sudo apt-get install curl python-software-properties
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install nodejs
Once those steps are completed the section here provides some usage examples for Javascript.
C++
Please follow the steps below to build the SDK in C++:
mkdir build
cd build
cmake ..
make
sudo make install
Once those steps are completed the section here provides some usage examples for C++.
Getting started
Python
Print output to console
Launch SENSR and run a project. In a terminal, type the following:
python3 console_output.py --address ip_address --example_type data
The arguments are the following:
- ip_address: ip address of the machine running SENSR (if running on the same machine, please type
localhost
) - data:
- zone will output data relative to zone events
- object will output data relative to objects in the scene
- point will the point result data
- time will output the system's timestamps
- health will output data relative to the system's health
Secure communication
To run in Secure mode, Launch SENSR with ssl on and use the script console_output_secure.py
:
python3 console_output_secure.py --address ip_address --example_type data
Save output to files
Launch SENSR and run a project. In a terminal, type the following to save data in a file:
python3 save_load_output.py --mode save --address ip_address --dir <folder_path_to_save>
Load output from files
Open terminal and type the following to load output
python3 save_load_output.py --mode load --dir <folder_path_to_load>
Javascript
Create your own project
To use the SENSR SDK in Javascript, you first need to create a project.
Create an empty directory for your project and navigate to it, the location does not matter. To initialize your project run:
mkdir my_project
cd my_project
npm init
Follow the instructions, the defaults should be fine.
Add sensr_js_sdk as dependency. This is added as a local module, hence you need to specify the relative (or absolute) path to sensr_js_sdk.
npm install ../relative/path/to/sensr_sdk/javascript/javascript_sdk
You should now have a main file (by default called index.js) that can be run using npm start or node index.js.
This file is the entry-point into your project.
Basic example
Launch SENSR in Runtime mode.
Open the terminal then navigate to javascript/console_output
folder
If you want to run is secure mode, please use javascript/console_output_secure
folder instead.
Install dependencies:
npm install
Run the example using the following command command
node console_output.js show -s ip_address -t data
The arguments are the following:
- ip_address: ip address of the machine running SENSR (if running on the same machine, please type
localhost
) - data:
- zone will output data relative to zone events
- object will output data relative to objects in the scene
- point will the point result data
- time will output the system's timestamps
- health will output data relative to the system's health
C++
Build the sample files
You can build the two samples separately with their own cmake config, in a terminal,
mkdir build_console
cd build_console
cmake ../samples/console_output
make
Note, you can also run build_console_output.sh from the root source folder.
Run the code
In a terminal please enter the following
cd
./build_console/console_output_sample ip_address data
console_output_sample takes following arguments:
- arg[1] : ip address of the machine running SENSR
- arg[2]-[5] : sample types:
- zone will output data relative to zone events
- object will output data relative to objects in the scene
- point will the point result data
- time will output the system's timestamps
- health will output data relative to the system's health
Further modifications
The sample code can be found in the file main.cpp.
You can use your favorite text editor to change the code and run the steps above again to recompile the console_output_sample project with your changes.
Enable secure Web Socket
WSS can be used if you need secure output communication. You can enable WSS by passing the certificate key path when you create a Client instance.
sensr::Client client(address, "$HOME/seoulrobotics/keys/sensr-ca.crt");