Set up Neuromeka's SDK on STEP-PC2 (Ubuntu)

From Neuromeka Wiki
Jump to: navigation, search

Access to STEP-PC File System from Windows

By default, every STEP-PC is delivered to customers with Samba installed on it. Briefly, Samba is a software suite that helps us access Linux file system in the easiest way. In order to use this feature, your Windows PC and STEP-PC are required to connect to the same Local Network (LAN). I suppose that the IP address of STEP-PC is 192.168.0.21.

In Windows PC, press Windows + R keys simultaneously and type the IP address of STEP-PC as shown below.

STEP-PC2-RemoteAccess-FileSystem2.JPG

Then, when you access the Home folder, you are required to specify login information. As usual, the username is user and the password is nrmk2013

From now, the /Home/user/ will be the place where we work in.

STEP-PC2-RemoteAccess-UserFolder2.JPG

Prepare SDK Directory

In this section, you are instructed how to set up the Neuromeka SDK on your STEP-PC. Actually, what you have to do is simply copy a few of header and library files from Windows-based SDK to the device. The Windows-based SDK is packed into installation files which are delivered to you along with Neuromeka's products (i.e. STEP-PC2, Indy RP, Indy5)

First of all, please create an empty folder for the SDK in the STEP-PC file system. Note that you can set any name and put the folder wherever you want. As an example, I create a folder named nrmk_sdk at /Home/user.

Make an empy 'nrmk_sdk' folder

Copy SDK Include Directory

The two most important parts of Neuromeka SDK are the Core and Helper library. They contain a plenty of robotics and motion library as well as third-party libraries which will ease you while developing your own applications. For example, all customers can utilize predefined Poco-based classes for socket communication, Etherlab-based EtherCAT interfaces, or a few of trajectory interpolators for their automation systems. Furthermore, for the Indy customers, the powerful Eigen, Liegroup, and Dynamics/Kinematics Control algorithms are the valuable things in the SDK. As a result, to develop your application with those libraries on STEP-PC, you need to copy them to your device.

Core Library

All Core header files can be found in <neuromeka_dir>\NRMKFoundation\core (e.g. "C:\Program Files (x86)\neuromeka\NRMKFoundation\core"). Please copy this core folder to the nrmk_sdk as shown below.


STEP-PC2 -SDK-Core Include2.JPG

Helper Library

Also, please do the same process with Helper header files from <neuromeka_dir>\NRMKFoundation\helper (e.g. "C:\Program Files (x86)\neuromeka\NRMKFoundation\helper")

STEP-PC2 -SDK-Helper Include2.JPG

Xenomai and EtherCAT Library

Finally, you should copy the library files for Xenomai and EtherCAT located in <neuromeka_dir>\NRMKPlatformPC2\bin\i686 (e.g. "C:\Program Files (x86)\neuromeka\NRMKPlatformPC2\bin\i686").

STEP-PC2 -SDK-Xenomai&EtherCAT.JPG

Copy SDK Library Directory

The SDK Library files (e.g. *.so, *.a) can be found in <neuromeka_dir>\NRMKFoundation\lib (e.g. "C:\Program Files (x86)\neuromeka\NRMKFoundation\lib").

Among all files in the lib folder, there are a few files you may need.

  • libNRMKCore.a (Release | For Indy customers)
  • libNRMKCored.a (Debug | For Indy customers)
  • libNRMKHelperi686.a (Release | For STEP-PC and Indy customers)
  • libNRMKHelperi686d.a (Debug | For STEP-PC and Indy customers)
  • libNRMKhw_tp.a (Release | For STEP-PC and Indy customers)
  • libNRMKhw_tpd.a (Debug | For STEP-PC and Indy customers)

STEP-PC2 -SDK-Library Files2.JPG

Work with CMake

In order to compile your application that uses Neuromeka libraries, you are recommended to make a CMake configuration file (CMakeLists.txt). In the CMakeLists.txt file, please insert some lines as shown below.

  • To configure Include paths
# NRMK Include Library
set(NRMK_PATH "/home/user/nrmk_sdk")
include_directories("${NRMK_PATH}/xenomai/mathlib")
include_directories("${NRMK_PATH}/xenomai/include")
include_directories("${NRMK_PATH}/ethercat/include")
include_directories("${NRMK_PATH}/core/include")
include_directories("${NRMK_PATH}/core/3rdparty/eigen")
include_directories("${NRMK_PATH}/core/3rdparty/Poco/include")
include_directories("${NRMK_PATH}/helper/include")
include_directories("${NRMK_PATH}/helper/include/hw")
include_directories("${NRMK_PATH}/helper/include/hw/nrmk_ecat")


  • To configure Library paths
target_link_libraries(Application_Name                            # TODO: Replace Application_Name with the name of your application or component.
  "${NRMK_PATH}/xenomai/mathlib/libm.a"
  "${NRMK_PATH}/xenomai/lib/libnative.so"
  "${NRMK_PATH}/xenomai/lib/libxenomai.so"
  "${NRMK_PATH}/xenomai/lib/librtdm.so"
  "${NRMK_PATH}/ethercat/lib/libethercat_rtdm.so"
  "${NRMK_PATH}/lib/libNRMKHelperi686.a"
  "${NRMK_PATH}/core/3rdparty/Poco/lib/i686/libPocoFoundation.so"
  "${NRMK_PATH}/core/3rdparty/Poco/lib/i686/libPocoNet.so"
)

XenomaiTest Example

In this section, I am going to make an SDK-based application on STEP-PC with helps of CMake. This application will simply test the real-time performance of Xenomai. Its source folder contains two files: main.cpp and CMakeLists.txt, whose contents are displayed at the bottom of this section.

The below figures show all necessary steps to configure, compile, and execute the application. You may note that I created the build folder to isolate source files and the results of configuration and compilation processes but you are free to run cmake and make commands wherever you want. The final result is a binary file named XenomaiTest which is executable under root privilege.

1. XenomaiTest Source Folder
2. Project Confituration with CMake
3. Project Compilation with Makefile generated by CMake
4. Execute the resulted binary file

#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <sys/mman.h>

#include <native/task.h>
#include <native/timer.h>

RT_TASK demo_task;

/* NOTE: error handling omitted. */

void demo(void *arg)
{
	RTIME now, previous;

	rt_task_set_periodic(NULL, TM_NOW, 1e9);
	previous = rt_timer_read();

	while (1) {
		rt_task_wait_period(NULL);
		now = rt_timer_read();

		printf("Time since last turn: %ld.%06ld ms\n",
		       (long)(now - previous) / 1000000,
		       (long)(now - previous) % 1000000);
		       previous = now;
	}
}

void catch_signal(int sig)
{
}

int main(int argc, char* argv[])
{
	signal(SIGTERM, catch_signal);
	signal(SIGINT, catch_signal);

	/* Avoids memory swapping for this program */
	mlockall(MCL_CURRENT|MCL_FUTURE);

	rt_task_create(&demo_task, "trivial", 0, 99, 0);

	rt_task_start(&demo_task, &demo, NULL);

	pause();

	rt_task_delete(&demo_task);

	return 0;
}

  • CMakeLists.txt:
cmake_minimum_required (VERSION 2.6)

project(XenomaiTest)

# NRMK Include Library
set(NRMK_PATH "/home/user/nrmk_sdk")
include_directories("${NRMK_PATH}/xenomai/mathlib")
include_directories("${NRMK_PATH}/xenomai/include")
include_directories("${NRMK_PATH}/ethercat/include")
include_directories("${NRMK_PATH}/core/include")
include_directories("${NRMK_PATH}/core/3rdparty/eigen")
include_directories("${NRMK_PATH}/core/3rdparty/Poco/include")
include_directories("${NRMK_PATH}/helper/include")
include_directories("${NRMK_PATH}/helper/include/hw")
include_directories("${NRMK_PATH}/helper/include/hw/nrmk_ecat")

add_executable(XenomaiTest main.cpp)

target_link_libraries(XenomaiTest 
  "${NRMK_PATH}/xenomai/mathlib/libm.a"
  "${NRMK_PATH}/xenomai/lib/libnative.so"
  "${NRMK_PATH}/xenomai/lib/libxenomai.so"
  "${NRMK_PATH}/xenomai/lib/librtdm.so"
  "${NRMK_PATH}/ethercat/lib/libethercat_rtdm.so"
  "${NRMK_PATH}/lib/libNRMKHelperi686.a"
  "${NRMK_PATH}/core/3rdparty/Poco/lib/i686/libPocoFoundation.so"
  "${NRMK_PATH}/core/3rdparty/Poco/lib/i686/libPocoNet.so"
)