Commit cb910e16 authored by Valenza Florian's avatar Valenza Florian
Browse files

[C++][Geom Parser] put default value to empty vector of string for user hint...

[C++][Geom Parser] put default value to empty vector of string for user hint directories. If user's hints and ROS_PACKAGE_PATH empty, then throw error. The function that parse ROS_PACKAGE_PATH doesn't throw errors anymore
parent 23631930
......@@ -81,23 +81,7 @@ namespace se3
*/
inline GeometryModel buildGeom(const Model & model,
const std::string & filename,
std::vector<std::string> & package_dirs);
/**
* @brief Build The GeometryModel from a URDF file. Search for meshes
* in the environment variable ROS_PACKAGE_PATH
*
* @param model The model of the robot, built with
* urdf::buildModel
* @param[in] filename The URDF complete (absolute) file path
* @param[in] root_joint If we added a root joint to the Model in addition
* to the urdf kinematic chain
*
* @return The GeometryModel associated to the urdf file and the Model
* given
*/
inline GeometryModel buildGeom(const Model & model,
const std::string & filename);
const std::vector<std::string> & package_dirs = std::vector<std::string>());
} // namespace urdf
......
......@@ -133,45 +133,25 @@ namespace se3
inline GeometryModel buildGeom(const Model & model,
const std::string & filename,
std::vector<std::string> & package_dirs)
const std::vector<std::string> & package_dirs)
{
GeometryModel model_geom(model);
try
{
appendRosPackagePaths(package_dirs);
}
catch (std::runtime_error & e)
{
std::cout << "ROS_PACKAGE_PATH environment variable is empty. Meshes may not be found when looking for geometry" << std::endl;
assert(!package_dirs.empty() && "You did not specify any package directory. Geometric parsing will crash" );
}
::urdf::ModelInterfacePtr urdfTree = ::urdf::parseURDFFile (filename);
parseTreeForGeom(urdfTree->getRoot(), model, model_geom, package_dirs);
return model_geom;
}
std::vector<std::string> hint_directories(package_dirs);
inline GeometryModel buildGeom(const Model & model,
const std::string & filename)
{
GeometryModel model_geom(model);
appendRosPackagePaths(hint_directories);
std::vector<std::string> package_dirs;
try
if(hint_directories.empty())
{
appendRosPackagePaths(package_dirs);
}
catch (std::runtime_error & e)
{
std::cout << "ROS_PACKAGE_PATH environment variable is empty. Meshes may not be found when looking for geometry" << std::endl;
assert(false && "You did not specify any package directory. Geometric parsing will crash" );
throw std::runtime_error("You did not specify any package directory and ROS_PACKAGE_PATH is empty. Geometric parsing will crash");
}
::urdf::ModelInterfacePtr urdfTree = ::urdf::parseURDFFile (filename);
parseTreeForGeom(urdfTree->getRoot(), model, model_geom, package_dirs);
parseTreeForGeom(urdfTree->getRoot(), model, model_geom, hint_directories);
return model_geom;
}
} // namespace urdf
} // namespace se3
......
......@@ -34,17 +34,13 @@ namespace se3
*
* @param[in][out] paths { The package directories where to search for meshes }
*/
void appendRosPackagePaths(std::vector<std::string> & package_dirs) throw (std::runtime_error)
void appendRosPackagePaths(std::vector<std::string> & package_dirs)
{
std::string delimiter = ":";
std::string policyStr = std::getenv("ROS_PACKAGE_PATH");
size_t lastOffset = 0;
if(policyStr.empty())
{
throw std::runtime_error("ROS_PACKAGE_PATH environment variable is empty");
}
while(true)
{
size_t offset = policyStr.find_first_of(delimiter, lastOffset);
......
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