how can I use the Xenomai functions in ROS?

asked 2018-08-24 08:03:58 -0600

matheus.pinto gravatar image

updated 2018-08-30 08:19:30 -0600

Hi there,

I trying to use Xenomai functions in a C++ file in a ROS(1) package.

The hardware plataform used is a Raspberry Pi 3

The goal is to create a Xenomai task with ROS functions inside.

As a entry point, I download the example from Xenomai website.

The makefile for a simple task program, outside catkin workspace, is:

SKIN=alchemy
MAIN_SRC=ex01
TARGET=ex01

LM=-lm

CFLAGS := $(shell xeno-config --skin=alchemy --cflags)
LDFLAGS := $(LM) $(shell xeno-config --skin=alchemy --ldflags)
CC := $(shell xeno-config --cc)

$(TARGET): $(MAIN_SRC).c
    $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)

The xeno-config --skin=alchemy --cflags returns arm-linux-gnueabihf-gcc.

In the catkin workspace I create a simple package named beginner_tutorials based in the example from:

http://wiki.ros.org/ROS/Tutorials/Wri... .

The program files are located in "src" subdirectory from package: talker.cpp and listener.cpp. In this sources was added the Xenomai include files to use its functions.

In "CMakeLists.txt" located in "beginner_tutorials", was added this commands to make possible compile and link the Xenomai lib to my executable:

execute_process(COMMAND xeno-config --skin=alchemy --cflags OUTPUT_VARIABLE XENO_CFLAGS)
execute_process(COMMAND xeno-config --skin=alchemy --ldflags OUTPUT_VARIABLE XENO_LDFLAGS)

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${XENO_CFLAGS}")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${XENO_LDFLAGS}")

add_executable(talker src/talker.cpp)
target_link_libraries(talker ${catkin_LIBRARIES})

add_executable(listener src/listener.cpp)
target_link_libraries(listener ${catkin_LIBRARIES})

message(STATUS "C COMPILER") # too see compiler and used and flags
message(STATUS ${CMAKE_CXX_COMPILER})
message(STATUS "XENOMAI CFLAGS")
message(STATUS ${XENO_CFLAGS})
message(STATUS "XENOMAI LDFLAGS")
message(STATUS ${XENO_LDFLAGS})

When I go to "~/catkin_ws" and tip catkin_make, the results are as folow:

Base path: /root/catkin_ws
Source space: /root/catkin_ws/src
Build space: /root/catkin_ws/build
Devel space: /root/catkin_ws/devel
Install space: /root/catkin_ws/install
####
#### Running command: "make cmake_check_build_system" in "/root/catkin_ws/build"
####
-- Using CATKIN_DEVEL_PREFIX: /root/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /opt/ros/kinetic
-- This workspace overlays: /opt/ros/kinetic
-- Using PYTHON_EXECUTABLE: /usr/bin/python
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /root/catkin_ws/build/test_results
-- Found gmock sources under '/usr/src/gmock': gmock will be built
-- Found gtest sources under '/usr/src/gmock': gtests will be built
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.7.11
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~  traversing 1 packages in topological order:
-- ~~  - beginner_tutorials
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin package: 'beginner_tutorials'
-- ==> add_subdirectory(beginner_tutorials)
-- C COMPILER
-- /usr/bin/c++

-- XENOMAI CFLAGS
-- -I/usr/xenomai/include/cobalt -I/usr/xenomai/include -march=armv7-a -mfloat-abi=hard -mfpu=neon -ffast-math -D_GNU_SOURCE -D_REENTRANT -D__COBALT__ -I/usr/xenomai/include/alchemy

-- XENOMAI LDFLAGS
-- -Wl,--no-as-needed -Wl,@/usr/xenomai/lib/modechk.wrappers -lalchemy -lcopperplate /usr/xenomai/lib/xenomai/bootstrap.o -Wl,--wrap=main -Wl,--dynamic-list=/usr/xenomai/lib/dynlist.ld -L/usr/xenomai/lib -lcobalt -lmodechk -lpthread -lrt  

-- Configuring done
-- Generating done
-- Build files have been written to: /root/catkin_ws/build
####
#### Running command: "make -j4 -l4" in "/root/catkin_ws/build"
####
[ 50%] Linking CXX executable /root/catkin_ws/devel/lib/beginner_tutorials/listener
[ 50%] Linking CXX executable /root/catkin_ws/devel/lib/beginner_tutorials/talker
c++: fatal error: no input files
compilation terminated.
c++: fatal error: no input files
compilation ...
(more)
edit retag flag offensive close merge delete

Comments

1

Ignoring the issues with the build process: can you please explain what you want to achieve? The whole of roscpp is most likely not hard real-time safe. It uses memory allocation, threads, locks and a lot of system calls that will make Xenomai very unhappy.

Creating a real-time safe ..

gvdhoorn gravatar imagegvdhoorn ( 2018-08-24 08:08:59 -0600 )edit

.. node is possible, but not in the way you're showing here.

gvdhoorn gravatar imagegvdhoorn ( 2018-08-24 08:09:13 -0600 )edit

First, I would like to see if it is possible to use xenomai functions inside the catkin. Then I would see details of how to make communication as predictable as possible (not necessarily hard).About what you said: what other means to achieve real time with ros1?

matheus.pinto gravatar imagematheus.pinto ( 2018-08-24 09:09:38 -0600 )edit

Please see RTROS – A real-time extension to the Robot Operating System from ROSCon16. It goes into some detail as to what the performance of ROS1 is when trying to use it for (even soft) real-time tasks.

gvdhoorn gravatar imagegvdhoorn ( 2018-08-24 09:12:15 -0600 )edit

First, I would like to see if it is possible to use xenomai functions inside the catkin

catkin == cmake.

I would recommend you try and find some information on how to compile and link Xenomai programs with CMake. The procedure for Catkin would be identical.

gvdhoorn gravatar imagegvdhoorn ( 2018-08-24 09:13:12 -0600 )edit

I am aware that catkin is basically the cmake. However, as I did not find any information in other communities, I ended up resorting to the ROS group.

Regarding the RT-ROS that you passed, I did not find any place where I can download the project.

matheus.pinto gravatar imagematheus.pinto ( 2018-08-24 20:25:27 -0600 )edit

However, as I did not find any information in other communities, I ended up resorting to the ROS group.

building Xenomai Apps with CMake appears to be a discussion on the Xenomai mailing list about just this subject.

gvdhoorn gravatar imagegvdhoorn ( 2018-08-25 02:49:49 -0600 )edit

Regarding the RT-ROS that you passed, I did not find any place where I can download the project.

I did not refer you to that presentation for that reason. I wanted to provide you with a source of information, and show you that others have done similar work.

gvdhoorn gravatar imagegvdhoorn ( 2018-08-25 02:50:23 -0600 )edit