quangounet / TOPP

Time-Optimal Path Parameterization (à la Bobrow)
GNU Lesser General Public License v3.0
168 stars 74 forks source link

Division by zero in function StraightProfile #34

Open luo1239021639 opened 6 years ago

luo1239021639 commented 6 years ago

Hi Cuong.

I think there's a bug here:

TOPP.cpp Line 1701~1706: // Address Switch Point if (!AddressSwitchPoint(constraints, switchpoint, sbackward, sdbackward, sforward, sdforward)) continue;

    // Add middle part
    constraints.resprofileslist.push_back(StraightProfile(sbackward,sforward,sdbackward,sdforward));

In function AddressSwitchPoint, when switchpoint's type is Tangent, Discontinuous or Zlajpah, sforward == sbackward.

TOPP.cpp Line 1666~1667: dReal dtmod = 2 * (sforward - sbackward) / (sdforward + sdbackward); dReal sdd = (sdforward - sdbackward) / dtmod;

sforward == sbackward means dtmod ==0 , and there is a Division by zero, then sdd will be a weird value.

Please forgive my poor English

quangounet commented 6 years ago

Hi Luo Thanks for your message. In fact this function should be used only for singular switch points. There should be a test for it. Let me know if you ever enter that function from another type of switch point. Cheers Cuong

-- Sent from my mobile phone www.normalesup.org/~pham www.ntu.edu.sg/home/cuong

On 8 Mar 2018, at 16:02, luo1239021639 notifications@github.com wrote:

Hi Cuong.

I think there's a bug here:

TOPP.cpp Line 1701~1706: // Address Switch Point if (!AddressSwitchPoint(constraints, switchpoint, sbackward, sdbackward, sforward, sdforward)) continue;

// Add middle part
constraints.resprofileslist.push_back(StraightProfile(sbackward,sforward,sdbackward,sdforward));

In function AddressSwitchPoint, when switchpoint's type is Tangent, Discontinuous or Zlajpah, sforward == sbackward.

TOPP.cpp Line 1666~1667: dReal dtmod = 2 * (sforward - sbackward) / (sdforward + sdbackward); dReal sdd = (sdforward - sdbackward) / dtmod;

sforward == sbackward means dtmod ==0 , and there is a Division by zero, then sdd will be a weird value.

Please forgive my poor English

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

luo1239021639 commented 6 years ago

Hi Cuong It is very nice to get your reply. When I test Wiki Quick Example Kinematic limits (initial trajectory specified by trajectorystring) there will some TANGENT and DISCONTINUOUS switch points.

Then, I enter the function from another type of switch point and get a sdd with weird value.

If I change the code like that, the breakpoint will be triggered

dReal dtmod = 2 * (sforward - sbackward) / (sdforward + sdbackward); dReal sdd; if (abs(dtmod) > TINY) sdd = (sdforward - sdbackward) / dtmod; else (breakpoint) sdd = 0;

Luo