-
Notifications
You must be signed in to change notification settings - Fork 85
Support multiple attachment frames #75
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
base: main
Are you sure you want to change the base?
Changes from 6 commits
89fcd09
a54a1a1
aa246ae
9f18316
7f3d533
1ec162d
b8ec2a3
831eda4
6edae82
43429d1
a0fad92
b1f9be7
6ed387c
8cfbc05
1bb1a9f
08544da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| #pragma once | ||
|
|
||
| #include <map> | ||
| #include <Eigen/Dense> | ||
| #include <Eigen/Geometry> | ||
|
|
||
|
|
@@ -22,7 +23,7 @@ namespace vamp::collision | |
| std::vector<Cuboid<DataT>> z_aligned_cuboids; | ||
| std::vector<HeightField<DataT>> heightfields; | ||
| std::vector<CAPT> pointclouds; | ||
| std::optional<Attachment<DataT>> attachments; | ||
| std::map<size_t, Attachment<DataT>> attachments; // eef_id to attachment | ||
|
|
||
| Environment() = default; | ||
|
|
||
|
|
@@ -36,7 +37,7 @@ namespace vamp::collision | |
| , z_aligned_cuboids(other.z_aligned_cuboids.begin(), other.z_aligned_cuboids.end()) | ||
| , heightfields(other.heightfields.begin(), other.heightfields.end()) | ||
| , pointclouds(other.pointclouds.begin(), other.pointclouds.end()) | ||
| , attachments(other.template clone_attachments<DataT>()) | ||
| , attachments(other.attachments.begin(), other.attachments.end()) | ||
| { | ||
| } | ||
|
|
||
|
|
@@ -71,25 +72,18 @@ namespace vamp::collision | |
| private: | ||
| template <typename OtherDataT> | ||
| friend struct Environment; | ||
|
|
||
| template <typename OtherDataT> | ||
| inline auto clone_attachments() const noexcept -> std::optional<Attachment<OtherDataT>> | ||
| { | ||
| if (attachments) | ||
| { | ||
| return Attachment<OtherDataT>(*attachments); | ||
| } | ||
|
|
||
| return std::nullopt; | ||
| } | ||
| }; | ||
|
|
||
| template <typename DataT> | ||
| template <size_t N, typename DataT> | ||
| inline auto set_attachment_pose( | ||
| const Environment<DataT> &e, | ||
| const Eigen::Transform<DataT, 3, Eigen::Isometry> &p_tf) noexcept | ||
| const std::array<Eigen::Transform<DataT, 3, Eigen::Isometry>, N> &p_tfs | ||
| ) noexcept | ||
| { | ||
| e.attachments->pose(p_tf); | ||
| for(auto i=0U; i < N; i++){ | ||
| if(e.attachments.find(i) != e.attachments.end()) | ||
| e.attachments.at(i).pose(p_tfs[i]); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see my comment on changing the structure of eef_attachments |
||
| } | ||
|
|
||
| } // namespace vamp::collision | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -252,18 +252,39 @@ namespace vamp | |
| inline constexpr auto attachment_environment_collision(const collision::Environment<DataT> &e) noexcept | ||
| -> bool | ||
| { | ||
| for (const auto &s : e.attachments->posed_spheres) | ||
| { | ||
| // HACK: The radius needs to be a float, and unfortunately the spheres assume homogeneous | ||
| // DataT for storage | ||
| // TODO: Fix the sphere representation to allow to store float radii even with vector | ||
| // centers | ||
| if (sphere_environment_in_collision(e, s.x, s.y, s.z, s.r[{0, 0}])) | ||
| for (const auto &attachment: e.attachments){ | ||
| for (const auto &s : attachment.second.posed_spheres) | ||
| { | ||
| return true; | ||
| // HACK: The radius needs to be a float, and unfortunately the spheres assume homogeneous | ||
| // DataT for storage | ||
| // TODO: Fix the sphere representation to allow to store float radii even with vector | ||
| // centers | ||
| if (sphere_environment_in_collision(e, s.x, s.y, s.z, s.r[{0, 0}])) | ||
| { | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
| // now treat the other attachments also as potential collision objects | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems pretty clunky to me, but idk if there's a better way |
||
| // This is probably expensive, find a more efficient way. | ||
| for (const auto &other_attachment: e.attachments){ | ||
| if(attachment.first != other_attachment.first) { // different obj | ||
| for (const auto &s : attachment.second.posed_spheres) { | ||
| for(const auto &s2 : other_attachment.second.posed_spheres) { | ||
| if (not collision::sphere_sphere_sql2(s, s2).test_zero()) | ||
| { | ||
| return true; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
|
|
||
|
|
||
|
|
||
| return false; | ||
| } | ||
|
|
||
|
|
@@ -280,15 +301,17 @@ namespace vamp | |
| auto sy = static_cast<DataT>(sy_); | ||
| auto sz = static_cast<DataT>(sz_); | ||
| auto sr = static_cast<DataT>(sr_); | ||
| for (const auto &att_s : e.attachments->posed_spheres) | ||
| for (const auto &attachment: e.attachments) | ||
| { | ||
| if (not collision::sphere_sphere_sql2(sx, sy, sz, sr, att_s.x, att_s.y, att_s.z, att_s.r) | ||
| .test_zero()) | ||
| for (const auto &att_s : attachment.second.posed_spheres) | ||
| { | ||
| return true; | ||
| if (not collision::sphere_sphere_sql2(sx, sy, sz, sr, att_s.x, att_s.y, att_s.z, att_s.r) | ||
| .test_zero()) | ||
| { | ||
| return true; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
| } // namespace vamp | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be off by default for python wheels