MJCF: support for angle units in <compile angle="...">, kill two stdout messages

This commit is contained in:
Oleg Klimov
2017-03-22 21:05:00 +03:00
parent c1e42daa0f
commit 634f4cfdbc
3 changed files with 29 additions and 10 deletions

View File

@@ -143,6 +143,7 @@ struct BulletMJCFImporterInternalData
//<compiler angle="radian" meshdir="mesh/" texturedir="texture/"/> //<compiler angle="radian" meshdir="mesh/" texturedir="texture/"/>
std::string m_meshDir; std::string m_meshDir;
std::string m_textureDir; std::string m_textureDir;
std::string m_angleUnits;
int m_activeModel; int m_activeModel;
@@ -213,6 +214,8 @@ struct BulletMJCFImporterInternalData
{ {
m_textureDir = textureDirStr; m_textureDir = textureDirStr;
} }
const char* angle = root_xml->Attribute("angle");
m_angleUnits = angle ? angle : "degree"; // degrees by default, http://www.mujoco.org/book/modeling.html#compiler
#if 0 #if 0
for (TiXmlElement* child_xml = root_xml->FirstChildElement() ; child_xml ; child_xml = child_xml->NextSiblingElement()) for (TiXmlElement* child_xml = root_xml->FirstChildElement() ; child_xml ; child_xml = child_xml->NextSiblingElement())
{ {
@@ -406,7 +409,7 @@ struct BulletMJCFImporterInternalData
isLimited = true; isLimited = true;
//parse the 'range' field //parse the 'range' field
btArray<std::string> pieces; btArray<std::string> pieces;
btArray<float> sizes; btArray<float> limits;
btAlignedObjectArray<std::string> strArray; btAlignedObjectArray<std::string> strArray;
urdfIsAnyOf(" ", strArray); urdfIsAnyOf(" ", strArray);
urdfStringSplit(pieces, rangeStr, strArray); urdfStringSplit(pieces, rangeStr, strArray);
@@ -414,17 +417,28 @@ struct BulletMJCFImporterInternalData
{ {
if (!pieces[i].empty()) if (!pieces[i].empty())
{ {
sizes.push_back(urdfLexicalCast<double>(pieces[i].c_str())); limits.push_back(urdfLexicalCast<double>(pieces[i].c_str()));
} }
} }
if (sizes.size()==2) bool success = false;
if (limits.size()==2)
{ {
// TODO angle units are in "<compiler angle="degree" inertiafromgeom="true"/> if (m_angleUnits=="degree")
range[0] = sizes[0] * B3_PI / 180; {
range[1] = sizes[1] * B3_PI / 180; range[0] = limits[0] * B3_PI / 180;
} else range[1] = limits[1] * B3_PI / 180;
success = true;
}
else if (m_angleUnits=="radian")
{
range[0] = limits[0];
range[1] = limits[1];
success = true;
}
}
if (!success)
{ {
logger->reportWarning("Expected range[2] in joint with limits"); logger->reportWarning( (sourceFileLocation(link_xml) + ": cannot parse 'range' attribute (units='" + m_angleUnits + "'')").c_str() );
} }
} }

View File

@@ -1398,8 +1398,8 @@ bool PhysicsServerCommandProcessor::processImportedObjects(const char* fileName,
//todo: move these internal API called inside the 'ConvertURDF2Bullet' call, hidden from the user //todo: move these internal API called inside the 'ConvertURDF2Bullet' call, hidden from the user
int rootLinkIndex = u2b.getRootLinkIndex(); //int rootLinkIndex = u2b.getRootLinkIndex();
b3Printf("urdf root link index = %d\n",rootLinkIndex); //b3Printf("urdf root link index = %d\n",rootLinkIndex);
MyMultiBodyCreator creation(m_data->m_guiHelper); MyMultiBodyCreator creation(m_data->m_guiHelper);
u2b.getRootTransformInWorld(rootTrans); u2b.getRootTransformInWorld(rootTrans);

View File

@@ -414,6 +414,11 @@ void convertURDFToVisualShape(const UrdfShape* visual, const char* urdfPathPrefi
break; break;
} // case mesh } // case mesh
case URDF_GEOM_PLANE:
// TODO: plane in tiny renderer
// TODO: export visualShapeOut for external render
break;
default: default:
{ {
b3Warning("TinyRenderer: unknown visual geometry type %i\n", visual->m_geometry.m_type); b3Warning("TinyRenderer: unknown visual geometry type %i\n", visual->m_geometry.m_type);