Skip to content

Commit cffb814

Browse files
committed
Add isFixed...() methods to plan profiles
1 parent c3c040d commit cffb814

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
@@ -90,6 +90,9 @@ class TrajOptDefaultPlanProfile : public TrajOptPlanProfile
9090
const std::vector<std::string>& active_links,
9191
int index) const override;
9292

93+
bool isFixedCartesian() const override;
94+
bool isFixedJoint() const override;
95+
9396
tinyxml2::XMLElement* toXML(tinyxml2::XMLDocument& doc) const override;
9497

9598
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
@@ -66,6 +66,9 @@ class TrajOptPlanProfile
6666
const std::vector<std::string>& active_links,
6767
int index) const = 0;
6868

69+
virtual bool isFixedCartesian() const = 0;
70+
virtual bool isFixedJoint() const = 0;
71+
6972
virtual tinyxml2::XMLElement* toXML(tinyxml2::XMLDocument& doc) const = 0;
7073
};
7174

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
@@ -211,6 +211,16 @@ void TrajOptDefaultPlanProfile::addConstraintErrorFunctions(trajopt::ProblemCons
211211
}
212212
}
213213

214+
bool TrajOptDefaultPlanProfile::isFixedCartesian() const {
215+
// If the term type is constraint and all coefficients are non-zero
216+
return (term_type == trajopt::TermType::TT_CNT) && (abs(cartesian_coeff.array()) >= std::numeric_limits<double>::epsilon()).all();
217+
}
218+
219+
bool TrajOptDefaultPlanProfile::isFixedJoint() const {
220+
// If the term type is constraint and all coefficients are non-zero
221+
return (term_type == trajopt::TermType::TT_CNT) && (abs(joint_coeff.array()) >= std::numeric_limits<double>::epsilon()).all();
222+
}
223+
214224
tinyxml2::XMLElement* TrajOptDefaultPlanProfile::toXML(tinyxml2::XMLDocument& doc) const
215225
{
216226
Eigen::IOFormat eigen_format(Eigen::StreamPrecision, Eigen::DontAlignCols, " ", " ");

tesseract_motion_planners/trajopt/src/trajopt_motion_planner.cpp

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

276276
// Add to fixed indices
277-
if (!cwp.isToleranced()) /** @todo Should not make fixed if term_type is cost */
277+
if (!cwp.isToleranced() && cur_plan_profile->isFixedCartesian())
278278
fixed_steps.push_back(i);
279279
}
280280
else if (move_instruction.getWaypoint().isJointWaypoint())
@@ -287,7 +287,7 @@ TrajOptMotionPlanner::createProblem(const PlannerRequest& request) const
287287
cur_plan_profile->apply(*pci, jwp, move_instruction, composite_mi, active_links, i);
288288

289289
// Add to fixed indices
290-
if (!jwp.isToleranced()) /** @todo Should not make fixed if term_type is cost */
290+
if (!jwp.isToleranced() && cur_plan_profile->isFixedJoint())
291291
fixed_steps.push_back(i);
292292
}
293293

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
@@ -65,6 +65,9 @@ class TrajOptIfoptDefaultPlanProfile : public TrajOptIfoptPlanProfile
6565
const std::vector<std::string>& active_links,
6666
int index) const override;
6767

68+
bool isFixedCartesian() const override;
69+
bool isFixedJoint() const override;
70+
6871
tinyxml2::XMLElement* toXML(tinyxml2::XMLDocument& doc) const override;
6972
};
7073
} // 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
@@ -68,6 +68,9 @@ class TrajOptIfoptPlanProfile
6868
const std::vector<std::string>& active_links,
6969
int index) const = 0;
7070

71+
virtual bool isFixedCartesian() const = 0;
72+
virtual bool isFixedJoint() const = 0;
73+
7174
virtual tinyxml2::XMLElement* toXML(tinyxml2::XMLDocument& doc) const = 0;
7275
};
7376

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
@@ -138,6 +138,16 @@ void TrajOptIfoptDefaultPlanProfile::apply(TrajOptIfoptProblem& problem,
138138
}
139139
}
140140

141+
bool TrajOptIfoptDefaultPlanProfile::isFixedCartesian() const {
142+
// If the term type is constraint and all coefficients are non-zero
143+
return (term_type == TrajOptIfoptTermType::CONSTRAINT) && (abs(cartesian_coeff.array()) >= std::numeric_limits<double>::epsilon()).all();
144+
}
145+
146+
bool TrajOptIfoptDefaultPlanProfile::isFixedJoint() const {
147+
// If the term type is constraint and all coefficients are non-zero
148+
return (term_type == TrajOptIfoptTermType::CONSTRAINT) && (abs(joint_coeff.array()) >= std::numeric_limits<double>::epsilon()).all();
149+
}
150+
141151
tinyxml2::XMLElement* TrajOptIfoptDefaultPlanProfile::toXML(tinyxml2::XMLDocument& /*doc*/) const
142152
{
143153
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
@@ -290,7 +290,7 @@ std::shared_ptr<TrajOptIfoptProblem> TrajOptIfoptMotionPlanner::createProblem(co
290290
cur_plan_profile->apply(*problem, cwp, move_instruction, composite_mi, active_links, i);
291291

292292
// Add to fixed indices
293-
if (!cwp.isToleranced()) /** @todo Should not make fixed if term_type is cost */
293+
if (!cwp.isToleranced() && cur_plan_profile->isFixedCartesian())
294294
fixed_steps.push_back(i);
295295
}
296296
else if (move_instruction.getWaypoint().isJointWaypoint())
@@ -312,7 +312,7 @@ std::shared_ptr<TrajOptIfoptProblem> TrajOptIfoptMotionPlanner::createProblem(co
312312
cur_plan_profile->apply(*problem, jwp, move_instruction, composite_mi, active_links, i);
313313

314314
// Add to fixed indices
315-
if (!jwp.isToleranced()) /** @todo Should not make fixed if term_type is cost */
315+
if (!jwp.isToleranced() && cur_plan_profile->isFixedJoint())
316316
fixed_steps.push_back(i);
317317
}
318318
}

0 commit comments

Comments
 (0)