control_cost_projection.cpp
Go to the documentation of this file.
1 
29 #include <ros/console.h>
31 #include <stomp_core/utils.h>
32 
34 
35 
36 namespace stomp_moveit
37 {
38 namespace update_filters
39 {
40 
41 double DEFAULT_TIME_STEP = 1.0;
42 
43 
44 ControlCostProjection::ControlCostProjection():
45  name_("ControlCostProjectionMatrix"),
46  num_timesteps_(0)
47 
48 {
49 
50 }
51 
52 ControlCostProjection::~ControlCostProjection()
53 {
54  // TODO Auto-generated destructor stub
55 }
56 
57 bool ControlCostProjection::initialize(moveit::core::RobotModelConstPtr robot_model_ptr,
58  const std::string& group_name,const XmlRpc::XmlRpcValue& config)
59 {
60  robot_model_ = robot_model_ptr;
61  group_name_ = group_name;
62 
63  if(!configure(config))
64  {
65  return false;
66  }
67 
68  return true;
69 }
70 
71 bool ControlCostProjection::configure(const XmlRpc::XmlRpcValue& config)
72 {
73  return true;
74 }
75 
76 bool ControlCostProjection::setMotionPlanRequest(const planning_scene::PlanningSceneConstPtr& planning_scene,
77  const moveit_msgs::MotionPlanRequest &req,
78  const stomp_core::StompConfiguration &config,
79  moveit_msgs::MoveItErrorCodes& error_code)
80 {
81 
82  num_timesteps_ = config.num_timesteps;
83  stomp_core::generateSmoothingMatrix(num_timesteps_,DEFAULT_TIME_STEP,projection_matrix_M_);
84 
85  // zeroing out first and last rows
86  projection_matrix_M_.topRows(1) = Eigen::VectorXd::Zero(num_timesteps_).transpose();
87  projection_matrix_M_(0,0) = 1.0;
88  projection_matrix_M_.bottomRows(1) = Eigen::VectorXd::Zero(num_timesteps_).transpose();
89  projection_matrix_M_(num_timesteps_ -1 ,num_timesteps_ -1 ) = 1;
90 
91  error_code.val = error_code.SUCCESS;
92  return true;
93 }
94 
95 bool ControlCostProjection::filter(std::size_t start_timestep,std::size_t num_timesteps,int iteration_number,
96  const Eigen::MatrixXd& parameters,
97  Eigen::MatrixXd& updates,
98  bool& filtered)
99 {
100 
101  for(auto d = 0u; d < updates.rows();d++)
102  {
103  updates.row(d).transpose() = projection_matrix_M_ * (updates.row(d).transpose());
104  }
105 
106  filtered = true;
107 
108  return true;
109 }
110 
111 } /* namespace update_filters */
112 } /* namespace stomp_moveit */
d
Interface class which applies filtering methods to the update parameters before it is added onto the ...
PLUGINLIB_EXPORT_CLASS(test_moveit_controller_manager::TestMoveItControllerManager, moveit_controller_manager::MoveItControllerManager)
This defines a control cost projection update filter.
virtual bool configure(const XmlRpc::XmlRpcValue &config) override
Sets internal members of the plugin from the configuration data.


stomp_moveit
Author(s): Jorge Nicho
autogenerated on Fri May 8 2020 03:35:47