Closed longwoo closed 6 years ago
You can check a typical CMakeLists.txt
in https://github.com/stack-of-tasks/tsid. We use for that the cmake modules https://github.com/jrl-umi3218/jrl-cmakemodules which is pretty useful.
I think you must avoid using -std=c++11
because Pinocchio on robotpkg has not been compiled with this option.
The same applies for -mavx
. You must first install Pinocchio using these options, or simply avoid to use it when prototyping your code.
You should use the pkg-config (.pc file of pinocchio) to configure the cmake project.
@jcarpent Thanks for the guide. It works.
Good. I will add a minimal project with Pinocchio soon.
Hi @longwoo , I just created a typical starting repository of projects that use Pinocchio: https://github.com/stack-of-tasks/pinocchio-minimal
@jcarpent Nice. It is very useful which simplified the cmakelist I used before. But I find it is useless to add the fwd.hpp
in main.cpp
, so I changed it like this.
#
# Copyright (c) 2018 CNRS
#
# This file is part of pinocchio-minimal
# pinocchio is free software: you can redistribute it
# and/or modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation, either version
# 3 of the License, or (at your option) any later version.
# pinocchio is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Lesser Public License for more details. You should have
# received a copy of the GNU Lesser General Public License along with
# pinocchio If not, see
# <http://www.gnu.org/licenses/>.
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
INCLUDE(cmake/base.cmake)
INCLUDE(cmake/boost.cmake)
SET(PROJECT_NAME pinocchio-minimal)
SET(PROJECT_DESCRIPTION "Minimal example of a simple application depending on Pinocchio")
SET(PROJECT_URL "http://github.com/stack-of-tasks/pinocchio-minimal")
# Disable -Werror on Unix for now.
SET(CXX_DISABLE_WERROR True)
SET(CMAKE_VERBOSE_MAKEFILE True)
# ----------------------------------------------------
# --- DEPENDANCIES -----------------------------------
# ----------------------------------------------------
ADD_REQUIRED_DEPENDENCY("pinocchio >= 1.2.0")
ADD_REQUIRED_DEPENDENCY("tsid >= 1.0.0")
ADD_REQUIRED_DEPENDENCY("eigen3 >= 3.2.0")
# ----------------------------------------------------
# --- INCLUDE ----------------------------------------
# ----------------------------------------------------
# Add headers here if any
SET(${PROJECT_NAME}_HEADERS
include/pinocchio-minimal/
)
INCLUDE_DIRECTORIES ( ${${PROJECT_NAME}_HEADERS})
# ----------------------------------------------------
# --- EXECUTABLE -------------------------------------
# ----------------------------------------------------
SET(${PROJECT_NAME}_SOURCES
src/main.cpp
)
# Create the main executable
ADD_EXECUTABLE(main ${${PROJECT_NAME}_SOURCES})
# Link main to its dependencies
PKG_CONFIG_USE_DEPENDENCY(main pinocchio tsid eigen3)
TARGET_LINK_LIBRARIES (main tsid)
# --- PACKAGING ----------------------------------------------------------------
PKG_CONFIG_APPEND_LIBS(${PROJECT_NAME})
So I can also use tsid
lib which contain a useful tool tsid::robots::RobotWrapper
.
@longwoo thanks for your feedback.
@longwoo the lineTARGET_LINK_LIBRARIES (main tsid)
is not requested as you are already linking against tsid with PKG_CONFIG_USE_DEPENDENCY(main pinocchio tsid eigen3)
I have write a cmakelist.txt like this
And a main.cpp like this
When compiling, it gives me error like this:
Is there an example of how to create a project using both Eigen and Pinocchio?