Skip to content

Commit

Permalink
fix testConstraintConstructor and testApproximateIK
Browse files Browse the repository at this point in the history
  • Loading branch information
RussTedrake committed Feb 24, 2015
1 parent 8694d59 commit 40f74fa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 62 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,14 @@ examples/IRB140/urdf/meshes/link3.wrl
examples/IRB140/urdf/meshes/link4.wrl
examples/IRB140/urdf/meshes/link5.wrl
examples/IRB140/urdf/meshes/link6.wrl
examples/PR2/pr2_description/meshes/base_v0/base.wrl
examples/PR2/pr2_description/meshes/base_v0/caster.wrl
examples/PR2/pr2_description/meshes/base_v0/wheel.wrl
examples/PR2/pr2_description/meshes/forearm_v0/wrist_roll.wrl
examples/PR2/pr2_description/meshes/head_v0/head_pan.wrl
examples/PR2/pr2_description/meshes/head_v0/head_tilt.wrl
examples/PR2/pr2_description/meshes/shoulder_v0/upper_arm_roll.wrl
examples/PR2/pr2_description/meshes/tilting_laser_v0/tilting_hokuyo.wrl
examples/PR2/pr2_description/meshes/torso_v0/torso_lift.wrl
examples/PR2/pr2_description/meshes/upper_arm_v0/forearm_roll.wrl
results_testRunning.mat
64 changes: 2 additions & 62 deletions systems/plants/URDFRigidBodyManipulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -778,69 +778,9 @@ bool URDFRigidBodyManipulator::addRobotFromURDFString(const string &xml_string,

}

compile();

// parse extra tags supported by drake

TiXmlDocument xml_doc;
xml_doc.Parse(xml_string.c_str()); // a little inefficient to parse a second time, but ok for now
// eventually, we'll probably just crop out the ros urdf parser completely.

TiXmlElement *robot_xml = xml_doc.FirstChildElement("robot");

// parse transmission elements
for (TiXmlElement* transmission_xml = robot_xml->FirstChildElement("transmission"); transmission_xml; transmission_xml = transmission_xml->NextSiblingElement("transmission"))
{
TiXmlElement* node = transmission_xml->FirstChildElement("joint");
if (!node) continue;

int _dofnum;
map<string, int>::const_iterator dn=findWithSuffix(dofname_to_dofnum,node->Attribute("name"));
if (dn == dofname_to_dofnum.end()) ROS_ERROR("can't find joint %s for transmission element. this shouldn't happen");
_dofnum = dn->second;
// cout << "adding actuator to joint " << node->Attribute("name") << " (dof: " << _dofnum << ")" << endl;
cout << "addRobotFromURDFString: got here" << endl;

node = transmission_xml->FirstChildElement("mechanicalReduction");
double gain = 1.0;
if (node) sscanf(node->Value(),"%lf",&gain);

VectorXd B_col = VectorXd::Zero(num_velocities);
B_col(_dofnum) = gain;

B.conservativeResize(num_velocities, B.cols()+1);
B.rightCols(1) = B_col;
}

for (TiXmlElement* loop_xml = robot_xml->FirstChildElement("loop_joint"); loop_xml; loop_xml = loop_xml->NextSiblingElement("loop_joint"))
{ // note: pushing this in without all of the surrounding drakeFunction logic just to get things moving. this one needs to be fast.
urdf::Vector3 pt;
TiXmlElement* node = loop_xml->FirstChildElement("link1");
int bodyA=-1,bodyB=-1;

string linkname = node->Attribute("link");
for (int i=0; i<num_bodies; i++)
if (linkname==bodies[i]->linkname) {
bodyA=i;
break;
}
if (bodyA<0) ROS_ERROR("couldn't find link %s referenced in loop joint",linkname.c_str());
pt.init(node->Attribute("xyz"));
Vector3d ptA; ptA << pt.x, pt.y, pt.z;

node = loop_xml->FirstChildElement("link2");
linkname = node->Attribute("link");
for (int i=0; i<num_bodies; i++)
if (linkname==bodies[i]->linkname) {
bodyB=i;
break;
}
if (bodyB<0) ROS_ERROR("couldn't find link %s referenced in loop joint",linkname.c_str());
pt.init(node->Attribute("xyz"));
Vector3d ptB; ptB << pt.x, pt.y, pt.z;

RigidBodyLoop l(bodies[bodyA],ptA,bodies[bodyB],ptB);
loops.push_back(l);
}
compile();

return true;
}
Expand Down

0 comments on commit 40f74fa

Please sign in to comment.