Robowflex  v0.1
Making MoveIt Easy
robowflex::darts::IO Namespace Reference

Functions

void addPackage (const std::string &package)
 Add a ROS package to Dart's searchable index. Looks up package with rospack. More...
 
void addPackage (const std::string &package, const std::string &location)
 Add a ROS package to Dart's searchable index. More...
 
bool loadURDF (Robot &robot, const std::string &urdf)
 Loads a URDF at urdf into a robot. More...
 
std::string getPackageFile (const std::string &uri)
 Get the filename for a package URI using Dart's lookup. More...
 

Function Documentation

◆ addPackage() [1/2]

void robowflex::darts::IO::addPackage ( const std::string package)

Add a ROS package to Dart's searchable index. Looks up package with rospack.

Parameters
[in]packagePackage name

Definition at line 15 of file robowflex_dart/src/io.cpp.

16 {
17  const auto path = robowflex::IO::resolvePackage("package://" + package);
18  if (not path.empty())
19  addPackage(package, path);
20 }
std::string resolvePackage(const std::string &path)
Resolves package:// URLs to their canonical form. The path does not need to exist,...
void addPackage(const std::string &package)
Add a ROS package to Dart's searchable index. Looks up package with rospack.

◆ addPackage() [2/2]

void robowflex::darts::IO::addPackage ( const std::string package,
const std::string location 
)

Add a ROS package to Dart's searchable index.

Parameters
[in]packagePackage name
[in]locationDirectory of package

Definition at line 22 of file robowflex_dart/src/io.cpp.

23 {
24  URDF.addPackageDirectory(package, location);
25  PACKAGE.addPackageDirectory(package, location);
26 }
static dart::utils::PackageResourceRetriever PACKAGE
static dart::utils::DartLoader URDF

◆ getPackageFile()

std::string robowflex::darts::IO::getPackageFile ( const std::string uri)

Get the filename for a package URI using Dart's lookup.

Parameters
[in]uriURI to lookup.
Returns
Path to file.

Definition at line 51 of file robowflex_dart/src/io.cpp.

52 {
54  if (file.empty())
55  file = PACKAGE.getFilePath(uri);
56 
57  return file;
58 }
T empty(T... args)

◆ loadURDF()

bool robowflex::darts::IO::loadURDF ( Robot robot,
const std::string urdf 
)

Loads a URDF at urdf into a robot.

Parameters
[out]robotRobot to load URDF in.
[in]urdfURDF location.
Returns
True on success, false on failure.

Definition at line 28 of file robowflex_dart/src/io.cpp.

29 {
30  // Pre-load URDF and extract all relevant ROS packages
31  const auto &file = IO::getPackageFile(urdf);
32  const auto &text = robowflex::IO::loadXMLToString(file);
33 
34  const auto packages = robowflex::IO::findPackageURIs(text);
35  for (const auto &package : packages)
36  IO::addPackage(package);
37 
38  auto skeleton = URDF.parseSkeletonString(text, "");
39  if (not skeleton)
40  return false;
41 
42  skeleton->setSelfCollisionCheck(true);
43 
44  for (auto *joint : skeleton->getJoints())
45  joint->setPositionLimitEnforced(true);
46 
47  robot.setSkeleton(skeleton);
48  return true;
49 }
Functions for loading and animating robots in Blender.
std::set< std::string > findPackageURIs(const std::string &string)
Finds all package URIs within a string.
std::string loadXMLToString(const std::string &path)
Loads an XML or .xacro file to a string.
std::string getPackageFile(const std::string &uri)
Get the filename for a package URI using Dart's lookup.