Skip to content

Commit d6f68f9

Browse files
rhaschkev4hn
authored andcommitted
Simplify code
We know that trajectory at least comprises the start state. Thus, we don't need the sanity checks.
1 parent 71fab0f commit d6f68f9

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

core/src/solvers/cartesian_path.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,14 @@ bool CartesianPath::plan(const planning_scene::PlanningSceneConstPtr& from, cons
102102
is_valid);
103103
#endif
104104

105-
if (!trajectory.empty()) {
106-
result.reset(new robot_trajectory::RobotTrajectory(sandbox_scene->getRobotModel(), jmg));
107-
for (const auto& waypoint : trajectory)
108-
result->addSuffixWayPoint(waypoint, 0.0);
105+
assert(!trajectory.empty()); // there should be at least the start state
106+
result = std::make_shared<robot_trajectory::RobotTrajectory>(sandbox_scene->getRobotModel(), jmg);
107+
for (const auto& waypoint : trajectory)
108+
result->addSuffixWayPoint(waypoint, 0.0);
109109

110-
trajectory_processing::IterativeParabolicTimeParameterization timing;
111-
timing.computeTimeStamps(*result, props.get<double>("max_velocity_scaling_factor"),
112-
props.get<double>("max_acceleration_scaling_factor"));
113-
}
110+
trajectory_processing::IterativeParabolicTimeParameterization timing;
111+
timing.computeTimeStamps(*result, props.get<double>("max_velocity_scaling_factor"),
112+
props.get<double>("max_acceleration_scaling_factor"));
114113

115114
return achieved_fraction >= props.get<double>("min_fraction");
116115
}

core/src/stages/move_relative.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -302,13 +302,11 @@ bool MoveRelative::compute(const InterfaceState& state, planning_scene::Planning
302302
const Eigen::Isometry3d& reached_pose = reached_state->getGlobalLinkTransform(link);
303303

304304
double distance = 0.0;
305-
if (robot_trajectory && robot_trajectory->getWayPointCount() > 0) {
306-
if (use_rotation_distance) {
307-
Eigen::AngleAxisd rotation(reached_pose.linear() * link_pose.linear().transpose());
308-
distance = rotation.angle();
309-
} else
310-
distance = (reached_pose.translation() - link_pose.translation()).norm();
311-
}
305+
if (use_rotation_distance) {
306+
Eigen::AngleAxisd rotation(reached_pose.linear() * link_pose.linear().transpose());
307+
distance = rotation.angle();
308+
} else
309+
distance = (reached_pose.translation() - link_pose.translation()).norm();
312310

313311
// min_distance reached?
314312
if (min_distance > 0.0) {

0 commit comments

Comments
 (0)