ScaleModel.cpp
Go to the documentation of this file.
00001 
00031 #include <urdf_transform/ScaleModel.h>
00032 #include <urdf_traverser/UrdfTraverser.h>
00033 #include <urdf_traverser/Functions.h>
00034 #include <ros/ros.h>
00035 
00036 using urdf_traverser::UrdfTraverser;
00037 
00041 int scaleModelFunc(urdf_traverser::RecursionParamsPtr& p)
00042 {
00043     urdf_traverser::FactorRecursionParamsPtr param =
00044         baselib_binding_ns::dynamic_pointer_cast<urdf_traverser::FactorRecursionParams>(p);
00045     if (!param)
00046     {
00047         ROS_ERROR("Wrong recursion parameter type");
00048         return -1;
00049     }
00050 
00051     urdf_traverser::LinkPtr link = param->getLink();
00052     if (!link)
00053     {
00054         ROS_ERROR("Recursion parameter must have initialised link!");
00055         return -1;
00056     }
00057     urdf_traverser::scaleTranslation(link, param->factor);
00058     urdf_traverser::JointPtr pjoint = link->parent_joint;
00059     if (pjoint)
00060     {
00061         urdf_traverser::scaleTranslation(pjoint, param->factor);
00062     }
00063     return 1;
00064 }
00065 
00066 bool urdf_transform::scaleModel(UrdfTraverser& traverser, const std::string& fromLink, double scale_factor)
00067 {
00068     // do one call of scaleModel(RecursionParams) for the root link
00069     urdf_traverser::RecursionParamsPtr p(new urdf_traverser::FactorRecursionParams(scale_factor));
00070     return traverser.traverseTreeTopDown(fromLink, boost::bind(&scaleModelFunc, _1), p, true) == 1;
00071 }
00072 
00073 bool urdf_transform::scaleModel(UrdfTraverser& traverser, double scale_factor)
00074 {
00075     std::string root_link = traverser.getRootLinkName();
00076     return scaleModel(traverser, root_link, scale_factor);
00077 }
00078 
00079 


urdf_transform
Author(s): Jennifer Buehler
autogenerated on Fri Mar 1 2019 03:38:10