概述
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
- 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.
- 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.
- 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.
- Install CMake ≥ 2.8.11. Here I install CMake 3.0.
- 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
- Boost:
- change directory to the boost folder. execute the following command:
bootstrap.bat - execute the following command:
b2 toolset=msvc-9.0 install address-model=32 --build-type=complete --prefix="C:Program Files (x86)Boost"
- add C:Program Files (x86)Boostlib to the system's PATH variable.
- execute the following command:
set BOOST_ROOT=%ProgramFiles(x86)%Boost
- change directory to the boost folder. execute the following command:
- 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 - LibXml2:
- change directory to the subdirectory "win32" and execute
cscript configure.js compiler=msvc debug=yes iconv=no prefix="C:Program Files (x86)libxml2" - 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).
- execute the following command to build the library
nmake /f Makefile.msvc
- 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
- change director to "win32", execute teh following command to install the library to c:Program Files (x86)
nmake /f Makefile.msvc install
- add the C:Program Files (x86)libxml2bin to the system's PATH variable
- change directory to the subdirectory "win32" and execute
- Coin3D:
- open the Visual Studio solution file buildmsvc9coin3.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.
- create a folder "c:Program Files (x86)coin".
- create a temporary folder named like "c:tempinstall". 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".
- change directory to the buildmsvc9 folder, type the following command
set COINDIR=c:tempinstall ..miscinstall-sdk.bat dll debug msvc9 coin3
xcopy /s %COINDIR% "%programfiles(x86)%coin"
- CGAL:
- change directory to the CGAL folder, open the CMakeLists.txt, remove the following line:
list (INSERT CGAL_ESSENTIAL_3RD_PARTY_LIBRARIES 0 GMP MPFR) - 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
- change directory to the CGAL folder, open the CMakeLists.txt, remove the following line:
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.
- 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)
- open CMake-gui, specify the source directory as "S:sourcerl-0.6.2" and build directory as "S:sourcerl-0.6.2build". click "Configure", select "Visual Studio 9 2008" as the generator, keeping the default option of "Use default native compilers'.
- It'll prompt "LIBXML2_INCLUDE_DIRS" can't be found, specify it as "C:Program Files (x86)libxml2includelibxml2". Also, add an entry "BOOST_ROOT", specifying its value as "C:Program Files (x86)Boost".
- 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.
- Open the "buildrl.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:
- Build the solution.
- Copy the pdb files to the installed folderxcopy /s libdebug*.pdb "c:Program Files (x86)rllib"
- 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 libdebug*.pdb "c:Program Files (x86)rllib"
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%Boostincludeboost-1_55 %RL_ROOT%rlinclude
xcopy /s %RL_ROOT%cgalinclude %RL_ROOT%rlinclude
mkdir %RL_ROOT%rlincludecoin
xcopy /s %RL_ROOT%coininclude %RL_ROOT%rlincludecoin
mkdir %RL_ROOT%rlincludeEigen
xcopy /s %RL_ROOT%eigenincludeeigen3Eigen %RL_ROOT%rlincludeEigen
xcopy /s %RL_ROOT%libxml2includelibxml2 %RL_ROOT%rlinclude
REM copy the lib files
xcopy /s %RL_ROOT%Boostlib %RL_ROOT%rllib
xcopy /s %RL_ROOT%cgallib %RL_ROOT%rllib
xcopy /s %RL_ROOT%coinlib %RL_ROOT%rllib
xcopy /s %RL_ROOT%libxml2lib %RL_ROOT%rllib
REM copy the dll files
mkdir %RL_ROOT%rlbin
xcopy /s %RL_ROOT%cgalbin %RL_ROOT%rlbin
xcopy /s %RL_ROOT%coinbin %RL_ROOT%rlbin
xcopy /s %RL_ROOT%libxml2bin %RL_ROOT%rlbin
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
- 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; }
- Set header file search path to "%RL_ROOT%rlinclude"
- Add "rlmdld.lib rlxmld.lib rlmathd.lib libxml2.lib" as library dependencies. Set library file search path to "%RL_ROOT%rllib"
- Add "EIGEN_DONT_ALIGN" to "C++"–> "Preprocessor" --> "Preprocessor Definitions." (this is to prevent the Eigen issue on 32 bit platforms)
- 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
转载于:https://www.cnblogs.com/kaige/p/how_to_build_the_robotics_library_from_source_code_on_windows.html
最后
以上就是娇气荔枝为你收集整理的How to build the Robotics Library from source code on Windows的全部内容,希望文章能够帮你解决How to build the Robotics Library from source code on Windows所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复