Skip to content

Commit

Permalink
fuck this
Browse files Browse the repository at this point in the history
Signed-off-by: Jade Turner <[email protected]>
  • Loading branch information
spacey-sooty committed Oct 7, 2024
1 parent cbd9c9e commit 034c963
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 56 deletions.
69 changes: 35 additions & 34 deletions trajoptlib/py/cpp/BindSwerve.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) TrajoptLib contributors

#include <nanobind/nanobind.h>
#include <nanobind/stl/function.h>

#include <vector>

Expand All @@ -12,13 +13,13 @@ namespace nb = nanobind;

namespace trajopt {
/*
void BindSwerveDrivetrain(nb::class<SwerveDrivetrain> cls);
void BindSwerveSolution(nb::class<SwerveSolution> cls);
void BindSwerveTrajectorySample(nb::class<SwerveTrajectorySample> cls);
void BindSwerveTrajectory(nb::class<SwerveTrajectory> cls);
void BindSwervePath(nb::class<SwervePath> cls);
void BindSwervePathBuilder(nb::class<SwervePathBuilder> cls);
void BindSwerveTrajectoryGenerator(nb::class<SwerveTrajectoryGenerator> cls);
void BindSwerveDrivetrain(nb::class_<SwerveDrivetrain> cls);
void BindSwerveSolution(nb::class_<SwerveSolution> cls);
void BindSwerveTrajectorySample(nb::class_<SwerveTrajectorySample> cls);
void BindSwerveTrajectory(nb::class_<SwerveTrajectory> cls);
void BindSwervePath(nb::class_<SwervePath> cls);
void BindSwervePathBuilder(nb::class_<SwervePathBuilder> cls);
void BindSwerveTrajectoryGenerator(nb::class_<SwerveTrajectoryGenerator> cls);
*/

void BindSwerveDrivetrain(nb::class_<SwerveDrivetrain>& cls) {
Expand All @@ -28,34 +29,34 @@ void BindSwerveDrivetrain(nb::class_<SwerveDrivetrain>& cls) {
std::vector<Translation2d>>(),
"mass"_a, "moi"_a, "wheelRadius"_a, "wheelMaxAngularVelocity"_a,
"wheelMaxTorque"_a, "modules"_a);
cls.def_ro("mass", double);
cls.def_ro("moi", double);
cls.def_ro("wheelRadius", double);
cls.def_ro("wheelMaxAngularVelocity", double);
cls.def_ro("wheelMaxTorque", double);
cls.def_ro("modules", std::vector<Translation2d>));
cls.def_ro("mass", double, DOC(_trajoptlib, SwerveDrivetrain, double));
cls.def_ro("moi", double, DOC(_trajoptlib, SwerveDrivetrain, double));
cls.def_ro("wheelRadius", double, DOC(_trajoptlib, SwerveDrivetrain, double));
cls.def_ro("wheelMaxAngularVelocity", double, DOC(_trajoptlib, SwerveDrivetrain, double));
cls.def_ro("wheelMaxTorque", double, DOC(_trajoptlib, SwerveDrivetrain, double));
cls.def_ro("modules", std::vector<Translation2d>, DOC(_trajoptlib, SwerveDrivetrain, std::vector<Translation2d>));
}

void BindSwerveSolution(nb::class<SwerveSolution> cls) {
using namespace nb::literals;

cls.def(nb::init<
std::vector<double>, std::vector<double>, std::vector<double>, std::vector<double>, std::vector<double>, std::vector<double>, std::vector<double>, std::vector<double>, std::vector<double>, std::vector<double>, std::vector<double>, std::vector<double>, std::vector<double>, >(),
"dt"_a, "x"_a, "y"_a, "thetacos"_a, "thetasin"_a, "vx"_a, "vy"_a,
"omega"_a, "ax"_a, "ay"_a, "alpha"_a, "moduleFX"_a, "moduleFY"_a);
cls.def_ro("dt", std::vector<double>);
cls.def_ro("x", std::vector<double>);
cls.def_ro("y", std::vector<double>);
cls.def_ro("thetacos", std::vector<double>);
cls.def_ro("thetasin", std::vector<double>);
cls.def_ro("vx", std::vector<double>);
cls.def_ro("vy", std::vector<double>);
cls.def_ro("omega", std::vector<double>);
cls.def_ro("ax", std::vector<double>);
cls.def_ro("ay", std::vector<double>);
cls.def_ro("alpha", std::vector<double>);
cls.def_ro("moduleFX", std::vector<double>);
cls.def_ro("moduleFY", std::vector<double>);
}
// void BindSwerveSolution(nb::class_<SwerveSolution>& cls) {
// using namespace nb::literals;
//
// cls.def(nb::init<
// std::vector<double>, std::vector<double>, std::vector<double>, std::vector<double>, std::vector<double>, std::vector<double>, std::vector<double>, std::vector<double>, std::vector<double>, std::vector<double>, std::vector<double>, std::vector<double>, std::vector<double>, >(),
// "dt"_a, "x"_a, "y"_a, "thetacos"_a, "thetasin"_a, "vx"_a, "vy"_a,
// "omega"_a, "ax"_a, "ay"_a, "alpha"_a, "moduleFX"_a, "moduleFY"_a);
// cls.def_ro("dt", std::vector<double>);
// cls.def_ro("x", std::vector<double>);
// cls.def_ro("y", std::vector<double>);
// cls.def_ro("thetacos", std::vector<double>);
// cls.def_ro("thetasin", std::vector<double>);
// cls.def_ro("vx", std::vector<double>);
// cls.def_ro("vy", std::vector<double>);
// cls.def_ro("omega", std::vector<double>);
// cls.def_ro("ax", std::vector<double>);
// cls.def_ro("ay", std::vector<double>);
// cls.def_ro("alpha", std::vector<double>);
// cls.def_ro("moduleFX", std::vector<double>);
// cls.def_ro("moduleFY", std::vector<double>);
// }

} // namespace trajopt
44 changes: 22 additions & 22 deletions trajoptlib/py/cpp/Binders.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,35 @@

#pragma once

#include <nanobind/nanobind.h>
#include <nanobind/nanobind.h>&

namespace nb = nanobind;

namespace trajopt {

void BindSwerveDrivetrain(nb::class<SwerveDrivetrain> cls);
void BindSwerveSolution(nb::class<SwerveSolution> cls);
void BindSwerveTrajectorySample(nb::class<SwerveTrajectorySample> cls);
void BindSwerveTrajectory(nb::class<SwerveTrajectory> cls);
void BindSwervePath(nb::class<SwervePath> cls);
void BindSwervePathBuilder(nb::class<SwervePathBuilder> cls);
void BindSwerveTrajectoryGenerator(nb::class<SwerveTrajectoryGenerator> cls);
void BindSwerveDrivetrain(nb::class_<SwerveDrivetrain>& cls);
void BindSwerveSolution(nb::class_<SwerveSolution>& cls);
void BindSwerveTrajectorySample(nb::class_<SwerveTrajectorySample>& cls);
void BindSwerveTrajectory(nb::class_<SwerveTrajectory>& cls);
void BindSwervePath(nb::class_<SwervePath>& cls);
void BindSwervePathBuilder(nb::class_<SwervePathBuilder>& cls);
void BindSwerveTrajectoryGenerator(nb::class_<SwerveTrajectoryGenerator>& cls);

void BindDifferentialDrivetrain(nb::class<DifferentialDrivetrain> cls);
void BindDifferentialSolution(nb::class<DifferentialTrajectory> cls);
void BindDifferentialDrivetrain(nb::class_<DifferentialDrivetrain>& cls);
void BindDifferentialSolution(nb::class_<DifferentialTrajectory>& cls);
void BindDifferentialTrajectorySample(
nb::class<DifferentialTrajectorySample> cls);
void BindDifferentialTrajectory(nb::class<DifferentialTrajectory> cls);
void BindDifferentialPath(nb::class<DifferentialPath> cls);
void BindDifferentialPathBuilder(nb::class<DifferentialPathBuilder> cls);
nb::class_<DifferentialTrajectorySample>& cls);
void BindDifferentialTrajectory(nb::class_<DifferentialTrajectory>& cls);
void BindDifferentialPath(nb::class_<DifferentialPath>& cls);
void BindDifferentialPathBuilder(nb::class_<DifferentialPathBuilder>& cls);
void BindDifferentialTrajectoryGenerator(
nb::class<DifferentialTrajectoryGenerator> cls);

// void BindExpressionType(nb::enum_<ExpressionType>& e);
// void BindVariable(nb::module_& autodiff, nb::class_<Variable>& cls);
// void BindOCPSolver(nb::enum_<TranscriptionMethod>& transcription_method,
// nb::enum_<DynamicsType>& dynamics_type,
// nb::enum_<TimestepMethod>& timestep_method,
// nb::class_<OCPSolver, OptimizationProblem>& cls);
nb::class_<DifferentialTrajectoryGenerator>& cls);

// void BindExpressionType(nb::enum_<ExpressionType>&& e);
// void BindVariable(nb::module_& autodiff, nb::class__<Variable>&& cls);
// void BindOCPSolver(nb::enum_<TranscriptionMethod>&& transcription_method,
// nb::enum_<DynamicsType>&& dynamics_type,
// nb::enum_<TimestepMethod>&& timestep_method,
// nb::class__<OCPSolver, OptimizationProblem>&& cls);

} // namespace trajopt

0 comments on commit 034c963

Please sign in to comment.