polynomial_smoother.cpp
Go to the documentation of this file.
00001 
00028 #include <ros/console.h>
00029 #include <Eigen/Geometry>
00030 #include <eigen_conversions/eigen_msg.h>
00031 #include <moveit/robot_state/robot_state.h>
00032 #include <moveit/robot_state/conversions.h>
00033 #include <pluginlib/class_list_macros.h>
00034 #include <stomp_moveit/update_filters/polynomial_smoother.h>
00035 #include <stomp_moveit/utils/polynomial.h>
00036 #include <XmlRpcException.h>
00037 
00038 PLUGINLIB_EXPORT_CLASS(stomp_moveit::update_filters::PolynomialSmoother,stomp_moveit::update_filters::StompUpdateFilter)
00039 
00040 namespace stomp_moveit
00041 {
00042 namespace update_filters
00043 {
00044 
00045 const double JOINT_LIMIT_MARGIN = 0.00001;
00046 
00047 PolynomialSmoother::PolynomialSmoother():
00048     name_("ExponentialSmoother")
00049 {
00050   // TODO Auto-generated constructor stub
00051 
00052 }
00053 
00054 PolynomialSmoother::~PolynomialSmoother()
00055 {
00056   // TODO Auto-generated destructor stub
00057 }
00058 
00059 bool PolynomialSmoother::initialize(moveit::core::RobotModelConstPtr robot_model_ptr,
00060                         const std::string& group_name,const XmlRpc::XmlRpcValue& config)
00061 {
00062   group_name_ = group_name;
00063   robot_model_ = robot_model_ptr;
00064 
00065   return configure(config);
00066 }
00067 
00068 bool PolynomialSmoother::configure(const XmlRpc::XmlRpcValue& config)
00069 {
00070   using namespace XmlRpc;
00071 
00072   try
00073   {
00074     XmlRpcValue params = config;
00075     poly_order_ = static_cast<int>(params["poly_order"]);
00076   }
00077   catch(XmlRpc::XmlRpcException& e)
00078   {
00079     ROS_ERROR("%s failed to load parameters, %s",getName().c_str(),e.getMessage().c_str());
00080     return false;
00081   }
00082 
00083   return true;
00084 }
00085 
00086 bool PolynomialSmoother::setMotionPlanRequest(const planning_scene::PlanningSceneConstPtr& planning_scene,
00087                  const moveit_msgs::MotionPlanRequest &req,
00088                  const stomp_core::StompConfiguration &config,
00089                  moveit_msgs::MoveItErrorCodes& error_code)
00090 {
00091   error_code.val = error_code.SUCCESS;
00092   return true;
00093 }
00094 
00095 bool PolynomialSmoother::filter(std::size_t start_timestep,
00096                     std::size_t num_timesteps,
00097                     int iteration_number,
00098                     const Eigen::MatrixXd& parameters,
00099                     Eigen::MatrixXd& updates,
00100                     bool& filtered)
00101 {
00102   using namespace Eigen;
00103   using namespace moveit::core;
00104   using namespace utils::polynomial;
00105 
00106   filtered = false;
00107   Eigen::MatrixXd parameters_updates = parameters + updates;
00108   if(applyPolynomialSmoothing(robot_model_,group_name_,parameters_updates,poly_order_,JOINT_LIMIT_MARGIN))
00109   {
00110     updates = parameters_updates - parameters;
00111     filtered = true;
00112   }
00113   else
00114   {
00115     ROS_ERROR("Unable to polynomial smooth trajectory!");
00116     return false;
00117   }
00118 
00119   return true;
00120 }
00121 
00122 
00123 } /* namespace update_filters */
00124 } /* namespace stomp_moveit */


stomp_moveit
Author(s): Jorge Nicho
autogenerated on Sat Jun 8 2019 19:24:01