Skip to content
This repository has been archived by the owner on Jul 8, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into embind
Browse files Browse the repository at this point in the history
  • Loading branch information
calcmogul committed Feb 19, 2024
2 parents 0c7745d + 043d747 commit fb1d221
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 58 deletions.
18 changes: 16 additions & 2 deletions include/trajopt/trajectory/HolonomicTrajectory.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#pragma once

#include <utility>
#include <vector>

#include "trajopt/SymbolExports.h"
Expand All @@ -18,19 +19,32 @@ class TRAJOPT_DLLEXPORT HolonomicTrajectory {
/// Trajectory samples.
std::vector<HolonomicTrajectorySample> samples;

HolonomicTrajectory() = default;

/**
* Construct a HolonomicTrajectory from samples.
*
* @param samples The samples.
*/
explicit HolonomicTrajectory(std::vector<HolonomicTrajectorySample> samples);
explicit HolonomicTrajectory(std::vector<HolonomicTrajectorySample> samples)
: samples{std::move(samples)} {}

/**
* Construct a HolonomicTrajectory from a solution.
*
* @param solution The solution.
*/
explicit HolonomicTrajectory(const HolonomicSolution& solution);
explicit HolonomicTrajectory(const HolonomicSolution& solution) {
double ts = 0.0;
for (size_t samp = 0; samp < solution.x.size(); ++samp) {
if (samp != 0) {
ts += solution.dt[samp - 1];
}
samples.emplace_back(ts, solution.x[samp], solution.y[samp],
solution.theta[samp], solution.vx[samp],
solution.vy[samp], solution.omega[samp]);
}
}
};

} // namespace trajopt
29 changes: 19 additions & 10 deletions include/trajopt/trajectory/HolonomicTrajectorySample.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,27 @@ namespace trajopt {
class TRAJOPT_DLLEXPORT HolonomicTrajectorySample {
public:
/// The timestamp.
double timestamp;
double timestamp = 0.0;

/// The x coordinate.
double x;
double x = 0.0;

/// The y coordinate.
double y;
double y = 0.0;

/// The heading.
double heading;
double heading = 0.0;

/// The velocity's x component.
double velocityX;
double velocityX = 0.0;

/// The velocity's y component.
double velocityY;
double velocityY = 0.0;

/// The angular velocity.
double angularVelocity;
double angularVelocity = 0.0;

constexpr HolonomicTrajectorySample() = default;

/**
* Construct a HolonomicTrajectorySample.
Expand All @@ -43,9 +45,16 @@ class TRAJOPT_DLLEXPORT HolonomicTrajectorySample {
* @param velocityY The velocity's y component.
* @param angularVelocity The angular velocity.
*/
HolonomicTrajectorySample(double timestamp, double x, double y,
double heading, double velocityX, double velocityY,
double angularVelocity);
constexpr HolonomicTrajectorySample(double timestamp, double x, double y,
double heading, double velocityX,
double velocityY, double angularVelocity)
: timestamp{timestamp},
x{x},
y{y},
heading{heading},
velocityX{velocityX},
velocityY{velocityY},
angularVelocity{angularVelocity} {}
};

} // namespace trajopt
26 changes: 0 additions & 26 deletions src/trajectory/HolonomicTrajectory.cpp

This file was deleted.

20 changes: 0 additions & 20 deletions src/trajectory/HolonomicTrajectorySample.cpp

This file was deleted.

0 comments on commit fb1d221

Please sign in to comment.