Commit 1d00bff4 authored by Joseph Mirabel's avatar Joseph Mirabel Committed by Joseph Mirabel
Browse files

Add function to make robots from URDF in unittest

* hpp::pinocchio::unittest::makeDevice
parent 35bff21f
......@@ -57,9 +57,11 @@ ADD_REQUIRED_DEPENDENCY("hpp-util >= 3")
ADD_REQUIRED_DEPENDENCY("hpp-fcl >= 0.4.2")
ADD_REQUIRED_DEPENDENCY("pinocchio >= 1.1")
ADD_REQUIRED_DEPENDENCY("resource_retriever")
ADD_OPTIONAL_DEPENDENCY("hpp-model >= 3")
ADD_OPTIONAL_DEPENDENCY("hpp-model-urdf >= 3")
ADD_OPTIONAL_DEPENDENCY("romeo_description >= 0.2")
ADD_OPTIONAL_DEPENDENCY("hpp_environments")
ADD_DEFINITIONS(-DWITH_URDFDOM)
ADD_DEFINITIONS(-DWITH_HPP_FCL)
......
......@@ -27,6 +27,16 @@ namespace hpp {
bool usingFF = true,
Device::Computation_t compFlags = (Device::Computation_t) (Device::JOINT_POSITION | Device::JACOBIAN)
);
namespace unittest {
enum TestDeviceType {
HumanoidRomeo,
CarLike,
ManipulatorArm2
};
DevicePtr_t makeDevice (TestDeviceType type);
}
} // namespace pinocchio
} // namespace hpp
#endif // HPP_PINOCCHIO_SIMPLE_DEVICE_HH
......@@ -50,6 +50,12 @@ ADD_LIBRARY(${LIBRARY_NAME}
IF(HPP_MODEL_FOUND)
SET_PROPERTY(TARGET ${LIBRARY_NAME} APPEND_STRING PROPERTY COMPILE_FLAGS " -DROMEO_MODEL_DIR=\\\"${ROMEO_DESCRIPTION_DATAROOTDIR}\\\"")
ENDIF(HPP_MODEL_FOUND)
IF(ROMEO_DESCRIPTION_FOUND)
SET_PROPERTY(TARGET ${LIBRARY_NAME} APPEND_STRING PROPERTY COMPILE_FLAGS " -DROMEO_DESCRIPTION")
ENDIF(ROMEO_DESCRIPTION_FOUND)
IF(HPP_ENVIRONMENTS_FOUND)
SET_PROPERTY(TARGET ${LIBRARY_NAME} APPEND_STRING PROPERTY COMPILE_FLAGS " -DHPP_ENVIRONMENTS")
ENDIF(HPP_ENVIRONMENTS_FOUND)
PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} assimp)
PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} hpp-util)
......
......@@ -18,6 +18,10 @@
# include <pinocchio/parsers/sample-models.hpp>
# include <hpp/pinocchio/device.hh>
# include <hpp/pinocchio/humanoid-robot.hh>
# include <hpp/pinocchio/urdf/util.hh>
namespace hpp {
namespace pinocchio {
DevicePtr_t humanoidSimple(
......@@ -41,5 +45,49 @@ namespace hpp {
robot->model().upperPositionLimit.segment<4>(3).setConstant( 1.01);
return robot;
}
namespace unittest {
DevicePtr_t makeDevice (TestDeviceType type)
{
switch (type) {
#ifdef HPP_ENVIRONMENTS
case CarLike:
{
DevicePtr_t robot = Device::create("carlike");
urdf::loadRobotModel (robot, "planar", "hpp_environments", "buggy", "", "");
robot->model().lowerPositionLimit.head<2>().setConstant(-1);
robot->model().upperPositionLimit.head<2>().setOnes();
return robot;
}
case ManipulatorArm2:
{
DevicePtr_t robot = Device::create("arm");
urdf::loadRobotModel (robot, "anchor", "hpp_environments", "tests/baxter", "_simple", "_simple");
return robot;
}
#else
case CarLike:
case ManipulatorArm2:
throw std::invalid_argument("hpp-pinocchio was compiled without HPP_ENVIRONMENTS");
#endif
break;
case HumanoidRomeo:
#ifdef ROMEO_DESCRIPTION
{
HumanoidRobotPtr_t robot = HumanoidRobot::create("romeo");
urdf::loadHumanoidModel (robot, "freeflyer", "romeo_description", "romeo", "_small", "_small");
robot->model().lowerPositionLimit.head<3>().setConstant(-1);
robot->model().upperPositionLimit.head<3>().setOnes();
return robot;
}
#else
throw std::invalid_argument("hpp-pinocchio was compiled without ROMEO_DESCRIPTION");
#endif
break;
default:
throw std::invalid_argument("Unknown robot type.");
}
}
}
} // namespace pinocchio
} // namespace hpp
Supports Markdown
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