Skip to content

Commit b7785a9

Browse files
committed
Add isFixed...() methods to plan profiles
1 parent fa22b52 commit b7785a9

File tree

8 files changed

+36
-4
lines changed

8 files changed

+36
-4
lines changed

tesseract_motion_planners/trajopt/include/tesseract_motion_planners/trajopt/profile/trajopt_default_plan_profile.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ class TrajOptDefaultPlanProfile : public TrajOptPlanProfile
9292
const std::vector<std::string>& active_links,
9393
int index) const override;
9494

95+
bool isFixedCartesian() const override;
96+
bool isFixedJoint() const override;
97+
9598
tinyxml2::XMLElement* toXML(tinyxml2::XMLDocument& doc) const override;
9699

97100
protected:

tesseract_motion_planners/trajopt/include/tesseract_motion_planners/trajopt/profile/trajopt_profile.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ class TrajOptPlanProfile
7171
const std::vector<std::string>& active_links,
7272
int index) const = 0;
7373

74+
virtual bool isFixedCartesian() const = 0;
75+
virtual bool isFixedJoint() const = 0;
76+
7477
virtual tinyxml2::XMLElement* toXML(tinyxml2::XMLDocument& doc) const = 0;
7578
};
7679

tesseract_motion_planners/trajopt/src/profile/trajopt_default_plan_profile.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,16 @@ void TrajOptDefaultPlanProfile::addConstraintErrorFunctions(trajopt::ProblemCons
280280
}
281281
}
282282

283+
bool TrajOptDefaultPlanProfile::isFixedCartesian() const {
284+
// If the term type is constraint and all coefficients are non-zero
285+
return (term_type == trajopt::TermType::TT_CNT) && (abs(cartesian_coeff.array()) >= std::numeric_limits<double>::epsilon()).all();
286+
}
287+
288+
bool TrajOptDefaultPlanProfile::isFixedJoint() const {
289+
// If the term type is constraint and all coefficients are non-zero
290+
return (term_type == trajopt::TermType::TT_CNT) && (abs(joint_coeff.array()) >= std::numeric_limits<double>::epsilon()).all();
291+
}
292+
283293
tinyxml2::XMLElement* TrajOptDefaultPlanProfile::toXML(tinyxml2::XMLDocument& doc) const
284294
{
285295
tinyxml2::XMLElement* xml_planner = doc.NewElement("Planner");

tesseract_motion_planners/trajopt/src/trajopt_motion_planner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ TrajOptMotionPlanner::createProblem(const PlannerRequest& request) const
289289
}
290290

291291
// Add to fixed indices
292-
if (!cwp.isToleranced()) /** @todo Should not make fixed if term_type is cost */
292+
if (!cwp.isToleranced() && cur_plan_profile->isFixedCartesian())
293293
fixed_steps.push_back(i);
294294
}
295295
else if (move_instruction.getWaypoint().isJointWaypoint())
@@ -302,7 +302,7 @@ TrajOptMotionPlanner::createProblem(const PlannerRequest& request) const
302302
cur_plan_profile->apply(*pci, jwp, move_instruction, composite_mi, active_links, i);
303303

304304
// Add to fixed indices
305-
if (!jwp.isToleranced()) /** @todo Should not make fixed if term_type is cost */
305+
if (!jwp.isToleranced() && cur_plan_profile->isFixedJoint())
306306
fixed_steps.push_back(i);
307307
}
308308

tesseract_motion_planners/trajopt_ifopt/include/tesseract_motion_planners/trajopt_ifopt/profile/trajopt_ifopt_default_plan_profile.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ class TrajOptIfoptDefaultPlanProfile : public TrajOptIfoptPlanProfile
6464
const std::vector<std::string>& active_links,
6565
int index) const override;
6666

67+
bool isFixedCartesian() const override;
68+
bool isFixedJoint() const override;
69+
6770
tinyxml2::XMLElement* toXML(tinyxml2::XMLDocument& doc) const override;
6871
};
6972
} // namespace tesseract_planning

tesseract_motion_planners/trajopt_ifopt/include/tesseract_motion_planners/trajopt_ifopt/profile/trajopt_ifopt_profile.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ class TrajOptIfoptPlanProfile
7373
const std::vector<std::string>& active_links,
7474
int index) const = 0;
7575

76+
virtual bool isFixedCartesian() const = 0;
77+
virtual bool isFixedJoint() const = 0;
78+
7679
virtual tinyxml2::XMLElement* toXML(tinyxml2::XMLDocument& doc) const = 0;
7780
};
7881

tesseract_motion_planners/trajopt_ifopt/src/profile/trajopt_ifopt_default_plan_profile.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,16 @@ void TrajOptIfoptDefaultPlanProfile::apply(TrajOptIfoptProblem& problem,
127127
}
128128
}
129129

130+
bool TrajOptIfoptDefaultPlanProfile::isFixedCartesian() const {
131+
// If the term type is constraint and all coefficients are non-zero
132+
return (term_type == TrajOptIfoptTermType::CONSTRAINT) && (abs(cartesian_coeff.array()) >= std::numeric_limits<double>::epsilon()).all();
133+
}
134+
135+
bool TrajOptIfoptDefaultPlanProfile::isFixedJoint() const {
136+
// If the term type is constraint and all coefficients are non-zero
137+
return (term_type == TrajOptIfoptTermType::CONSTRAINT) && (abs(joint_coeff.array()) >= std::numeric_limits<double>::epsilon()).all();
138+
}
139+
130140
tinyxml2::XMLElement* TrajOptIfoptDefaultPlanProfile::toXML(tinyxml2::XMLDocument& /*doc*/) const
131141
{
132142
throw std::runtime_error("TrajOptIfoptDefaultPlanProfile::toXML is not implemented!");

tesseract_motion_planners/trajopt_ifopt/src/trajopt_ifopt_motion_planner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ std::shared_ptr<TrajOptIfoptProblem> TrajOptIfoptMotionPlanner::createProblem(co
299299
cur_plan_profile->apply(*problem, cwp, move_instruction, composite_mi, active_links, i);
300300

301301
// Add to fixed indices
302-
if (!cwp.isToleranced()) /** @todo Should not make fixed if term_type is cost */
302+
if (!cwp.isToleranced() && cur_plan_profile->isFixedCartesian())
303303
fixed_steps.push_back(i);
304304
}
305305
else if (move_instruction.getWaypoint().isJointWaypoint())
@@ -321,7 +321,7 @@ std::shared_ptr<TrajOptIfoptProblem> TrajOptIfoptMotionPlanner::createProblem(co
321321
cur_plan_profile->apply(*problem, jwp, move_instruction, composite_mi, active_links, i);
322322

323323
// Add to fixed indices
324-
if (!jwp.isToleranced()) /** @todo Should not make fixed if term_type is cost */
324+
if (!jwp.isToleranced() && cur_plan_profile->isFixedJoint())
325325
fixed_steps.push_back(i);
326326
}
327327
}

0 commit comments

Comments
 (0)