print_model_node.cpp
Go to the documentation of this file.
00001 
00031 #include <ros/ros.h>
00032 #include <urdf_traverser/UrdfTraverser.h>
00033 #include <urdf_traverser/PrintModel.h>
00034 #include <urdf_traverser/DependencyOrderedJoints.h>
00035 
00036 #include <string>
00037 
00038 using urdf_traverser::UrdfTraverser;
00039 
00040 int main(int argc, char **argv)
00041 {
00042     ros::init(argc, argv, "urdf_traverser_join_fixed_links", ros::init_options::AnonymousName);
00043     ros::NodeHandle priv("~");
00044 
00045     if (argc < 2)
00046     {
00047         ROS_INFO_STREAM("Usage: " << argv[0] << " <input-file> [<from-link>]");
00048         ROS_INFO_STREAM("If <from-link> is specified, the URDF is processed from this link down instead of the root link.");
00049         return 0;
00050     }
00051 
00052     std::string inputFile = argv[1];
00053     std::string fromLink;
00054 
00055     if (argc > 2)
00056     {
00057         fromLink = argv[2];
00058     }
00059 
00060     ROS_INFO_STREAM("Traversing model from file " << inputFile << "...");
00061     if (!fromLink.empty()) ROS_INFO_STREAM("Starting from link " << fromLink);
00062 
00063 
00064     ROS_INFO("Loading file...");
00065     UrdfTraverser traverser;
00066     if (!traverser.loadModelFromFile(inputFile))
00067     {
00068         ROS_ERROR_STREAM("Could not load file " << inputFile);
00069         return 0;
00070     }
00071 
00072     bool verbose = true;
00073 
00074     /*
00075     ROS_INFO("###### MODEL #####");
00076     traverser.printModel(verbose);
00077     */
00078     ROS_INFO("###### MODEL #####");
00079     traverser.printModel(verbose);
00080 
00081     ROS_INFO("###### JOINT NAMES #####");
00082     traverser.printJointNames(fromLink);
00083 
00084     /*    std::vector<urdf_traverser::JointPtr> depOrdered;
00085         if (!urdf_traverser::getDependencyOrderedJoints(traverser,depOrdered, fromLink, true, false))
00086         {
00087             ROS_ERROR("Could not get dependency ordered joints");
00088         }
00089         else
00090         {
00091             ROS_INFO("Dependency ordered joints:");
00092         }
00093         for (std::vector<urdf_traverser::JointPtr>::iterator it=depOrdered.begin(); it!=depOrdered.end(); ++it)
00094         {
00095             urdf_traverser::JointPtr j=*it;
00096             std::cout<<j->name<<std::endl;
00097         }
00098     */
00099     return 0;
00100 }
00101 
00102 


urdf_traverser
Author(s): Jennifer Buehler
autogenerated on Fri Mar 1 2019 03:38:07