Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional methods for the class DiscreteTimeTrajectory #22624

Open
wei-chen-li opened this issue Feb 13, 2025 · 1 comment
Open

Additional methods for the class DiscreteTimeTrajectory #22624

wei-chen-li opened this issue Feb 13, 2025 · 1 comment

Comments

@wei-chen-li
Copy link
Contributor

Is your feature request related to a problem? Please describe.

  1. When a function returns a DiscreteTimeTrajectory, the std::vector used for its construction is unnecessarily copied.
  2. There is no convenient method to sample from a Trajectory and generate a DiscreteTimeTrajectory.

Describe the solution you'd like
Implement the following three methods in the DiscreteTimeTrajectory class

DiscreteTimeTrajectory(const std::vector<T>& times, std::vector<MatrixX<T>>&& values, const double time_comparison_tolerance)

DiscreteTimeTrajectory(std::vector<T>&& times, std::vector<MatrixX<T>>&& values, const double time_comparison_tolerance)

static DiscreteTimeTrajectory<T> SampleFrom(const Tajectory<T>& traj, double time_period, double time_offset=0)

Additional Considerations

A potential issue with SampleFrom is handling cases where traj.start_time() == -inf or traj.end_time() == inf. Possible solutions include:

  • Returning an empty trajectory
  • Throwing an exception
  • Defining a reasonable default start time and end time

Feedback on the preferred behavior for these edge cases would be appreciated.

@cohnt
Copy link
Contributor

cohnt commented Feb 13, 2025

Wouldn't the Trajectory::vector_values method do what you need? I guess this doesn't work for trajectories that are matrix-value yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants