Skip to content

Commit 68926e9

Browse files
committed
Format and visualize
1 parent e4a5474 commit 68926e9

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

doc/how_to_guides/planner_cost_functions/src/planner_cost_functions_main.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,17 @@ class Demo
186186
planning_component_->setStartStateToCurrentState();
187187

188188
// Set cost function
189-
planning_component_->setStateCostFunction(moveit::cost_functions::getClearanceCostFn());
189+
planning_component_->setStateCostFunction(
190+
[this, LOGGER](const moveit::core::RobotState& robot_state, const planning_interface::MotionPlanRequest& request,
191+
const planning_scene::PlanningSceneConstPtr& planning_scene) mutable {
192+
// Publish robot state
193+
// auto const ee_tip = robot_state.getJointModelGroup(PLANNING_GROUP)->getOnlyOneEndEffectorTip();
194+
// this->getVisualTools().publishSphere(robot_state.getGlobalLinkTransform(ee_tip), rviz_visual_tools::GREEN,
195+
// rviz_visual_tools::MEDIUM); this->getVisualTools().trigger();
196+
197+
auto clearance_cost_fn = moveit::cost_functions::getClearanceCostFn();
198+
return clearance_cost_fn(robot_state, request, planning_scene);
199+
});
190200

191201
auto plan_solution = planning_component_->plan();
192202

@@ -211,6 +221,11 @@ class Demo
211221
visual_tools_.trigger();
212222
}
213223

224+
moveit_visual_tools::MoveItVisualTools& getVisualTools()
225+
{
226+
return visual_tools_;
227+
}
228+
214229
private:
215230
std::shared_ptr<rclcpp::Node> node_;
216231
std::shared_ptr<moveit_cpp::MoveItCpp> moveit_cpp_;

0 commit comments

Comments
 (0)