Skip to content

Commit

Permalink
add meme back
Browse files Browse the repository at this point in the history
  • Loading branch information
mcm001 committed Oct 3, 2024
1 parent 1e7f526 commit b823411
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 0 deletions.
1 change: 1 addition & 0 deletions photon-lib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build_cmake/*
29 changes: 29 additions & 0 deletions photon-lib/CMakeLists.txt
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"
)
5 changes: 5 additions & 0 deletions photon-lib/meme.py
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 added photon-lib/meme/__init__.py
Empty file.
20 changes: 20 additions & 0 deletions photon-lib/meme/bind_a.cpp
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");
}
5 changes: 5 additions & 0 deletions photon-lib/test.py
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)

0 comments on commit b823411

Please sign in to comment.