Thanks fergs. It was actually pretty easy once I looked at the geometric_shapes package (motion_planning_common stack - version 3.0 or newer). I copied code from 2 different locations to accomplish the 2 things I listed above.
bool SBPLCollisionSpace::getBoundingCylinderOfMesh(std::string mesh_file, shapes::Shape &mesh, bodies::BoundingCylinder &cyl)
{
bool retval = false;
if (!mesh_file.empty())
{
resource_retriever::Retriever retriever;
resource_retriever::MemoryResource res;
bool ok = true;
try
{
res = retriever.get(mesh_file);
}
catch (resource_retriever::Exception& e)
{
ROS_ERROR("%s", e.what());
ok = false;
}
if (ok)
{
if (res.size == 0)
ROS_WARN("Retrieved empty mesh for resource '%s'", mesh_file.c_str());
else
{
mesh = shapes::createMeshFromBinaryStlData(reinterpret_cast<char*>(res.data.get()), res.size);
if (mesh == NULL)
ROS_ERROR("Failed to load mesh '%s'", mesh_file.c_str());
else
retval = true;
}
}
}
else
ROS_WARN("Empty mesh filename");
if(retval)
{
const bodies::Body *body=new bodies::ConvexMesh(mesh);
body->computeBoundingCylinder(cyl);
ROS_INFO("Bounding cylinder has radius: %0.3f length: %0.3f", cyl.radius, cyl.length);
}
return retval;
}