User Tools

Site Tools


alros

This is an old revision of the document!


Integrating ROS 1 & 2 into AL

Author Keitaro Nishimura Date: Last modified on <08/27/18>


This tutorial will teach students how to enable ros integration with the ALs directly so as to bypass shared memory. This tutorial shows the reader how to make a AL into a ROS node and takes approximately 1~2 hrs to complete.
Please note that once an AL has been rosified it will no longer build through Qt.

Motivation and Audience

This tutorial's motivation is to teach readers how to “rosify” an AL. Readers of this tutorial are assumed to have the following background and interests:
*Knowledge and experience with Hubo and PODO
*Knowledge and experience with ROS 1 or 2
*Knowledge and experience with CPP

The rest of this tutorial is presented as follows:

Parts List and Source

You will need an intel nuc running Ubuntu 16.04 with Xenomai and PODO installed. If you do not have that please follow this tutorial to install Ubuntu 16.04, Xenomai, and PODO.
*Installing Xenomai3, PODO3, and QT

Download ROS 1 and or 2


You now need to install either ROS 1 or 2 onto the intel nuc. Don't forget to initialize your workspace!

ROS 1

ROS 1 should be used if you are communicating with other machines running on Ubuntu or if you want to have the widest compatibility with existing ROS packages. ROS Kinetic will be used for this tutorial. Please follow the instructions in the linked installation tutorial for ROS Kinetic.

ROS 2

If you need to communicate with Windows or OSX based machines you will need to install ROS 2. As of writing this tutorial, it is still early in its development with only version 1.0 available. I would not recommend someone to learn ROS 2 before mastering the basics of ROS 1. It is possible that the following link is not the most current installation tutorial so please double check before proceeding.
ROS 2 Installation for Linux
This is the link to the ROS 2 installation tutorials for Windows and OSX:
ROS 2 Installation for Windows
ROS 2 Installation for OSX

Adding AL to ROS Workspace

Once you have the version of ROS you need installed make a new package within your workspace. Once you have it named you will need to make a symbolic link to the AL you want to rosify. This can be done by using the following terminal command.


ln -s /path/to/file /path/to/symlink



This creates a “shortcut” for catkin or ament to find the AL code within its workspace. An example of how to use this command is as follows:


ln -s ~/Desktop/podo_nrl/src/ALPrograms/ManualMove ~/catkin_ws/src/test_AL/src



This command connected the directory “src” within our test package “test_AL” to the “ManualMove” directory within PODO.

Building and Running AL ROS Node

Now in order to build to PODO code with catkin or ament we will need to add all of it's dependencies to the CMakeLists.txt file. The package.xml does not need to change. An example of a rosified AL's cmakelist is shown bellow.

cmake_minimum_required(VERSION 2.8.3)
project(mpcwalk)
 
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
## Add support for C++11, supported in ROS Kinetic and newer
# add_definitions(-std=c++11)
 
## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(Qt5Core REQUIRED)
 
find_package(catkin REQUIRED COMPONENTS
  geometry_msgs
  message_runtime
  roscpp
  std_msgs
)
 
find_library(COPPERPLATE copperplate /usr/include/xenomai/)
find_library(COBALT cobalt /usr/include/xenomai/)
find_library(ALCHEMY alchemy /usr/include/xenomai)
 
 
include_directories( src src/BasicFiles src/JoyStick src/solver
/opt/Qt5.5.1/5.5/gcc_64/include
  ${catkin_INCLUDE_DIRS}
)
 
 add_executable(mpcwalk
 		 src/main.cpp
		 src/StateMachine.cpp
		 src/solver/ldl.cpp
		 src/solver/matrix_support.cpp
		 src/solver/solver.cpp
		 src/solver/util.cpp
		 src/JoyStick/RBJoystick.cpp
		 src/ManualCAN.cpp
		 src/BasicFiles/BasicSetting.h
		 src/BasicFiles/BasicJoint.h
		 src/StateMachine.h
		 src/Definitions.h
		 src/solver/solver.h
		 src/JoyStick/joystickvariable.h
		 src/JoyStick/joystickclass.h
		 src/ManualCAN.h
)
 
 
## Add cmake target dependencies of the executable
## same as for the library above
 add_dependencies(mpcwalk ${${PROJECT_NAME}_EXPORTED_TARGETS}
 ${catkin_EXPORTED_TARGETS} 
 
)
qt5_use_modules(mpcwalk Core Gui Widgets Network) 
## Specify libraries to link a library or executable target against
 target_link_libraries(mpcwalk ${ALCHEMY} ${COPPERPLATE} ${COBALT} rt pcan pthread
		 /home/nishkei/new_podo_nrl/new_podo_nrl/share/Libs/libik_math4.a
		 /home/nishkei/new_podo_nrl/new_podo_nrl/share/Libs/libKINE_DRC_HUBO4.a
          ${catkin_LIBRARIES}
 )
 
target_include_directories(mpcwalk
		PRIVATE /usr/include/xenomai /usr/include/xenomai/cobalt
~/new_podo_nrl/new_podo_nrl/share/Headers 
${catkin_INCLUDE_DIRS})
 
 
set_target_properties(mpcwalk PROPERTIES LINK_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /usr/lib/xenomai/bootstrap.o -Wl,--wrap=main -Wl,--dynamic-list=/usr/lib/dynlist.ld")
 
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
	add_definitions("-fmessage-length=0 -Wall -Wextra -std=c++11")
endif ()


Make sure that the following set and find_package functions are at the top and unchanged:

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
 
find_package(Qt5Core REQUIRED)


Double check that the directories for the following find_library and include_directories functions are correct. You may not have or need some of the directories within the include_directories function:

find_library(COPPERPLATE copperplate /usr/include/xenomai/)
find_library(COBALT cobalt /usr/include/xenomai/)
find_library(ALCHEMY alchemy /usr/include/xenomai)
 
include_directories( src src/BasicFiles src/JoyStick src/solver
/opt/Qt5.5.1/5.5/gcc_64/include
  ${catkin_INCLUDE_DIRS}
)


You will need to tell catkin where every file within the AL directory is in the add_executable function:

 add_executable(mpcwalk
 		 src/main.cpp
		 src/StateMachine.cpp
		 src/solver/ldl.cpp
		 src/solver/matrix_support.cpp
		 src/solver/solver.cpp
		 src/solver/util.cpp
		 src/JoyStick/RBJoystick.cpp
		 src/ManualCAN.cpp
		 src/BasicFiles/BasicSetting.h
		 src/BasicFiles/BasicJoint.h
		 src/StateMachine.h
		 src/Definitions.h
		 src/solver/solver.h
		 src/JoyStick/joystickvariable.h
		 src/JoyStick/joystickclass.h
		 src/ManualCAN.h
)


Make sure that this function is unchanged:

qt5_use_modules(mpcwalk Core Gui Widgets Network)


Double check the paths for the libraries needed by the AL. You will need everything else though:

 target_link_libraries(mpcwalk ${ALCHEMY} ${COPPERPLATE} ${COBALT} rt pcan pthread
		 /home/nishkei/new_podo_nrl/new_podo_nrl/share/Libs/libik_math4.a
		 /home/nishkei/new_podo_nrl/new_podo_nrl/share/Libs/libKINE_DRC_HUBO4.a
          ${catkin_LIBRARIES}
 )


Make sure that the paths are correct for your machine but other than that leave these functions untouched:

target_include_directories(mpcwalk
		PRIVATE /usr/include/xenomai /usr/include/xenomai/cobalt
~/new_podo_nrl/new_podo_nrl/share/Headers 
${catkin_INCLUDE_DIRS})
 
 
set_target_properties(mpcwalk PROPERTIES LINK_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /usr/lib/xenomai/bootstrap.o -Wl,--wrap=main -Wl,--dynamic-list=/usr/lib/dynlist.ld")
 
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
	add_definitions("-fmessage-length=0 -Wall -Wextra -std=c++11")
endif ()


Once you have made the appropriate changes to the CMakeLists.txt file you will be able to build the AL through ROS.

Final Words


This tutorial showed students how to bring an AL into the ROS environment to further expand research and the capabilities of the DRC-HUBO robot. However, this has only been tested with Ubuntu 16.04 and ROS Kinetic and ROS 2 Ardent. Further testing with different version of Ubuntu, ROS 1 and ROS 2 is needed.

alros.1535520609.txt.gz · Last modified: 2018/08/28 22:30 by keitaronishimura