Skip to content

Commit ac5ddc4

Browse files
committed
Add isFixed...() methods to plan profiles
1 parent c55e4c5 commit ac5ddc4

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
@@ -277,7 +277,7 @@ TrajOptMotionPlanner::createProblem(const PlannerRequest& request) const
277277
}
278278

279279
// Add to fixed indices
280-
if (!cwp.isToleranced()) /** @todo Should not make fixed if term_type is cost */
280+
if (!cwp.isToleranced() && cur_plan_profile->isFixedCartesian())
281281
fixed_steps.push_back(i);
282282
}
283283
else if (move_instruction.getWaypoint().isJointWaypoint())
@@ -290,7 +290,7 @@ TrajOptMotionPlanner::createProblem(const PlannerRequest& request) const
290290
cur_plan_profile->apply(*pci, jwp, move_instruction, composite_mi, active_links, i);
291291

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

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
@@ -291,7 +291,7 @@ std::shared_ptr<TrajOptIfoptProblem> TrajOptIfoptMotionPlanner::createProblem(co
291291
cur_plan_profile->apply(*problem, cwp, move_instruction, composite_mi, active_links, i);
292292

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

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

0 commit comments

Comments
 (0)