Commit 5affb24b authored by Justin Carpentier's avatar Justin Carpentier Committed by GitHub
Browse files

Merge pull request #361 from jcarpent/devel

Improve compatibility of the lib + fix bug in potential energy
parents 8a832427 1f913f34
......@@ -61,19 +61,24 @@ OPTION (BUILD_UTILS "Build the utils" OFF)
OPTION (INITIALIZE_WITH_NAN "Initialize Eigen entries with NaN" OFF)
OPTION (BUILD_TESTS_WITH_HPP "Build geom tests and benchmarks with hpp to do comparisons" OFF)
OPTION (BUILD_PYTHON_INTERFACE "Build the python binding" ON)
OPTION (BUILD_WITH_COMMIT_VERSION "Build libraries by setting specific commit version" OFF)
IF (INITIALIZE_WITH_NAN)
MESSAGE (STATUS "Initialize with NaN all the Eigen entries.")
ADD_DEFINITIONS(-DEIGEN_INITIALIZE_MATRICES_BY_NAN)
ENDIF (INITIALIZE_WITH_NAN)
MACRO(TAG_LIBRARY_VERSION target)
SET_TARGET_PROPERTIES(${target} PROPERTIES SOVERSION ${PROJECT_VERSION})
ENDMACRO(TAG_LIBRARY_VERSION)
# ----------------------------------------------------
# --- DEPENDANCIES -----------------------------------
# ----------------------------------------------------
ADD_REQUIRED_DEPENDENCY("eigen3 >= 3.0.5")
ADD_OPTIONAL_DEPENDENCY("metapod >= 1.0.7")
ADD_OPTIONAL_DEPENDENCY("urdfdom >= 0.2.0")
ADD_OPTIONAL_DEPENDENCY("lua5.1")
ADD_OPTIONAL_DEPENDENCY("lua5.2")
ADD_OPTIONAL_DEPENDENCY("hpp-fcl >= 0.4.2")
# Spetcial care of Eigen3 greater than 3.2.10
......@@ -96,6 +101,21 @@ IF(URDFDOM_FOUND)
ENDIF(${URDFDOM_VERSION} VERSION_LESS "0.3.0")
ENDIF(URDFDOM_FOUND)
# Special care of lua which can be of versions 5.1 or 5.2
# Priority is set to lua5.2
IF(LUA5_2_FOUND)
SET(LUA5_FOUND TRUE)
SET(LUA5_PACKAGE "lua5.2")
ADD_DEFINITIONS(-DLUA_VERSION_GREATER_5_2)
PKG_CONFIG_APPEND_CFLAGS("-DLUA_VERSION_GREATER_5_2")
ELSEIF(LUA5_2_FOUND)
ADD_OPTIONAL_DEPENDENCY("lua5.1")
IF(LUA5_1_FOUND)
SET(LUA5_FOUND TRUE)
SET(LUA5_PACKAGE "lua5.1")
ENDIF(LUA5_1_FOUND)
ENDIF(LUA5_2_FOUND)
SET(BOOST_REQUIERED_COMPONENTS filesystem system)
SET(BOOST_BUILD_COMPONENTS unit_test_framework)
SET(BOOST_OPTIONAL_COMPONENTS "")
......@@ -241,15 +261,15 @@ IF(HPP_FCL_FOUND)
LIST(APPEND CFLAGS_DEPENDENCIES "-DWITH_HPP_FCL")
ENDIF(HPP_FCL_FOUND)
IF(LUA5_1_FOUND)
IF(LUA5_FOUND)
LIST(APPEND ${PROJECT_NAME}_PARSERS_HEADERS
parsers/lua.hpp
parsers/lua/lua_tables.hpp
)
ADD_DEFINITIONS(-DWITH_LUA)
LIST(APPEND CFLAGS_DEPENDENCIES "-DWITH_LUA")
ENDIF(LUA5_1_FOUND)
ADD_DEFINITIONS(-DWITH_LUA5)
LIST(APPEND CFLAGS_DEPENDENCIES "-DWITH_LUA5")
ENDIF(LUA5_FOUND)
SET(HEADERS
${${PROJECT_NAME}_MATH_HEADERS}
......
......@@ -146,6 +146,9 @@ SET(${PYWRAP}_SOURCES ${${PROJECT_NAME}_PYTHON_SOURCES} ${${PROJECT_NAME}_PARSER
SET(${PYWRAP}_HEADERS ${${PROJECT_NAME}_PYTHON_HEADERS} ${${PROJECT_NAME}_PARSER_PYTHON_HEADERS})
ADD_LIBRARY(${PYWRAP} SHARED ${${PYWRAP}_SOURCES} ${${PYWRAP}_HEADERS})
IF(BUILD_WITH_COMMIT_VERSION)
TAG_LIBRARY_VERSION(${PYWRAP})
ENDIF(BUILD_WITH_COMMIT_VERSION)
ADD_HEADER_GROUP(${PYWRAP}_HEADERS)
ADD_SOURCE_GROUP(${PYWRAP}_SOURCES)
PKG_CONFIG_USE_DEPENDENCY(${PYWRAP} eigenpy)
......@@ -165,9 +168,7 @@ ENDIF(APPLE)
SET_TARGET_PROPERTIES(${PYWRAP} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bindings/python/${PROJECT_NAME}")
INSTALL(FILES
"${CMAKE_BINARY_DIR}/bindings/python/${PROJECT_NAME}/lib${PYWRAP}.so"
DESTINATION ${${PYWRAP}_INSTALL_DIR})
INSTALL(TARGETS ${PYWRAP} DESTINATION ${${PYWRAP}_INSTALL_DIR})
# --- INSTALL SCRIPTS
SET(PYTHON_FILES
......
......@@ -32,7 +32,7 @@ namespace se3
"Update kinematics (bool)"),
"Computes the kinematic energy of the model for the "
"given joint configuration and velocity and stores the result "
" in data.kinetic_energy. By default, the kinematics of model is updated.");
"in data.kinetic_energy. By default, the first order kinematic quantities of the model are updated.");
bp::def("potentialEnergy",potentialEnergy,
bp::args("Model","Data",
......@@ -40,7 +40,7 @@ namespace se3
"Update kinematics (bool)"),
"Computes the potential energy of the model for the "
"given the joint configuration and stores the result "
" in data.potential_energy. By default, the kinematics of model is updated.");
"in data.potential_energy. By default, the first order kinematic quantities of the model are updated.");
}
} // namespace python
......
......@@ -30,9 +30,9 @@
#include "pinocchio/bindings/python/multibody/geometry-model.hpp"
#include "pinocchio/bindings/python/multibody/geometry-data.hpp"
#ifdef WITH_LUA
#ifdef WITH_LUA5
#include "pinocchio/parsers/lua.hpp"
#endif // #ifdef WITH_LUA
#endif // #ifdef WITH_LUA5
#include "pinocchio/parsers/srdf.hpp"
......@@ -110,7 +110,7 @@ namespace se3
#endif // #ifdef WITH_HPP_FCL
#endif // #ifdef WITH_URDFDOM
#ifdef WITH_LUA
#ifdef WITH_LUA5
static Model buildModelFromLua(const std::string & filename,
bool ff,
bool verbose
......@@ -120,7 +120,7 @@ namespace se3
model = se3::lua::buildModel (filename, ff, verbose);
return model;
}
#endif // #ifdef WITH_LUA
#endif // #ifdef WITH_LUA5
static Eigen::VectorXd getNeutralConfigurationFromSrdf(Model & model,
const std::string & filename,
......@@ -176,14 +176,14 @@ namespace se3
#endif // #ifdef WITH_HPP_FCL
#endif // #ifdef WITH_URDFDOM
#ifdef WITH_LUA
#ifdef WITH_LUA5
bp::def("buildModelFromLua",buildModelFromLua,
bp::args("Filename (string)",
"Free flyer (bool, false for a fixed robot)",
"Verbose option "),
"Parse the urdf file given in input and return a proper pinocchio model "
"(remember to create the corresponding data structure).");
#endif // #ifdef WITH_LUA
#endif // #ifdef WITH_LUA5
bp::def("getNeutralConfigurationFromSrdf",getNeutralConfigurationFromSrdf,
// static_cast <ModelHandler (*) ( const std::string &, bool)> (&ParsersPythonVisitor::getNeutralConfigurationFromSrdf),
......
......@@ -61,12 +61,12 @@ IF(URDFDOM_FOUND)
)
ENDIF(URDFDOM_FOUND)
IF(LUA5_1_FOUND)
IF(LUA5_FOUND)
LIST(APPEND ${PROJECT_NAME}_PARSERS_SOURCES
parsers/lua/lua_tables.cpp
parsers/lua.cpp
)
ENDIF(LUA5_1_FOUND)
ENDIF(LUA5_FOUND)
SET(${PROJECT_NAME}_SOURCES
${${PROJECT_NAME}_MULTIBODY_SOURCES}
......@@ -75,8 +75,11 @@ SET(${PROJECT_NAME}_SOURCES
IF(UNIX)
# Create target libpinocchio.so
ADD_LIBRARY ( ${PROJECT_NAME} SHARED ${HEADERS} ${${PROJECT_NAME}_SOURCES} )
SET_TARGET_PROPERTIES( ${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX)
ADD_LIBRARY(${PROJECT_NAME} SHARED ${HEADERS} ${${PROJECT_NAME}_SOURCES})
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX)
IF(BUILD_WITH_COMMIT_VERSION)
TAG_LIBRARY_VERSION(${PROJECT_NAME})
ENDIF(BUILD_WITH_COMMIT_VERSION)
PKG_CONFIG_USE_DEPENDENCY(${PROJECT_NAME} eigen3)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY})
......@@ -88,9 +91,9 @@ IF(UNIX)
PKG_CONFIG_USE_DEPENDENCY(${PROJECT_NAME} hpp-fcl)
ENDIF(HPP_FCL_FOUND)
IF(LUA5_1_FOUND)
PKG_CONFIG_USE_DEPENDENCY(${PROJECT_NAME} lua5.1)
ENDIF(LUA5_1_FOUND)
IF(LUA5_FOUND)
PKG_CONFIG_USE_DEPENDENCY(${PROJECT_NAME} ${LUA5_PACKAGE})
ENDIF(LUA5_FOUND)
ADD_HEADER_GROUP(HEADERS)
ADD_SOURCE_GROUP(${PROJECT_NAME}_SOURCES)
......
......@@ -99,7 +99,7 @@ namespace se3
for(Model::JointIndex i=1;i<(Model::JointIndex)(model.njoints);++i)
{
com_global = data.oMi[i].translation() + data.oMi[i].rotation() * model.inertias[i].lever();
data.potential_energy += model.inertias[i].mass() * com_global.dot(g);
data.potential_energy -= model.inertias[i].mass() * com_global.dot(g);
}
return data.potential_energy;
......
......@@ -109,8 +109,16 @@ namespace se3
template<typename Scalar, int Options>
inline std::ostream & operator << (std::ostream& os, const FrameTpl<Scalar,Options> & f)
{
os << "Frame name:" << f.name << "paired to (parent joint/ previous frame)" << "(" <<f.parent << "/" << f.previousFrame << ")"<< std::endl;
os << "with relative placement wrt parent joint:\n" << f.placement << std::endl;
os
<< "Frame name: "
<< f.name
<< " paired to (parent joint/ previous frame)"
<< "(" <<f.parent << "/" << f.previousFrame << ")"
<< std::endl
<< "with relative placement wrt parent joint:\n" <<
f.placement
<< std::endl;
return os;
}
......
......@@ -534,8 +534,13 @@ size_t LuaTableNode::length()
{
size_t result = 0;
if (stackQueryValue()) {
if (stackQueryValue())
{
#ifdef LUA_VERSION_GREATER_5_2
result = lua_rawlen(luaTable->L, -1);
#else
result = lua_objlen(luaTable->L, -1);
#endif
}
stackRestore();
......@@ -694,7 +699,11 @@ int LuaTable::length()
}
size_t result = 0;
#ifdef LUA_VERSION_GREATER_5_2
result = lua_rawlen(L, -1);
#else
result = lua_objlen(L, -1);
#endif
return (int)result;
}
......
......@@ -97,10 +97,10 @@ IF(URDFDOM_FOUND)
ENDIF(HPP_FCL_FOUND)
ENDIF(URDFDOM_FOUND)
IF(LUA5_1_FOUND)
ADD_UNIT_TEST(lua "eigen3;lua5.1")
IF(LUA5_FOUND)
ADD_UNIT_TEST(lua "eigen3;${LUA5_PACKAGE}")
ADD_TEST_CFLAGS(lua '-DPINOCCHIO_SOURCE_DIR=\\\"${${PROJECT_NAME}_SOURCE_DIR}\\\"')
ENDIF(LUA5_1_FOUND)
ENDIF(LUA5_FOUND)
IF(BUILD_PYTHON_INTERFACE)
IF (BUILD_UNIT_TESTS)
......
......@@ -188,7 +188,7 @@ BOOST_AUTO_TEST_CASE ( test_pinocchio_Sym3 )
Symmetric3 S(M);
for(int i=0;i<3;++i)
for(int j=0;j<3;++j)
BOOST_CHECK_EQUAL(S(i,j), M(i,j) );
BOOST_CHECK_SMALL(S(i,j) - M(i,j), Eigen::NumTraits<double>::dummy_precision());
}
}
......
......@@ -25,7 +25,7 @@
#include "pinocchio/parsers/urdf.hpp"
#endif
#ifdef WITH_LUA
#ifdef WITH_LUA5
#include "pinocchio/parsers/lua.hpp"
#endif
......@@ -73,7 +73,7 @@ int main(int argc, char *argv[])
#endif
break;
case se3::LUA:
#ifdef WITH_LUA
#ifdef WITH_LUA5
model = se3::lua::buildModel(filename, false, verbose);
#else
std::cerr << "It seems that the LUA module has not been found during the Cmake process." << std::endl;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment