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

Commit

Permalink
Replace InitialGuessPoint in Rust API with Pose2d (#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
calcmogul authored Jun 26, 2024
1 parent cfc5a2b commit 5f237b7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mod ffi {
}

#[derive(Debug, Deserialize, Serialize)]
struct InitialGuessPoint {
struct Pose2d {
x: f64,
y: f64,
heading: f64,
Expand Down Expand Up @@ -75,7 +75,7 @@ mod ffi {
fn sgmt_initial_guess_points(
self: Pin<&mut SwervePathBuilderImpl>,
from_index: usize,
guess_points: &Vec<InitialGuessPoint>,
guess_points: &Vec<Pose2d>,
);

fn wpt_linear_velocity_direction(
Expand Down Expand Up @@ -224,7 +224,7 @@ impl SwervePathBuilder {
pub fn sgmt_initial_guess_points(
&mut self,
from_index: usize,
guess_points: &Vec<crate::ffi::InitialGuessPoint>,
guess_points: &Vec<crate::ffi::Pose2d>,
) {
crate::ffi::SwervePathBuilderImpl::sgmt_initial_guess_points(
self.path.pin_mut(),
Expand Down Expand Up @@ -439,6 +439,6 @@ impl Default for SwervePathBuilder {

pub use ffi::HolonomicTrajectory;
pub use ffi::HolonomicTrajectorySample;
pub use ffi::InitialGuessPoint;
pub use ffi::Pose2d;
pub use ffi::SwerveDrivetrain;
pub use ffi::SwerveModule;
7 changes: 3 additions & 4 deletions src/trajoptlibrust.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ trajopt::SwerveDrivetrain _convert_swerve_drivetrain(
&_convert_swerve_module>(drivetrain.modules)};
}

trajopt::Pose2d _convert_initial_guess_point(
const InitialGuessPoint& initialGuessPoint) {
trajopt::Pose2d _convert_initial_guess_point(const Pose2d& initialGuessPoint) {
return {initialGuessPoint.x, initialGuessPoint.y, initialGuessPoint.heading};
}

Expand Down Expand Up @@ -111,9 +110,9 @@ void SwervePathBuilderImpl::empty_wpt(size_t index, double x_guess,
}

void SwervePathBuilderImpl::sgmt_initial_guess_points(
size_t from_index, const rust::Vec<InitialGuessPoint>& guess_points) {
size_t from_index, const rust::Vec<Pose2d>& guess_points) {
std::vector<trajopt::Pose2d> convertedGuessPoints =
_rust_vec_to_cpp_vector<InitialGuessPoint, trajopt::Pose2d,
_rust_vec_to_cpp_vector<Pose2d, trajopt::Pose2d,
&_convert_initial_guess_point>(guess_points);
path.SgmtInitialGuessPoints(from_index, convertedGuessPoints);
}
Expand Down
6 changes: 3 additions & 3 deletions src/trajoptlibrust.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace trajoptlibrust {

struct HolonomicTrajectory;
struct InitialGuessPoint;
struct Pose2d;
struct SwerveDrivetrain;

class SwervePathBuilderImpl {
Expand All @@ -28,8 +28,8 @@ class SwervePathBuilderImpl {
void empty_wpt(size_t index, double x_guess, double y_guess,
double heading_guess);

void sgmt_initial_guess_points(
size_t from_index, const rust::Vec<InitialGuessPoint>& guess_points);
void sgmt_initial_guess_points(size_t from_index,
const rust::Vec<Pose2d>& guess_points);

void wpt_linear_velocity_direction(size_t index, double angle);
void wpt_linear_velocity_max_magnitude(size_t index, double magnitude);
Expand Down

0 comments on commit 5f237b7

Please sign in to comment.