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 <04/25/18>


The photo above shows a “ROSified” AL publishing a “Hello World” text a node listening is outputting into a terminal. The big picture is 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.

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 ()

Final Words

alros.1532483338.txt.gz · Last modified: 2018/07/24 18:48 by keitaronishimura