Skip to content

TrapezoidProfile methods (somewhat) incompatible with new API #6452

Open
@chauser

Description

@chauser

Describe the bug
Several of the methods in TrapezoidProfile have surprising behavior in some cases when used with the new (non-deprecated, single-argument) constructor because member variables they depend on are not initialized by the new constructor.

Java:
timeLeftUntil uses m_current -- it will get a null pointer exception if called before calculate is called.
totalTime uses m_endDeccel -- it will return zero if called before calculate is called.
isFinished uses totalTime() -- it will return true if called before calculate is called.
If calculate has been called, totalTime and timeLeftUntil return (I think) the times for a profile starting at the current state of the last call to calculate and ending at its goal state.

C++:
Essentially the same issues when any of these methods is called before calculate.
Since m_current isn't a reference it probably won't segfault, but m_current and m_endDeccel are uninitialized in the same cases and the actual behavior may be less predictable than for Java.

It is not clear to me how useful any of these stateful methods are when using the new API. Should they be deprecated as well? And if that were done, couldn't the whole API be boiled down to a single stateless method
calculate(Constraints constraints, double t, State current, State goal)?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions