wpilibsuite/allwpilib

TrapezoidProfile methods (somewhat) incompatible with new API

Open

#6,452 建立於 2024年3月19日

在 GitHub 查看
 (2 留言) (0 反應) (0 負責人)C++ (714 fork)auto 404
component: wpimatheffort: 3good first issuetype: bug

倉庫指標

Star
 (1,281 star)
PR 合併指標
 (PR 指標待抓取)

描述

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)?

貢獻者指南