Skip to content

Commit

Permalink
[FIX] removes link_ee
Browse files Browse the repository at this point in the history
  • Loading branch information
kamiradi committed Oct 8, 2024
1 parent fb4fcb8 commit db0fe36
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion include/ktopt_interface/ktopt_planning_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class KTOptPlanningContext : public planning_interface::PlanningContext
void setRobotDescription(std::string robot_description);
void transcribePlanningScene(const planning_scene::PlanningScene& planning_scene);
void addPathPositionConstraints(KinematicTrajectoryOptimization& trajopt, const MultibodyPlant<double>& plant,
const Frame<double>& link_ee_frame, Context<double>& plant_context);
Context<double>& plant_context);

private:
const ktopt_interface::Params params_;
Expand Down
5 changes: 0 additions & 5 deletions res/ktopt_moveit_parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ ktopt_interface:
description: "Robot description to be loaded by the internal Drake MultibodyPlant",
default_value: "package://drake_models/franka_description/urdf/panda_arm_hand.urdf",
}
link_ee: {
type: string,
description: "Name of the end-effector frame as per urdf/srdf",
default_value: "panda_hand"
}
num_iterations: {
type: int,
description: "Number of iterations for the Drake mathematical program solver.",
Expand Down
15 changes: 11 additions & 4 deletions src/ktopt_planning_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ void KTOptPlanningContext::solve(planning_interface::MotionPlanResponse& res)
RCLCPP_INFO_STREAM(getLogger(), "Planning for group: " << getGroupName());
const int num_positions = plant.num_positions();
const int num_velocities = plant.num_velocities();
const auto link_ee = params_.link_ee;
const auto& link_ee_frame = plant.GetFrameByName(link_ee);
// const auto link_ee = params_.link_ee;
// const auto& link_ee_frame = plant.GetFrameByName(link_ee);

// extract position and velocity bounds
std::vector<double> lower_position_bounds;
Expand Down Expand Up @@ -180,7 +180,7 @@ void KTOptPlanningContext::solve(planning_interface::MotionPlanResponse& res)
trajopt.AddDurationConstraint(0.5, 5);

// process path_constraints
addPathPositionConstraints(trajopt, plant, link_ee_frame, plant_context);
addPathPositionConstraints(trajopt, plant, plant_context);

// solve the program
auto result = Solve(prog);
Expand Down Expand Up @@ -237,7 +237,6 @@ void KTOptPlanningContext::solve(planning_interface::MotionPlanResponse& res)

void KTOptPlanningContext::addPathPositionConstraints(KinematicTrajectoryOptimization& trajopt,
const MultibodyPlant<double>& plant,
const Frame<double>& link_ee_frame,
Context<double>& plant_context)
{
// retrieve the motion planning request
Expand All @@ -255,6 +254,14 @@ void KTOptPlanningContext::addPathPositionConstraints(KinematicTrajectoryOptimiz
// Extract dimensions of the bounding box from
// constraint_region.primitives Assuming it is a box
// (shape_msgs::SolidPrimitive::BOX) and has dimensions in [x, y, z]
const auto link_ee = position_constraint.link_name;
if (!plant.HasBodyNamed(link_ee))
{
RCLCPP_ERROR(getLogger(), "The link specified in the PositionConstraint message does not exist in the Drake "
"plant, please check your URDF");
continue;
}
const auto& link_ee_frame = plant.GetFrameByName(link_ee);
const auto& primitive = position_constraint.constraint_region.primitives[0];
if (primitive.type != shape_msgs::msg::SolidPrimitive::BOX)
{
Expand Down

0 comments on commit db0fe36

Please sign in to comment.