|
From: <stu...@us...> - 2008-09-05 18:36:59
|
Revision: 3986
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=3986&view=rev
Author: stuglaser
Date: 2008-09-05 18:37:10 +0000 (Fri, 05 Sep 2008)
Log Message:
-----------
Searches the correct path for the robot's .xml description file.
Modified Paths:
--------------
pkg/trunk/drivers/simulator/gazebo_plugin/src/gazebo_actuators.cpp
pkg/trunk/robot_descriptions/wg_robot_description_parser/src/parser.cpp
Modified: pkg/trunk/drivers/simulator/gazebo_plugin/src/gazebo_actuators.cpp
===================================================================
--- pkg/trunk/drivers/simulator/gazebo_plugin/src/gazebo_actuators.cpp 2008-09-05 18:05:23 UTC (rev 3985)
+++ pkg/trunk/drivers/simulator/gazebo_plugin/src/gazebo_actuators.cpp 2008-09-05 18:37:10 UTC (rev 3986)
@@ -73,13 +73,16 @@
return;
}
- // TODO: should look for the file relative to the path of the world file.
- std::string filename = robot->GetString("filename", "", 1);
+ std::string filename = robot->GetFilename("filename", "", 1);
printf("Loading %s\n", filename.c_str());
TiXmlDocument doc(filename);
- doc.LoadFile();
- assert(doc.RootElement());
+ if (!doc.LoadFile())
+ {
+ fprintf(stderr, "Error: Could not load the gazebo actuators plugin's configuration file: %s\n",
+ filename.c_str());
+ abort();
+ }
urdf::normalizeXml(doc.RootElement());
// Pulls out the list of actuators used in the robot configuration.
Modified: pkg/trunk/robot_descriptions/wg_robot_description_parser/src/parser.cpp
===================================================================
--- pkg/trunk/robot_descriptions/wg_robot_description_parser/src/parser.cpp 2008-09-05 18:05:23 UTC (rev 3985)
+++ pkg/trunk/robot_descriptions/wg_robot_description_parser/src/parser.cpp 2008-09-05 18:37:10 UTC (rev 3986)
@@ -196,6 +196,10 @@
TiXmlElement *previous = NULL; // tracks the element before elt
+ //------------------------------------------------------------
+ // Zeroeth Pass
+
+ // - Replaces include elements with the desired file
while (elt)
{
if (elt->ValueStr() == std::string("include"))
@@ -243,7 +247,6 @@
// - Replaces insert_const_block elements with the corresponding xml tree.
// - Replaces const strings with the actual values.
// - Reduces mathematical expressions.
- // - Replaces include elements with the desired file
while (elt)
{
// Kills elt, if it's a const or const_block definition
@@ -270,30 +273,6 @@
elt = next_element(previous);
}
- // Replaces elt if it's an include tag.
- else if (elt->ValueStr() == std::string("include"))
- {
- std::string filename(elt->GetText());
-
- // FIXME: get path of current xml node and use relative path for includes
- std::string currentPath = getenv("MC_RESOURCE_PATH") ? getenv("MC_RESOURCE_PATH") : ".";
- if (currentPath!="") filename = (currentPath+"/")+filename;
-
- TiXmlDocument doc(filename);
- doc.LoadFile();
-
- if (!doc.RootElement())
- {
- fprintf(stderr, "Included file not found: %s\n", filename.c_str());
- elt->Parent()->RemoveChild(elt);
- }
- else
- {
- replaceReference(&elt, doc.RootElement()->FirstChild());
- }
-
- elt = next_element(previous);
- }
// Replaces the attributes of elt and the text inside elt if they
// have constants or expressions, and continues down the tree.
else
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|