Skip to content

Commit

Permalink
parse the scale attribute of the mesh element if it exists
Browse files Browse the repository at this point in the history
For example, the crazyflie/crazyflie.urdf uses the scale attribute.
Handling for scale must already exist in the matlab parser but wasn't
working in the cpp parser.  This adds support by introducing a scale
member variable to DrakeShapes::Mesh.
  • Loading branch information
patmarion committed Aug 10, 2015
1 parent e3fdc41 commit 1ec9212
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
9 changes: 8 additions & 1 deletion drake/systems/plants/RigidBodyManipulatorURDF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,15 @@ bool parseGeometry(TiXmlElement* node, const map<string,string>& package_map, co
}
string filename(attr);
string resolved_filename = resolveFilename(filename, package_map, root_dir);
element.setGeometry(DrakeShapes::Mesh(filename, resolved_filename));
DrakeShapes::Mesh mesh(filename, resolved_filename);

attr = shape_node->Attribute("scale");
if (attr) {
stringstream s(attr);
s >> mesh.scale;
}

element.setGeometry(mesh);
} else {
cerr << "Warning: geometry element has an unknown type and will be ignored." << endl;
}
Expand Down
4 changes: 2 additions & 2 deletions drake/systems/plants/shapes/Geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ namespace DrakeShapes
}

Mesh::Mesh(const string& filename)
: Geometry(MESH), filename(filename)
: Geometry(MESH), scale(1.0), filename(filename)
{}

Mesh::Mesh(const string& filename, const string& resolved_filename)
: Geometry(MESH), filename(filename), resolved_filename(resolved_filename)
: Geometry(MESH), scale(1.0), filename(filename), resolved_filename(resolved_filename)
{}

bool Mesh::extractMeshVertices(Matrix3Xd& vertex_coordinates) const
Expand Down
1 change: 1 addition & 0 deletions drake/systems/plants/shapes/Geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ namespace DrakeShapes
virtual void getPoints(Eigen::Matrix3Xd &points) const;
virtual void getBoundingBoxPoints(Eigen::Matrix3Xd &points) const;

double scale;
std::string filename;
std::string resolved_filename;
bool extractMeshVertices(Eigen::Matrix3Xd& vertex_coordinates) const;
Expand Down

0 comments on commit 1ec9212

Please sign in to comment.