The Robotics Library is an open source C++ library for robot kinematics, motion planning and control.

The official website provides a Windows installer. But it's release only and has no debug information. To better debug into the library, we need to build it from the source code.

There's an official building instructions including its source code and all 3rd parties' download and building steps. But that description is for VS 2010 x64 release build, if building into VS 2008 win32 debug version, there're some extra work to do. This article describes all the required steps.

Step-by-step guide

The library can be built in many VS versions (2008, 2010, 2012, .. etc) and flavors (debug/release, win32/x64 bit). This article uses VS 2008 win32 debug version as an example. The process for other flavors (e.g VS 2012 x64 release) are similar.

Part 1: Preparation

  1. Create a temporary folder c:\temp, type command "subst S: c:\temp". This makes the code path in pdb files starts with a virtual logic drive "S:" so it's easier to debug the robotics library code in the future.
  2. Download the required third parties following the official building instructions, extract them to different folders in S:\3p. Here we only build the core library, so in a minimum we need Eigen, Boost, LibXml2, Coin3D and CGAL. If we want to build the demo programs then we need more 3ps like Qt, SOLID, .. etc.
  3. Download the source code of the robotics library, extract it to S:\source. Here is what my folder structure looks like after doing all these.
  4. Install CMake ≥ 2.8.11. Here I install CMake 3.0.
  5. Start "Visual Studio 2008 Command Prompt". type the following command to allow multi-core compilation support.
          set VCBUILD_DEFAULT_OPTIONS=/M%NUMBER_OF_PROCESSORS%
          set CL=/MP

Part 2: Build the 3rd parties

  1. Boost:
    1. change directory to the boost folder. execute the following command:
        bootstrap.bat
    2. execute the following command:
      b2 toolset=msvc-9.0 install address-model=32 --build-type=complete --prefix="C:\Program Files (x86)\Boost"
    3. add C:\Program Files (x86)\Boost\lib to the system's PATH variable.
    4. execute the following command:
      set BOOST_ROOT=%ProgramFiles(x86)%\Boost
  2. Eigen:
         change directory to the Eigen folder and execute the following command:
           mkdir Default
    cd Default
    cmake -G "Visual Studio 9 2008" -D CMAKE_INSTALL_PREFIX="C:\Program Files (x86)\eigen" ..
    cmake --build . --config Debug --target INSTALL
  3. LibXml2: 
    1. change directory to the subdirectory "win32" and execute 
      cscript configure.js compiler=msvc debug=yes iconv=no prefix="C:\Program Files (x86)\libxml2"
    2. edit the file "config.msvc" in that folder, find the line PREFIX=C:\Program Files (x86)\libxml2, change it to PREFIX="C:\Program Files (x86)\libxml2". (use double quote to enclose the path).
    3. execute the following command to build the library
      nmake /f Makefile.msvc
    4. change directory to the folder "bin.msvc", execute the following command to embed the manifest into the generated dll
      mt.exe -manifest libxml2.dll.manifest -outputresource:libxml2.dll;2
    5. change director to "win32", execute teh following command to install the library to c:\Program Files (x86)
      nmake /f Makefile.msvc install
    6. add the C:\Program Files (x86)\libxml2\bin to the system's PATH variable
  4. Coin3D:
    1. open the Visual Studio solution file build\msvc9\coin3.sln. Select the desired configuration (here are the dll-debug and lib-debug) and build. It'll report "coin3 docs" project built fails (possibly due to lack of doxygen), which is OK.
    2. create a folder "c:\Program Files (x86)\coin".
    3. create a temporary folder named like "c:\temp\install". Note this temp folder's full path should have no white space. We'll firstly install Coin3D to it and then copy all the files to "c:\Program Files (x86)\coin".
    4. change directory to the build\msvc9 folder, type the following command
         set COINDIR=c:\temp\install
      ..\misc\install-sdk.bat dll debug msvc9 coin3
      xcopy /s %COINDIR% "%programfiles(x86)%\coin" 
  5. CGAL:
    1. change directory to the CGAL folder, open the CMakeLists.txt, remove the following line:
      list (INSERT CGAL_ESSENTIAL_3RD_PARTY_LIBRARIES 0 GMP MPFR)
    2. execute the following command
      mkdir Default
      cd Default
      cmake -G "Visual Studio 9 2008" -D CMAKE_INSTALL_PREFIX="C:\Program Files (x86)\cgal" -D WITH_CGAL_ImageIO=OFF -D WITH_CGAL_Qt3=OFF -D WITH_CGAL_Qt4=OFF -D WITH_GMP=OFF -D WITH_MPFR=OFF ..
      cmake --build . --config Debug --target INSTALL

Part 3: Build the Robotics Library

The building instructions builds the library in command line, while I meet some problem when using it. Here are the steps of how to build it with CMake-gui and VS IDE.

  1. change directory to the robotics library folder, open the CMakeLists.txt. Change the following options to "FALSE" because we don't want to build the demos and tests.

    option(BUILD_DEMOS "Build demos" FALSE)
    option(BUILD_EXTRAS "Build extras" FALSE)
    option(BUILD_RL_MATH "Build RL::MATH" TRUE)
    option(BUILD_RL_UTIL "Build RL::UTIL" TRUE)
    option(BUILD_RL_XML "Build RL::XML" TRUE)
    option(BUILD_TESTS "Build tests" FALSE)

  2. open CMake-gui, specify the source directory as "S:\source\rl-0.6.2" and build directory as "S:\source\rl-0.6.2\build". click "Configure", select "Visual Studio 9 2008" as the generator, keeping the default option of "Use default native compilers'.
  3. It'll prompt "LIBXML2_INCLUDE_DIRS" can't be found, specify it as "C:\Program Files (x86)\libxml2\include\libxml2". Also, add an entry "BOOST_ROOT", specifying its value as "C:\Program Files (x86)\Boost".
  4. Click "Configure", there'll be no error any more. Click "Configure" again so there's no red item. Click "Generate" to generate the solution files.
  5. Open the "build\rl.sln" in VS2008. Find these 8 projects: rlhal, rlkin, rlmath, rlmdl, rlplan, rlsg, rlutil, rlxml. Change their default pdb files name to "$(ProjectName)d.pdb" as following:
     
  6. Build the solution.
  7. Copy the pdb files to the installed folderxcopy /s  lib\debug\*.pdb "c:\Program Files (x86)\rl\lib"
  8. Change directory to the "build" folder. Execute the following commands to copy the header files, library files and pdb files to "c:\Program Files (x86)\rl"
    cmake --build . --config Debug --target INSTALL
    xcopy /s  lib\debug\*.pdb "c:\Program Files (x86)\rl\lib"
Note:

  • If building in release, replace the "debug", "Debug" command options to "release", "Release".
  • If building in x64, start the "Visual Studio x64 Win64 Command Prompt". And replace the installation folder from "c:\Program Files (x86)" to "c:\Program Files"
  • If building in other VS versions, replace the tool set and visual studio version string. E.g., for VS 2012 x64 version, replace "msvc-9.0" with "msvc-11.0", replace "Visual Studio 9 2008" with "Visual Studio 11 Win64". A complete list of CMake 3.0 VS generator string can be found here.
  • See the official building instructions for more examples on 64 bit release build instructions.

Part 4: Package the library

The built Robotics Library files and its 3rd parties are in "c:\Program Files (x86)", they don't have to be there. And we can copy all their lib files to one place so the application referencing will be easier.

Copy the following content to a batch file and execute it to put all the files (header, lib, dll) into a similar folder structure as the Robotics Library's official Windows installation.

====================================================================

set RL_ROOT=%programfiles(x86)%

REM copy the header files
xcopy /s %RL_ROOT%\Boost\include\boost-1_55 %RL_ROOT%\rl\include
xcopy /s %RL_ROOT%\cgal\include %RL_ROOT%\rl\include
mkdir %RL_ROOT%\rl\include\coin
xcopy /s %RL_ROOT%\coin\include %RL_ROOT%\rl\include\coin
mkdir %RL_ROOT%\rl\include\Eigen
xcopy /s %RL_ROOT%\eigen\include\eigen3\Eigen %RL_ROOT%\rl\include\Eigen
xcopy /s %RL_ROOT%\libxml2\include\libxml2 %RL_ROOT%\rl\include

REM copy the lib files
xcopy /s %RL_ROOT%\Boost\lib %RL_ROOT%\rl\lib
xcopy /s %RL_ROOT%\cgal\lib %RL_ROOT%\rl\lib
xcopy /s %RL_ROOT%\coin\lib %RL_ROOT%\rl\lib
xcopy /s %RL_ROOT%\libxml2\lib %RL_ROOT%\rl\lib

REM copy the dll files
mkdir %RL_ROOT%\rl\bin
xcopy /s %RL_ROOT%\cgal\bin %RL_ROOT%\rl\bin
xcopy /s %RL_ROOT%\coin\bin %RL_ROOT%\rl\bin
xcopy /s %RL_ROOT%\libxml2\bin %RL_ROOT%\rl\bin

REM remove the old files
rmdir /s /q %RL_ROOT%\Boost
rmdir /s /q %RL_ROOT%\cgal
rmdir /s /q %RL_ROOT%\coin
rmdir /s /q %RL_ROOT%\eigen
rmdir /s /q %RL_ROOT%\libxml2

Part 5: Test the library

  1. Create a win32 console application, copy below content to the main .cpp file.

    #include <iostream>
    #include <rl/math/Transform.h>
    #include <rl/math/Unit.h>
    #include <rl/mdl/Kinematic.h>
    #include <rl/mdl/Model.h>
    #include <rl/mdl/XmlFactory.h> int
    main(int argc, char** argv)
    {
    rl::mdl::XmlFactory factory;
    rl::mdl::Kinematic * kinematics = dynamic_cast<rl::mdl::Kinematic *>(factory.create("C:\\Program Files (x86)\\rl-0.6.2\\share\\rl\\examples\\rlmdl\\unimation-puma560.xml"));
    rl::math::Vector q(6);
    q << 10, 10, -20, 30, 50, -10;
    q *= rl::math::DEG2RAD;
    kinematics->setPosition(q);
    kinematics->forwardPosition();
    rl::math::Transform t = kinematics->getOperationalPosition(0);
    rl::math::Vector3 position = t.translation();
    rl::math::Vector3 orientation = t.rotation().eulerAngles(2, 1, 0).reverse();
    std::cout << "Joint configuration in degrees: " << q.transpose() * rl::math::RAD2DEG << std::endl;
    std::cout << "End-effector position: [m] " << position.transpose() << " orientation [deg] " << orientation.transpose() * rl::math::RAD2DEG << std::endl;
    return 0;
    }

      

  2. Set header file search path to "%RL_ROOT%\rl\include"
  3. Add "rlmdld.lib rlxmld.lib rlmathd.lib libxml2.lib" as library dependencies. Set library file search path to "%RL_ROOT%\rl\lib"
  4. Add "EIGEN_DONT_ALIGN" to "C++"–> "Preprocessor" --> "Preprocessor Definitions." (this is to prevent the Eigen issue on 32 bit platforms)
  5. Build the application, copy libxml2.dll to the exe folder. Run the application, you'll get the following result:

Reference

http://www.roboticslibrary.org/tutorials/build-windows

How to build the Robotics Library from source code on Windows的更多相关文章

  1. How to Build MySQL from Source Code on Windows & compile MySQL on win7+vs2010

    Not counting obtaining the source code, and once you have the prerequisites satisfied, [Windows] use ...

  2. Visual Studio 2012,创建工程Build Driver,基于纯Source Code.

    拿到一堆纯代码,怎么去Create Project,设置Include路径,lib路径,要不要Pre-compile技术,配置Project之间的依赖关系. SourcesConverter  Bas ...

  3. How to build windows azure PowerShell Source Code

    Download any version source code of Windows Azure Powershell from https://github.com/Azure/azure-sdk ...

  4. How to compile and install Linux Kernel 5.1.2 from source code

    How to compile and install Linux Kernel 5.1.2 from source code Compiling a custom kernel has its adv ...

  5. nginx 编译某个模板的问题./configure: error: SSL modules require the OpenSSL library. You can either do not enable the modules, or install the OpenSSL library into the system, or build the OpenSSL library stati

    root@hett-PowerEdge-T30:/usr/local/src/nginx-1.9.8# ./configure --prefix=/usr/local/nginx  --add-mod ...

  6. Attach source code to a Netbeans Library Wrapper Module

    http://rubenlaguna.com/wp/2008/02/22/attach-source-code-to-a-netbeans-library-wrapper-module/ Attach ...

  7. Tips for newbie to read source code

    This post is first posted on my WeChat public account: GeekArtT Reading source code is always one bi ...

  8. 3 Ways of JDK Source Code Attachment in Eclipse---reference

    You wanna look at a JVM class while you are coding and you cannot. Here is the solution. First of al ...

  9. How to compile and install Snort from source code on Ubuntu

    http://www.tuicool.com/articles/v6j2Ab Snort is by far the most popular open-source network intrusio ...

随机推荐

  1. Linux:添加永久路由

    没有以下文件时,可创建 vim /etc/sysconfig/network-scripts/route-eth0添加如下信息:192.168.142.100/32 via 192.168.142.1 ...

  2. C--关键字static

    static在C中主要有两个作用: 1.修饰变量  (局部变量.全局变量 都存在内存的静态区) 静态全局变量: 作用域仅限于变量被定义的文件中,其中文件即使用extern声明也无法使用它. 静态局部变 ...

  3. redis集群讨论

    一.生产应用场景 二.存储架构演变 三.应用最佳实践 四.运维经验总结 第1.2节:介绍redis cluster在唯品会的生产应用场景,以及存储架构的演变.第3节:redis cluster的稳定性 ...

  4. centos7.2环境elasticsearch-5.0.1+kibana-5.0.1+zookeeper3.4.6+kafka_2.9.2-0.8.2.1部署详解

    centos7.2环境elasticsearch-5.0.1+kibana-5.0.1+zookeeper3.4.6+kafka_2.9.2-0.8.2.1部署详解 环境准备: 操作系统:centos ...

  5. VUE 入门基础(6)

    六,条件渲染 v-if 添加一个条件块 <h1 v-if="ok">Yes</h1> 也可以用v-else 添加else 块 <template> ...

  6. Python实现插件机制——自动import一个目录下的所有.py文件

    假设有这样一个目录结构: /src          main.py          /plugins                __init__.py                a.py  ...

  7. DGV换行操作

    DGV.RowsDefaultCellStyle.WrapMode = DataGridViewTriState.True;

  8. 【英语魔法俱乐部——读书笔记】 0 序&前沿

    [英语魔法俱乐部——读书笔记] 0 序&前沿   0.1 以编者自身的经历引入“不求甚解,以看完为目的”阅读方式,即所谓“泛读”.找到适合自己的文章开始“由浅入深”的阅读,在阅读过程中就会见到 ...

  9. 初学c# -- 学习笔记(四)

    想想,数据库先用mysql了,这玩意小且安装方便.前面web学了些,现在学winform的.数据库先看看便捷的mysql. 下载了一个mysql5.7版的,装上居然找不到密码,重装3.4回,找不到,说 ...

  10. java 常见dos命令

    盘符: 进入指定的盘符下. dir : 列出当前目录下的文件以及文件夹 md : 创建目录 rd : 删除目录    注意:rd不能删除非空的文件夹,而且只能用于删除文件夹. cd : 进入指定目录 ...