Skip to content

Commit

Permalink
working commit: fixing wavefront meshes implementation in drake_urdf_…
Browse files Browse the repository at this point in the history
…renderer

git-svn-id: https://svn.csail.mit.edu/locomotion/robotlib/trunk@6470 c9849af7-e679-4ec6-a44e-fc146a885bd3
  • Loading branch information
russt committed Jul 3, 2013
1 parent c9e0885 commit 3132933
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,4 @@ util/test/debugMexTest_mexdebug.mat
*.class
tmp_w.mat
bin
drake.jar
12 changes: 6 additions & 6 deletions systems/plants/@RigidBodyManipulator/RigidBodyManipulator.m
Original file line number Diff line number Diff line change
Expand Up @@ -640,12 +640,12 @@ function drawKinematicTree(model)

function v = constructVisualizer(obj,options)
checkDirty(obj);
% try
% v = BotVisualizer(obj);
% catch ex
% warning(ex.identifier,ex.message);
v = RigidBodyWRLVisualizer(obj);
% end
try
v = BotVisualizer(obj);
catch ex
warning(ex.identifier,ex.message);
v = RigidBodyWRLVisualizer(obj);
end
end

function index = getActuatedJoints(model)
Expand Down
10 changes: 6 additions & 4 deletions systems/plants/urdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ URDFRigidBodyManipulator::URDFRigidBodyManipulator(boost::shared_ptr<urdf::Model
std::string ext = mypath.extension().native();
boost::to_lower(ext);

if (ext.compare(".dae")==0) {
if (ext.compare(".obj")==0) {
cout << "Loading mesh from " << fname << endl;
BotWavefrontModel* wavefront_model = bot_wavefront_model_create(fname.c_str());
if (!wavefront_model) {
cerr << "Error loading mesh: " << fname << endl;
Expand All @@ -194,15 +195,16 @@ URDFRigidBodyManipulator::URDFRigidBodyManipulator(boost::shared_ptr<urdf::Model
}
} else {
// try changing the extension to dae and loading
if ( boost::filesystem::exists( mypath.replace_extension(".dae") ) ) {
BotWavefrontModel* wavefront_model = bot_wavefront_model_create(mypath.replace_extension(".dae").native().c_str());
if ( boost::filesystem::exists( mypath.replace_extension(".obj") ) ) {
cout << "Loading mesh from " << mypath.replace_extension(".obj").native() << endl;
BotWavefrontModel* wavefront_model = bot_wavefront_model_create(mypath.replace_extension(".obj").native().c_str());
if (!wavefront_model) {
cerr << "Error loading mesh: " << fname << endl;
} else {
mesh_map.insert(make_pair(mesh->filename, wavefront_model));
}
} else {
cout << "Warning: Mesh " << mypath.native() << " ignored because it does not have extension .dae (nor can I find a juxtaposed file with a .dae extension)" << endl;
cout << "Warning: Mesh " << mypath.native() << " ignored because it does not have extension .obj (nor can I find a juxtaposed file with a .obj extension)" << endl;
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions systems/plants/viewer/drake_urdf_renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,11 @@ static void my_draw( BotViewer *viewer, BotRenderer *renderer )
boost::shared_ptr<urdf::Mesh> mesh(boost::dynamic_pointer_cast<urdf::Mesh>(vptr->geometry));
glScalef(mesh->scale.x,mesh->scale.y,mesh->scale.z);
map<string,BotWavefrontModel*>::iterator iter = self->model->mesh_map.find(mesh->filename);
bot_wavefront_model_gl_draw(iter->second);
// glmDraw(iter->second->glm_model, GLM_SMOOTH);
cout << "got here" << endl;
if (iter!= self->model->mesh_map.end()) {
bot_wavefront_model_gl_draw(iter->second);
// glmDraw(iter->second->glm_model, GLM_SMOOTH);
cout << "got here" << endl;
}
}
glPopMatrix();
}
Expand Down

0 comments on commit 3132933

Please sign in to comment.