-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build_cmake/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
cmake_minimum_required(VERSION 3.15...3.29) | ||
project(example LANGUAGES CXX) | ||
set(CMAKE_CXX_STANDARD 20) | ||
|
||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
|
||
# Checked out commit https://github.com/pybind/pybind11/tree/a5b0cdcb937b2853e012489633d692099dab7078 | ||
add_subdirectory(pybind11) | ||
|
||
pybind11_add_module(wrap_a meme/bind_a.cpp) | ||
|
||
target_compile_definitions(wrap_a PRIVATE | ||
PYBIND11_USE_SMART_HOLDER_AS_DEFAULT=1 | ||
) | ||
message(asdfasdf ${CMAKE_SOURCE_DIR}) | ||
target_include_directories( | ||
wrap_a | ||
PRIVATE | ||
${CMAKE_SOURCE_DIR}/../.venv/Lib/site-packages/wpimath/_impl/include/ | ||
${CMAKE_SOURCE_DIR}/../.venv/Lib/site-packages/wpiutil/include/ | ||
) | ||
target_link_libraries( | ||
wrap_a | ||
PRIVATE | ||
# /home/mmorley/photonvision/.venv/lib/python3.10/site-packages/wpimath/_impl/lib/libwpimath.so | ||
"C:\\Users\\matth\\Documents\\GitHub\\photonvision\\.venv\\Lib\\site-packages\\wpimath\\_impl\\lib\\wpimath.lib" | ||
# /home/mmorley/photonvision/.venv/lib/python3.10/site-packages/wpiutil/lib/libwpiutil.so | ||
"C:\\Users\\matth\\Documents\\GitHub\\photonvision\\.venv\\Lib\\site-packages\\wpiutil\\lib\\wpiutil.lib" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from wpimath.geometry import Translation3d | ||
from cmake_build import wrap_a as a | ||
|
||
t = Translation3d(1.2, 3.4, 5.6) | ||
a.print_t(t) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <pybind11/pybind11.h> | ||
#include <iostream> | ||
|
||
#include "frc/geometry/Translation3d.h" | ||
|
||
namespace py = pybind11; | ||
using namespace frc; | ||
using namespace std; | ||
|
||
void print_t(frc::Translation3d t) { | ||
using namespace std; | ||
cout << "Translation x " << t.X().to<double>() << " y " << t.Y().to<double>() << " z " << t.Z().to<double>() << endl; | ||
} | ||
|
||
PYBIND11_MODULE(wrap_a, m) { | ||
py::module_::import("wpimath"); | ||
py::module_::import("wpimath.geometry"); | ||
|
||
m.def("print_t", &print_t, "A function to print a pose"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from wpimath.geometry import Translation3d | ||
from build_cmake.Release import wrap_a | ||
|
||
t = Translation3d(1,2,3) | ||
wrap_a.print_t(t) |