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

Commit

Permalink
Remove unused or redundant Rust functions (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
calcmogul authored Jun 26, 2024
1 parent ad31912 commit 8660354
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 120 deletions.
4 changes: 2 additions & 2 deletions examples/swerve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ fn main() {
path.set_bumpers(1.3, 1.3);
path.pose_wpt(0, 0.0, 0.0, 0.0);
path.pose_wpt(1, 1.0, 0.0, 0.0);
path.wpt_angular_velocity(0, 0.0);
path.wpt_angular_velocity(1, 0.0);
path.wpt_angular_velocity_max_magnitude(0, 0.0);
path.wpt_angular_velocity_max_magnitude(1, 0.0);
path.sgmt_circle_obstacle(0, 1, 0.5, 0.1, 0.2);
path.set_control_interval_counts(vec![40]);
println!("setup complete");
Expand Down
50 changes: 0 additions & 50 deletions include/trajopt/constraint/AngularVelocityEqualityConstraint.hpp

This file was deleted.

5 changes: 1 addition & 4 deletions include/trajopt/constraint/Constraint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <sleipnir/autodiff/Variable.hpp>
#include <sleipnir/optimization/OptimizationProblem.hpp>

#include "trajopt/constraint/AngularVelocityEqualityConstraint.hpp"
#include "trajopt/constraint/AngularVelocityMaxMagnitudeConstraint.hpp"
#include "trajopt/constraint/LinePointConstraint.hpp"
#include "trajopt/constraint/LinearVelocityDirectionConstraint.hpp"
Expand Down Expand Up @@ -47,7 +46,6 @@ concept ConstraintType =
} -> std::same_as<void>;
};

static_assert(ConstraintType<AngularVelocityEqualityConstraint>);
static_assert(ConstraintType<AngularVelocityMaxMagnitudeConstraint>);
static_assert(ConstraintType<LinePointConstraint>);
static_assert(ConstraintType<LinearVelocityDirectionConstraint>);
Expand All @@ -59,8 +57,7 @@ static_assert(ConstraintType<PoseEqualityConstraint>);
static_assert(ConstraintType<TranslationEqualityConstraint>);

using Constraint =
std::variant<AngularVelocityEqualityConstraint,
AngularVelocityMaxMagnitudeConstraint, LinePointConstraint,
std::variant<AngularVelocityMaxMagnitudeConstraint, LinePointConstraint,
LinearVelocityDirectionConstraint,
LinearVelocityMaxMagnitudeConstraint, PointAtConstraint,
PointLineConstraint, PointPointConstraint,
Expand Down
10 changes: 5 additions & 5 deletions include/trajopt/path/SwervePathBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ namespace trajopt {
*/
class TRAJOPT_DLLEXPORT SwervePathBuilder {
public:
/**
* Cancel all currently generating SwervePathBuilders.
*/
void CancelAll();

/**
* Get the SwervePath being constructed
*
Expand Down Expand Up @@ -186,6 +181,11 @@ class TRAJOPT_DLLEXPORT SwervePathBuilder {
void AddIntermediateCallback(
const std::function<void(SwerveSolution&, int64_t)> callback);

/**
* Cancel all currently generating SwervePathBuilders.
*/
void CancelAll();

private:
SwervePath path;

Expand Down
40 changes: 4 additions & 36 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@ mod ffi {
index: usize,
magnitude: f64,
);
fn wpt_angular_velocity(
self: Pin<&mut SwervePathBuilderImpl>,
index: usize,
angular_velocity: f64,
);
fn wpt_angular_velocity_max_magnitude(
self: Pin<&mut SwervePathBuilderImpl>,
index: usize,
Expand All @@ -118,12 +113,6 @@ mod ffi {
to_index: usize,
magnitude: f64,
);
fn sgmt_angular_velocity(
self: Pin<&mut SwervePathBuilderImpl>,
from_index: usize,
to_index: usize,
angular_velocity: f64,
);
fn sgmt_angular_velocity_max_magnitude(
self: Pin<&mut SwervePathBuilderImpl>,
from_index: usize,
Expand Down Expand Up @@ -249,14 +238,6 @@ impl SwervePathBuilder {
);
}

pub fn wpt_angular_velocity(&mut self, index: usize, angular_velocity: f64) {
crate::ffi::SwervePathBuilderImpl::wpt_angular_velocity(
self.path.pin_mut(),
index,
angular_velocity,
);
}

pub fn wpt_angular_velocity_max_magnitude(&mut self, index: usize, angular_velocity: f64) {
crate::ffi::SwervePathBuilderImpl::wpt_angular_velocity_max_magnitude(
self.path.pin_mut(),
Expand Down Expand Up @@ -309,20 +290,6 @@ impl SwervePathBuilder {
);
}

pub fn sgmt_angular_velocity(
&mut self,
from_index: usize,
to_index: usize,
angular_velocity: f64,
) {
crate::ffi::SwervePathBuilderImpl::sgmt_angular_velocity(
self.path.pin_mut(),
from_index,
to_index,
angular_velocity,
);
}

pub fn sgmt_angular_velocity_max_magnitude(
&mut self,
from_index: usize,
Expand Down Expand Up @@ -413,9 +380,6 @@ impl SwervePathBuilder {
}
}

pub fn cancel_all(&mut self) {
crate::ffi::SwervePathBuilderImpl::cancel_all(self.path.pin_mut());
}
///
/// Add a callback that will be called on each iteration of the solver.
///
Expand All @@ -428,6 +392,10 @@ impl SwervePathBuilder {
pub fn add_progress_callback(&mut self, callback: fn(HolonomicTrajectory, i64)) {
crate::ffi::SwervePathBuilderImpl::add_progress_callback(self.path.pin_mut(), callback);
}

pub fn cancel_all(&mut self) {
crate::ffi::SwervePathBuilderImpl::cancel_all(self.path.pin_mut());
}
}

impl Default for SwervePathBuilder {
Expand Down
8 changes: 4 additions & 4 deletions src/path/SwervePathBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@

namespace trajopt {

void SwervePathBuilder::CancelAll() {
trajopt::GetCancellationFlag() = 1;
}

SwervePath& SwervePathBuilder::GetPath() {
return path;
}
Expand Down Expand Up @@ -202,6 +198,10 @@ void SwervePathBuilder::AddIntermediateCallback(
path.callbacks.push_back(callback);
}

void SwervePathBuilder::CancelAll() {
trajopt::GetCancellationFlag() = 1;
}

void SwervePathBuilder::NewWpts(size_t finalIndex) {
int64_t targetIndex = finalIndex;
int64_t greatestIndex = path.waypoints.size() - 1;
Expand Down
16 changes: 0 additions & 16 deletions src/trajoptlibrust.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <vector>

#include "trajopt/SwerveTrajectoryGenerator.hpp"
#include "trajopt/constraint/AngularVelocityEqualityConstraint.hpp"
#include "trajopt/constraint/AngularVelocityMaxMagnitudeConstraint.hpp"
#include "trajopt/constraint/LinearVelocityDirectionConstraint.hpp"
#include "trajopt/constraint/LinearVelocityMaxMagnitudeConstraint.hpp"
Expand Down Expand Up @@ -129,13 +128,6 @@ void SwervePathBuilderImpl::wpt_linear_velocity_max_magnitude(
trajopt::LinearVelocityMaxMagnitudeConstraint{magnitude});
}

void SwervePathBuilderImpl::wpt_angular_velocity(size_t index,
double angular_velocity) {
// this probably ought to be added to SwervePathBuilder in the C++ API
path.WptConstraint(
index, trajopt::AngularVelocityEqualityConstraint{angular_velocity});
}

void SwervePathBuilderImpl::wpt_angular_velocity_max_magnitude(
size_t index, double angular_velocity) {
path.WptConstraint(
Expand Down Expand Up @@ -164,14 +156,6 @@ void SwervePathBuilderImpl::sgmt_linear_velocity_max_magnitude(
trajopt::LinearVelocityMaxMagnitudeConstraint{magnitude});
}

void SwervePathBuilderImpl::sgmt_angular_velocity(size_t from_index,
size_t to_index,
double angular_velocity) {
path.SgmtConstraint(
from_index, to_index,
trajopt::AngularVelocityEqualityConstraint{angular_velocity});
}

void SwervePathBuilderImpl::sgmt_angular_velocity_max_magnitude(
size_t from_index, size_t to_index, double angular_velocity) {
path.SgmtConstraint(
Expand Down
3 changes: 0 additions & 3 deletions src/trajoptlibrust.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class SwervePathBuilderImpl {

void wpt_linear_velocity_direction(size_t index, double angle);
void wpt_linear_velocity_max_magnitude(size_t index, double magnitude);
void wpt_angular_velocity(size_t index, double angular_velocity);
void wpt_angular_velocity_max_magnitude(size_t index,
double angular_velocity);
void wpt_point_at(size_t index, double field_point_x, double field_point_y,
Expand All @@ -43,8 +42,6 @@ class SwervePathBuilderImpl {
double angle);
void sgmt_linear_velocity_max_magnitude(size_t from_index, size_t to_index,
double magnitude);
void sgmt_angular_velocity(size_t from_index, size_t to_index,
double angular_velocity);
void sgmt_angular_velocity_max_magnitude(size_t from_index, size_t to_index,
double angular_velocity);
void sgmt_point_at(size_t from_index, size_t to_index, double field_point_x,
Expand Down

0 comments on commit 8660354

Please sign in to comment.