Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--[BE] Remove Eigen dependency Part 1 #2301

Merged
merged 51 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
9f82f08
--remove eigen refs from viewer.
jturner65 Jan 12, 2024
bec7eb3
--remove unused eigen typedefs
jturner65 Jan 12, 2024
526bb34
--many refactors across system
jturner65 Jan 16, 2024
80b8671
--fix replicascene semantics load
jturner65 Jan 16, 2024
8fee4ba
--fix elementwise pathfinder min/max
jturner65 Jan 16, 2024
0c4762f
--return data array of quaternion in binding
jturner65 Jan 16, 2024
3625a32
--update mesh joining
jturner65 Jan 16, 2024
6d5d86e
--remove more unused Eigen typedefs
jturner65 Jan 16, 2024
c5e3deb
--address obbs (change box3f to Magnum Range 3D)
jturner65 Jan 16, 2024
ceef9af
--semantic bindings issue
jturner65 Jan 16, 2024
7399df7
--more cleanup.
jturner65 Jan 16, 2024
481dcfb
--bugfixes
jturner65 Jan 16, 2024
38f51be
--bug fixes
jturner65 Jan 16, 2024
0d72985
--more bugfixes
jturner65 Jan 16, 2024
e21dddd
--still more bugfixes
jturner65 Jan 16, 2024
0886c1b
--oops
jturner65 Jan 16, 2024
cd2c48b
--reviewer suggestions
jturner65 Jan 16, 2024
d42872e
--clang-tidy
jturner65 Jan 17, 2024
b2a750e
--missing include
jturner65 Jan 22, 2024
91df858
--reviewer suggestions
jturner65 Jan 25, 2024
fe454c7
--fix an error - shouldn't normalize the cross product.
jturner65 Jan 26, 2024
47dd843
--cleanup;
jturner65 Feb 5, 2024
d142133
--use join function
jturner65 Feb 5, 2024
1e5a5a1
--fix bbox bindings issue
jturner65 Feb 6, 2024
b821ba8
--fix broken constructor
jturner65 Mar 5, 2024
674500e
--another ortho test mistake
jturner65 Jul 9, 2024
108493f
--replace quat rotation from 2 vectors function with magnum version
jturner65 Jul 9, 2024
7136da3
--Specify rotations as Matrix3x3 instead of full 2D transformation ma…
jturner65 Jul 10, 2024
fef55e2
--cleanup
jturner65 Jul 10, 2024
9a23173
--missing include
jturner65 Jul 10, 2024
bed5bc6
--cleanup
jturner65 Jul 10, 2024
2f58694
--return to Matrix3
jturner65 Jul 11, 2024
cc94230
--remove call to obviated function
jturner65 Sep 6, 2024
1eac15f
--remove unused include
jturner65 Sep 13, 2024
20e62a0
--cleanup
jturner65 Sep 13, 2024
9249328
--fix test
jturner65 Oct 30, 2024
7aa2296
--fix missing namespace alias
jturner65 Dec 4, 2024
62e7709
--fix controls test by wrapping
jturner65 Dec 30, 2024
ac7d2c0
--missed 'swizzle' issue
jturner65 Jan 6, 2025
78b9069
--minor warning cleanups; remove unused eigenIntegration includes
jturner65 Jan 6, 2025
ef72837
--update island radius expected size cache
jturner65 Jan 6, 2025
7f21ab9
--isolate eigen dynamic matrix typedefs
jturner65 Jan 6, 2025
3ba1ce5
--DO NOT MERGE THIS COMMIT : Test against LAB pr
jturner65 Jan 8, 2025
9219b8d
--DO NOT COMMIT; fix lab branch checkout
jturner65 Jan 8, 2025
6c88f5e
--update quaternions to magnum
jturner65 Jan 8, 2025
dfb16e7
--try again
jturner65 Jan 9, 2025
453bee3
--update tests to use magnum quats
jturner65 Jan 9, 2025
c06e5a2
--fetch first perhaps
jturner65 Jan 9, 2025
71e6930
-- Remove repo ref lab PR
jturner65 Jan 9, 2025
bb46e42
--remove superfluous integration includes
jturner65 Jan 13, 2025
c92bfc3
--remove deprecated function
jturner65 Jan 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions examples/demo_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,21 +302,21 @@ def do_time_steps(self):
def print_semantic_scene(self):
if self._sim_settings["print_semantic_scene"]:
scene = self._sim.semantic_scene
print(f"House center:{scene.aabb.center} dims:{scene.aabb.sizes}")
print(f"House center:{scene.aabb.center} dims:{scene.aabb.size}")
for level in scene.levels:
print(
f"Level id:{level.id}, center:{level.aabb.center},"
f" dims:{level.aabb.sizes}"
f" dims:{level.aabb.size}"
)
for region in level.regions:
print(
f"Region id:{region.id}, category:{region.category.name()},"
f" center:{region.aabb.center}, dims:{region.aabb.sizes}"
f" center:{region.aabb.center}, dims:{region.aabb.size}"
)
for obj in region.objects:
print(
f"Object id:{obj.id}, category:{obj.category.name()},"
f" center:{obj.aabb.center}, dims:{obj.aabb.sizes}"
f" center:{obj.aabb.center}, dims:{obj.aabb.size}"
)
input("Press Enter to continue...")

Expand Down
8 changes: 4 additions & 4 deletions examples/tutorials/nb_python/ECCV_2020_Navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,23 +375,23 @@ def print_scene_recur(scene, limit_output=10):
print(
f"House has {len(scene.levels)} levels, {len(scene.regions)} regions and {len(scene.objects)} objects"
)
print(f"House center:{scene.aabb.center} dims:{scene.aabb.sizes}")
print(f"House center:{scene.aabb.center} dims:{scene.aabb.size}")

count = 0
for level in scene.levels:
print(
f"Level id:{level.id}, center:{level.aabb.center},"
f" dims:{level.aabb.sizes}"
f" dims:{level.aabb.size}"
)
for region in level.regions:
print(
f"Region id:{region.id}, category:{region.category.name()},"
f" center:{region.aabb.center}, dims:{region.aabb.sizes}"
f" center:{region.aabb.center}, dims:{region.aabb.size}"
)
for obj in region.objects:
print(
f"Object id:{obj.id}, category:{obj.category.name()},"
f" center:{obj.aabb.center}, dims:{obj.aabb.sizes}"
f" center:{obj.aabb.center}, dims:{obj.aabb.size}"
)
count += 1
if count >= limit_output:
Expand Down
4 changes: 3 additions & 1 deletion examples/tutorials/new_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ def _strafe_impl(
np.array(scene_node.absolute_transformation().rotation_scaling())
@ habitat_sim.geo.FRONT
)
rotation = quat_from_angle_axis(np.deg2rad(strafe_angle), habitat_sim.geo.UP)
rotation = quat_from_angle_axis(
np.deg2rad(strafe_angle), np.array(habitat_sim.geo.UP)
)
move_ax = quat_rotate_vector(rotation, forward_ax)

scene_node.translate_local(move_ax * forward_amount)
Expand Down
8 changes: 4 additions & 4 deletions examples/tutorials/notebooks/ECCV_2020_Navigation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -450,23 +450,23 @@
" print(\n",
" f\"House has {len(scene.levels)} levels, {len(scene.regions)} regions and {len(scene.objects)} objects\"\n",
" )\n",
" print(f\"House center:{scene.aabb.center} dims:{scene.aabb.sizes}\")\n",
" print(f\"House center:{scene.aabb.center} dims:{scene.aabb.size}\")\n",
"\n",
" count = 0\n",
" for level in scene.levels:\n",
" print(\n",
" f\"Level id:{level.id}, center:{level.aabb.center},\"\n",
" f\" dims:{level.aabb.sizes}\"\n",
" f\" dims:{level.aabb.size}\"\n",
" )\n",
" for region in level.regions:\n",
" print(\n",
" f\"Region id:{region.id}, category:{region.category.name()},\"\n",
" f\" center:{region.aabb.center}, dims:{region.aabb.sizes}\"\n",
" f\" center:{region.aabb.center}, dims:{region.aabb.size}\"\n",
" )\n",
" for obj in region.objects:\n",
" print(\n",
" f\"Object id:{obj.id}, category:{obj.category.name()},\"\n",
" f\" center:{obj.aabb.center}, dims:{obj.aabb.sizes}\"\n",
" f\" center:{obj.aabb.center}, dims:{obj.aabb.size}\"\n",
" )\n",
" count += 1\n",
" if count >= limit_output:\n",
Expand Down
1 change: 0 additions & 1 deletion src/esp/assets/BaseMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <Corrade/Containers/ArrayViewStl.h>
#include <Corrade/Utility/FormatStl.h>
#include <Magnum/DebugTools/ColorMap.h>
#include <Magnum/EigenIntegration/GeometryIntegration.h>
#include <Magnum/Math/Color.h>
#include <Magnum/Math/PackingBatch.h>
#include <Magnum/MeshTools/Compile.h>
Expand Down
6 changes: 3 additions & 3 deletions src/esp/assets/GenericSemanticMeshData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <Magnum/PixelFormat.h>
#include <Magnum/Shaders/GenericGL.h>

#include "esp/core/Utility.h"
#include "esp/geo/Geo.h"
#include "esp/scene/SemanticScene.h"

Expand Down Expand Up @@ -65,8 +66,7 @@ GenericSemanticMeshData::buildSemanticMeshData(
if (semanticFilename.find(".ply") != std::string::npos) {
// Generic Semantic PLY meshes have -Z gravity
const auto T_esp_scene =
Mn::Quaternion{quatf::FromTwoVectors(-vec3f::UnitZ(), geo::ESP_GRAVITY)}
.toMatrix();
Mn::Quaternion::rotation(geo::ESP_FRONT, geo::ESP_GRAVITY).toMatrix();
for (auto& xyz : semanticMeshData->cpu_vbo_) {
xyz = T_esp_scene * xyz;
}
Expand Down Expand Up @@ -307,7 +307,7 @@ GenericSemanticMeshData::buildSemanticMeshData(
// display or save report denoting presence of semantic object-defined colors
// in mesh
return semanticMeshData;
} // GenericSemanticMeshData::buildSemanticMeshData
} // namespace assets

std::vector<std::unique_ptr<GenericSemanticMeshData>>
GenericSemanticMeshData::partitionSemanticMeshData(
Expand Down
9 changes: 4 additions & 5 deletions src/esp/assets/MeshData.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,20 @@
#include <vector>

#include "esp/core/Esp.h"
#include "esp/core/EspEigen.h"

namespace esp {
namespace assets {

//! Raw mesh data storage
struct MeshData {
//! Vertex positions
std::vector<vec3f> vbo;
std::vector<Magnum::Vector3> vbo;
//! Vertex normals
std::vector<vec3f> nbo;
std::vector<Magnum::Vector3> nbo;
//! Texture coordinates
std::vector<vec2f> tbo;
std::vector<Magnum::Vector2> tbo;
//! Vertex colors
std::vector<vec3f> cbo;
std::vector<Magnum::Vector3> cbo;
//! Index buffer
std::vector<uint32_t> ibo;

Expand Down
6 changes: 3 additions & 3 deletions src/esp/assets/MeshMetaData.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ struct MeshMetaData {
* @param frame target frame in world space
*/
void setRootFrameOrientation(const geo::CoordinateFrame& frame) {
const quatf& transform = frame.rotationFrameToWorld();
Magnum::Matrix4 R = Magnum::Matrix4::from(
Magnum::Quaternion(transform).toMatrix(), Magnum::Vector3());
const Magnum::Quaternion& transform = frame.rotationFrameToWorld();
Magnum::Matrix4 R =
Magnum::Matrix4::from(transform.toMatrix(), Magnum::Vector3());
root.transformFromLocalToParent = R * root.transformFromLocalToParent;
}
};
Expand Down
15 changes: 4 additions & 11 deletions src/esp/assets/ResourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#include <Corrade/Utility/Path.h>
#include <Corrade/Utility/Resource.h>
#include <Corrade/Utility/String.h>
#include <Magnum/EigenIntegration/GeometryIntegration.h>
#include <Magnum/EigenIntegration/Integration.h>
#include <Magnum/GL/Context.h>
#include <Magnum/GL/Extensions.h>
#include <Magnum/GL/TextureFormat.h>
Expand Down Expand Up @@ -694,11 +692,8 @@ esp::geo::CoordinateFrame ResourceManager::buildFrameFromAttributes(
const Mn::Vector3& up,
const Mn::Vector3& front,
const Mn::Vector3& origin) {
const vec3f upEigen{Mn::EigenIntegration::cast<vec3f>(up)};
const vec3f frontEigen{Mn::EigenIntegration::cast<vec3f>(front)};
if (upEigen.isOrthogonal(frontEigen)) {
const vec3f originEigen{Mn::EigenIntegration::cast<vec3f>(origin)};
esp::geo::CoordinateFrame frame{upEigen, frontEigen, originEigen};
if (abs(Mn::Math::dot(up, front)) < Mn::Math::TypeTraits<float>::epsilon()) {
esp::geo::CoordinateFrame frame{up, front, origin};
return frame;
}
ESP_DEBUG(Mn::Debug::Flag::NoSpace)
Expand Down Expand Up @@ -3481,8 +3476,7 @@ void ResourceManager::joinHierarchy(
<< "` so skipping join.";
} else {
for (const auto& pos : meshData.positions) {
mesh.vbo.push_back(Mn::EigenIntegration::cast<vec3f>(
transformFromLocalToWorld.transformPoint(pos)));
mesh.vbo.push_back(transformFromLocalToWorld.transformPoint(pos));
}
for (const auto& index : meshData.indices) {
mesh.ibo.push_back(index + lastIndex);
Expand Down Expand Up @@ -3529,8 +3523,7 @@ void ResourceManager::joinSemanticHierarchy(

// Save the vertices
for (const auto& pos : vertices) {
mesh.vbo.push_back(Mn::EigenIntegration::cast<vec3f>(
transformFromLocalToWorld.transformPoint(pos)));
mesh.vbo.push_back(transformFromLocalToWorld.transformPoint(pos));
}

// Save the indices
Expand Down
12 changes: 0 additions & 12 deletions src/esp/bindings/Bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,6 @@
namespace py = pybind11;
using py::literals::operator""_a;

namespace esp {

void initEspBindings(py::module& m) {
// ==== box3f ====
py::class_<box3f>(m, "BBox")
.def_property_readonly("sizes", &box3f::sizes)
.def_property_readonly("center", &box3f::center);
}

} // namespace esp

PYBIND11_MODULE(habitat_sim_bindings, m) {
m.attr("cuda_enabled") =
#ifdef ESP_BUILD_WITH_CUDA
Expand Down Expand Up @@ -59,7 +48,6 @@ PYBIND11_MODULE(habitat_sim_bindings, m) {

py::bind_map<std::map<std::string, std::string>>(m, "MapStringString");

esp::initEspBindings(m);
esp::core::config::initConfigBindings(m);
esp::core::initCoreBindings(m);
esp::geo::initGeoBindings(m);
Expand Down
29 changes: 15 additions & 14 deletions src/esp/bindings/GeoBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
#include "esp/geo/Geo.h"
#include "esp/geo/OBB.h"

#include <Magnum/EigenIntegration/GeometryIntegration.h>

namespace Mn = Magnum;
namespace py = pybind11;
using py::literals::operator""_a;
Expand All @@ -23,18 +21,17 @@ void initGeoBindings(py::module& m) {
geo.attr("GRAVITY") = ESP_GRAVITY;
geo.attr("FRONT") = ESP_FRONT;
geo.attr("BACK") = ESP_BACK;
geo.attr("LEFT") = ESP_FRONT.cross(ESP_GRAVITY);
geo.attr("RIGHT") = ESP_FRONT.cross(ESP_UP);
geo.attr("LEFT") = Mn::Math::cross(ESP_FRONT, ESP_GRAVITY);
geo.attr("RIGHT") = Mn::Math::cross(ESP_FRONT, ESP_UP);

// ==== OBB ====
py::class_<OBB>(m, "OBB", R"(This is an OBB.)")
.def(py::init([](const vec3f& center, const vec3f& dimensions,
.def(py::init([](const Mn::Vector3& center, const Mn::Vector3& dimensions,
const Mn::Quaternion& rotation) {
return OBB(center, dimensions,
Mn::EigenIntegration::cast<quatf>(rotation));
return OBB(center, dimensions, rotation);
}),
"center"_a, "dimensions"_a, "rotation"_a)
.def(py::init<box3f&>())
.def(py::init<Mn::Range3D&>())
.def(
"contains", &OBB::contains,
R"(Returns whether world coordinate point p is contained in this OBB within threshold distance epsilon.)")
Expand All @@ -48,7 +45,7 @@ void initGeoBindings(py::module& m) {
.def(
"rotate",
[](OBB& self, const Mn::Quaternion& rotation) {
return self.rotate(Mn::EigenIntegration::cast<quatf>(rotation));
return self.rotate(rotation);
},
R"(Rotate this OBB by the given rotation and return reference to self.)")
.def_property_readonly("center", &OBB::center, R"(Centroid of this OBB.)")
Expand All @@ -59,15 +56,19 @@ void initGeoBindings(py::module& m) {
.def_property_readonly("half_extents", &OBB::halfExtents,
R"(Half-extents of this OBB (dimensions).)")
.def_property_readonly(
"rotation", [](const OBB& self) { return self.rotation().coeffs(); },
// Return as an array of format [x,y,z,w] to retain existing
// expectations
"rotation",
[](const OBB& self) {
const Mn::Quaternion q = self.rotation();
return Mn::Vector4(q.vector(), q.scalar());
},
R"(Quaternion representing rotation of this OBB.)")
.def_property_readonly(
"local_to_world",
[](const OBB& self) { return self.localToWorld().matrix(); },
"local_to_world", [](const OBB& self) { return self.localToWorld(); },
R"(Transform from local [0,1]^3 coordinates to world coordinates.)")
.def_property_readonly(
"world_to_local",
[](const OBB& self) { return self.worldToLocal().matrix(); },
"world_to_local", [](const OBB& self) { return self.worldToLocal(); },
R"(Transform from world coordinates to local [0,1]^3 coordinates.)");

geo.def(
Expand Down
6 changes: 3 additions & 3 deletions src/esp/bindings/SceneBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,11 @@ void initSceneBindings(
.def_static(
"load_mp3d_house",
[](const std::string& filename, SemanticScene& scene,
const vec4f& rotation) {
const Mn::Vector4& rotation) {
// numpy doesn't have a quaternion equivalent, use vec4
// instead
return SemanticScene::loadMp3dHouse(
filename, scene, Eigen::Map<const quatf>(rotation.data()));
return SemanticScene::loadMp3dHouse(filename, scene,
{rotation.xyz(), rotation.w()});
},
R"(
Loads a SemanticScene from a Matterport3D House format file into passed
Expand Down
13 changes: 7 additions & 6 deletions src/esp/bindings/ShortestPathBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,24 +174,25 @@ void initShortestPathBindings(py::module& m) {
R"(Finds the shortest path between a start point and the closest of a set of end points (in geodesic distance) on the navigation mesh using MultiGoalShortestPath module. Path variable is filled if successful. Returns boolean success.)")
.def("try_step", &PathFinder::tryStep<Magnum::Vector3>, "start"_a,
"end"_a)
.def("try_step", &PathFinder::tryStep<vec3f>, "start"_a, "end"_a)
.def("try_step", &PathFinder::tryStep<Magnum::Vector3>, "start"_a,
"end"_a)
.def("try_step_no_sliding",
&PathFinder::tryStepNoSliding<Magnum::Vector3>, "start"_a, "end"_a)
.def("try_step_no_sliding",
&PathFinder::tryStepNoSliding<Magnum::Vector3>, "start"_a, "end"_a)
.def("try_step_no_sliding", &PathFinder::tryStepNoSliding<vec3f>,
"start"_a, "end"_a)
.def("snap_point", &PathFinder::snapPoint<Magnum::Vector3>, "point"_a,
"island_index"_a = ID_UNDEFINED)
.def("snap_point", &PathFinder::snapPoint<vec3f>, "point"_a,
.def("snap_point", &PathFinder::snapPoint<Magnum::Vector3>, "point"_a,
"island_index"_a = ID_UNDEFINED)
.def(
"get_island", &PathFinder::getIsland<Magnum::Vector3>, "point"_a,
R"(Query the island closest to a point. Snaps the point to the NavMesh first, so check the snap distance also if unsure.)")
.def(
"get_island", &PathFinder::getIsland<vec3f>, "point"_a,
"get_island", &PathFinder::getIsland<Magnum::Vector3>, "point"_a,
R"(Query the island closest to a point. Snaps the point to the NavMesh first, so check the snap distance also if unsure.)")
.def(
"island_radius",
[](PathFinder& self, const vec3f& pt) {
[](PathFinder& self, const Magnum::Vector3& pt) {
return self.islandRadius(pt);
},
"pt"_a,
Expand Down
Loading
Loading