personalrobotics / aikido

Artificial Intelligence for Kinematics, Dynamics, and Optimization
https://personalrobotics.github.io/aikido/
BSD 3-Clause "New" or "Revised" License
213 stars 30 forks source link

Remove bug where Kunz hangs on empty trajectory #629

Closed egordon closed 1 year ago

egordon commented 1 year ago

Previously, in the case of an empty trajectory (which is possible for an Offset planner with 0 offset or a configuration planner with goal == start), the resulting trajectory was length 0.

In this case, any postprocessor should return a valid (but empty) trajectory.

However, Kunz's Trajectory class initially timed the trajectory using the velocity without checking for 0 velocity. If there is 0 velocity but non-0 position, the trajectory is invalid (this should never happen). But if there is 0 velocity AND 0 change in position, the trajectory is valid but empty, and Kunz shouldn't perform the division (which results in a NaN endTime, which in turn leads to a VERY LARGE sequence of waypoints when naively constructed with aikido::common::StepSequence, which in turn causes the program to loop nearly infinitely).

In addition, the Robot class has been modified to gracefully handle valid and empty trajectories (namely: not executing them).


Before creating a pull request

Before merging a pull request

codecov[bot] commented 1 year ago

Codecov Report

Merging #629 (3c761fb) into master (55ca618) will decrease coverage by 0.06%. The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master     #629      +/-   ##
==========================================
- Coverage   73.06%   73.00%   -0.07%     
==========================================
  Files         221      221              
  Lines        7972     7978       +6     
==========================================
- Hits         5825     5824       -1     
- Misses       2147     2154       +7     
Impacted Files Coverage Δ
include/aikido/common/util.hpp 71.42% <0.00%> (-28.58%) :arrow_down:
include/aikido/robot/util.hpp 54.54% <ø> (ø)
src/robot/Robot.cpp 19.88% <0.00%> (-0.12%) :arrow_down:
src/planner/ompl/CRRT.cpp 72.95% <0.00%> (-0.52%) :arrow_down: