rng) -> PlanningResult
{
- return PlannerT::solve(Input::to(start), Input::to(goal), EnvVec(env), s, rng);
+ return PlannerT
::solve(Input::to(start), Input::to(goal), make_environment(env), s, rng);
}
template
@@ -259,7 +298,7 @@ namespace vamp::binding
{
goals_v.emplace_back(Input::to(g));
}
- return PlannerT::solve(Input::to(start), goals_v, EnvVec(env), s, rng);
+ return PlannerT
::solve(Input::to(start), goals_v, make_environment(env), s, rng);
}
static auto simplify(
@@ -268,7 +307,7 @@ namespace vamp::binding
const vamp::planning::SimplifySettings &settings,
std::shared_ptr rng) -> PlanningResult
{
- return vamp::planning::simplify(p, EnvVec(env), settings, rng);
+ return vamp::planning::simplify(p, make_environment(env), settings, rng);
}
// Shared skeleton of the constrained planner entry points: convert
@@ -299,7 +338,7 @@ namespace vamp::binding
const auto goal_c = Input::to(goal);
check_feasible(lp, start_c, "start", message);
check_feasible(lp, goal_c, "goal", message);
- return PlannerT::solve(start_c, goal_c, EnvVec(env), s, rng, lp);
+ return PlannerT
::solve(start_c, goal_c, make_environment(env), s, rng, lp);
}
template
@@ -323,7 +362,7 @@ namespace vamp::binding
check_feasible(lp, goals_v.back(), "goal", message);
}
- return PlannerT::solve(start_c, goals_v, EnvVec(env), s, rng, lp);
+ return PlannerT
::solve(start_c, goals_v, make_environment(env), s, rng, lp);
}
template
@@ -344,7 +383,7 @@ namespace vamp::binding
}
return vamp::planning::simplify(
- p, EnvVec(env), settings, rng, lp);
+ p, make_environment(env), settings, rng, lp);
}
// Constraint-aware variants. These members are only instantiated when referenced,
@@ -445,7 +484,7 @@ namespace vamp::binding
std::shared_ptr rng) -> Roadmap
{
return PlannerT::build_roadmap(
- Input::to(start), Input::to(goal), EnvVec(env), s, rng);
+ Input::to(start), Input::to(goal), make_environment(env), s, rng);
}
static auto roadmap_vertex(const Roadmap &r, std::size_t i)
@@ -467,6 +506,43 @@ namespace vamp::binding
return result;
}
+ // Robot cuboids posed at a configuration, as the same Cuboid type environments use (center, three
+ // axes, and half-lengths), so they can be drawn like any other cuboid. Empty for robots without
+ // cuboids.
+ static auto cuboid_fk(const Cfg &c) -> std::vector>
+ {
+ std::vector> result;
+
+ if constexpr (n_cuboids_v > 0)
+ {
+ typename Robot::template Cuboids<1> out;
+ Robot::template cuboid_fk<1>(Input::template block<1>(c), out);
+
+ result.reserve(Robot::n_cuboids);
+ for (auto i = 0U; i < Robot::n_cuboids; ++i)
+ {
+ result.emplace_back(
+ out.x[{i, 0}],
+ out.y[{i, 0}],
+ out.z[{i, 0}],
+ out.axis_1_x[{i, 0}],
+ out.axis_1_y[{i, 0}],
+ out.axis_1_z[{i, 0}],
+ out.axis_2_x[{i, 0}],
+ out.axis_2_y[{i, 0}],
+ out.axis_2_z[{i, 0}],
+ out.axis_3_x[{i, 0}],
+ out.axis_3_y[{i, 0}],
+ out.axis_3_z[{i, 0}],
+ out.axis_1_r[{i, 0}],
+ out.axis_2_r[{i, 0}],
+ out.axis_3_r[{i, 0}]);
+ }
+ }
+
+ return result;
+ }
+
static auto eefk(const Cfg &c, std::size_t end_effector) -> Eigen::Matrix4f
{
if constexpr (robot_has_end_effectors_v)
@@ -491,14 +567,14 @@ namespace vamp::binding
static auto debug(const Cfg &c, const Env &env) -> typename Robot::Debug
{
- return Robot::fkcc_debug(EnvVec(env), Input::template block(c));
+ return Robot::fkcc_debug(make_environment(env), Input::template block(c));
}
static auto validate(const Cfg &c, const Env &env, bool check_bounds) -> bool
{
auto configuration = Input::to(c);
return (not check_bounds or in_bounds(configuration)) and
- vamp::planning::validate_motion(configuration, configuration, EnvVec(env));
+ vamp::planning::validate_motion(configuration, configuration, make_environment(env));
}
static auto validate_motion(const Cfg &c_in, const Cfg &c_out, const Env &env, bool check_bounds)
@@ -507,7 +583,7 @@ namespace vamp::binding
auto cfg_in = Input::to(c_in);
auto cfg_out = Input::to(c_out);
return (not check_bounds or (in_bounds(cfg_in) and in_bounds(cfg_out))) and
- vamp::planning::validate_motion(cfg_in, cfg_out, EnvVec(env));
+ vamp::planning::validate_motion(cfg_in, cfg_out, make_environment(env));
}
static auto
@@ -516,9 +592,15 @@ namespace vamp::binding
// TODO: Do this smarter with SIMD CC
EnvVec ev(env);
+ // NOTE: Only points are checked against the environment here (as spheres), never robot
+ // cuboids, so unlike the other entry points this is fine for pointcloud environments and
+ // does not go through make_environment.
typename Robot::template Spheres<1> out;
Robot::template sphere_fk<1>(Input::template block<1>(c), out);
+ // Robot cuboids; empty for robots without any
+ const auto robot_cuboids = cuboid_fk(c);
+
Pc filtered;
filtered.reserve(pc.size());
@@ -538,6 +620,34 @@ namespace vamp::binding
}
}
+ // Sphere (the point, inflated by point_radius) vs. each robot cuboid
+ for (const auto &cuboid : robot_cuboids)
+ {
+ if (not valid)
+ {
+ break;
+ }
+
+ const float xs = x - cuboid.x, ys = y - cuboid.y, zs = z - cuboid.z;
+ const float a1 = std::max(
+ std::abs(cuboid.axis_1_x * xs + cuboid.axis_1_y * ys + cuboid.axis_1_z * zs) -
+ cuboid.axis_1_r,
+ 0.F);
+ const float a2 = std::max(
+ std::abs(cuboid.axis_2_x * xs + cuboid.axis_2_y * ys + cuboid.axis_2_z * zs) -
+ cuboid.axis_2_r,
+ 0.F);
+ const float a3 = std::max(
+ std::abs(cuboid.axis_3_x * xs + cuboid.axis_3_y * ys + cuboid.axis_3_z * zs) -
+ cuboid.axis_3_r,
+ 0.F);
+
+ if (a1 * a1 + a2 * a2 + a3 * a3 < r * r)
+ {
+ valid = false;
+ }
+ }
+
if (valid)
{
filtered.emplace_back(point);
@@ -579,7 +689,7 @@ namespace vamp::binding
static auto path_validate(Path &p, const Env &e) -> bool
{
- return p.template validate(EnvVec(e));
+ return p.template validate(make_environment(e));
}
static auto path_numpy(const Path &p)
@@ -643,18 +753,25 @@ namespace vamp::binding
};
template
- inline auto init_robot(nanobind::module_ &pymodule) -> nanobind::module_
+ // `submodule_name` is the name the robot is exposed under in Python. The build uses the same name
+ // (the robot's header name) to list robots and generate stubs, so it has to be what the module is
+ // registered as. It defaults to the robot's own name; they differ for generated robots whose name has
+ // no underscore but whose header does (e.g., KMRIiwaTool is named "kmriiwatool" but lives in
+ // kmriiwa_tool.hh).
+ inline auto init_robot(nanobind::module_ &pymodule, const char *submodule_name = Robot::name)
+ -> nanobind::module_
{
using NA = NDArrayInput;
using CA = ArrayInput;
using TA = StaticRobotTraits;
using TC = StaticRobotTraits;
- auto submodule = pymodule.def_submodule(Robot::name, "Robot-specific submodule");
+ auto submodule = pymodule.def_submodule(submodule_name, "Robot-specific submodule");
submodule.def("dimension", []() { return Robot::dimension; });
submodule.def("resolution", []() { return Robot::resolution; });
submodule.def("n_spheres", []() { return Robot::n_spheres; });
+ submodule.def("n_cuboids", []() { return n_cuboids_v; });
submodule.def("space_measure", []() { return Robot::space_measure(); });
submodule.def(
"min_max_radii",
diff --git a/src/impl/vamp/collision/attachments.hh b/src/impl/vamp/collision/attachments.hh
index 7ad762ab..924343af 100644
--- a/src/impl/vamp/collision/attachments.hh
+++ b/src/impl/vamp/collision/attachments.hh
@@ -34,6 +34,12 @@ namespace vamp::collision
{
spheres.emplace_back(sphere);
}
+
+ cuboids.reserve(o.cuboids.size());
+ for (const auto &cuboid : o.cuboids)
+ {
+ cuboids.emplace_back(cuboid);
+ }
}
// Index into the robot's end-effector list this attachment rides on.
@@ -55,10 +61,17 @@ namespace vamp::collision
return false;
}
+ // The attached geometry, in the attachment's own frame (`tf` relative to the end-effector)
std::vector> spheres;
+ std::vector> cuboids;
+
+ // The attached geometry in the world frame, as of the last call to pose.
// HACK: To get around passing the environment as const but needing to re-pose the
// attachments
mutable std::vector> posed_spheres;
+ // Posed cuboids are OrientedBoxes (rather than Cuboids) since they are recomputed at every
+ // configuration, so they should not pay to precompute a min_distance.
+ mutable std::vector> posed_cuboids;
Eigen::Transform tf;
inline void pose(const Eigen::Transform &p_tf) const noexcept
@@ -73,6 +86,41 @@ namespace vamp::collision
auto tfs = n_tf * sp;
posed_spheres[i] = Sphere(tfs[0], tfs[1], tfs[2], s.r);
}
+
+ // Cuboids move rigidly with the attachment: the center is transformed like a sphere's, and
+ // the axes (directions) are only rotated. The half-lengths are unchanged.
+ posed_cuboids.resize(cuboids.size());
+ const auto &rotation = n_tf.linear();
+ for (auto i = 0U; i < cuboids.size(); ++i)
+ {
+ const auto &c = cuboids[i];
+ Eigen::Matrix center(c.x, c.y, c.z);
+ Eigen::Matrix axis_1(c.axis_1_x, c.axis_1_y, c.axis_1_z);
+ Eigen::Matrix axis_2(c.axis_2_x, c.axis_2_y, c.axis_2_z);
+ Eigen::Matrix axis_3(c.axis_3_x, c.axis_3_y, c.axis_3_z);
+
+ const Eigen::Matrix tc = n_tf * center;
+ const Eigen::Matrix t1 = rotation * axis_1;
+ const Eigen::Matrix t2 = rotation * axis_2;
+ const Eigen::Matrix t3 = rotation * axis_3;
+
+ posed_cuboids[i] = OrientedBox(
+ tc[0],
+ tc[1],
+ tc[2],
+ t1[0],
+ t1[1],
+ t1[2],
+ t2[0],
+ t2[1],
+ t2[2],
+ t3[0],
+ t3[1],
+ t3[2],
+ c.axis_1_r,
+ c.axis_2_r,
+ c.axis_3_r);
+ }
}
};
} // namespace vamp::collision
diff --git a/src/impl/vamp/collision/cuboid_capsule.hh b/src/impl/vamp/collision/cuboid_capsule.hh
new file mode 100644
index 00000000..1fd74a24
--- /dev/null
+++ b/src/impl/vamp/collision/cuboid_capsule.hh
@@ -0,0 +1,110 @@
+#pragma once
+
+#include
+
+#include
+#include
+
+namespace vamp::collision
+{
+ namespace detail
+ {
+ // Squared distance between the segment p(t) = p0 + t * d, t in [0, 1], and an axis-aligned box
+ // centered at the origin with half-lengths `e`. `p0` and `d` are given in the box's frame.
+ //
+ // f(t) = |p(t) - clamp(p(t), -e, e)|^2 is convex and piecewise quadratic, so its derivative
+ // f'(t) / 2 = sum_k d_k * (q_k - clamp(q_k, -e_k, e_k)), q = p(t),
+ // is continuous and nondecreasing. We find its root by bisection with a fixed trip count (so every
+ // SIMD lane does the same work). Since f is minimized there, the error in f is second order in
+ // the bracket width 2^-Iterations: ~1e-6 relative to the segment length squared at the default
+ // of 10, i.e. microns for decimeter-scale links.
+ template
+ inline auto segment_aabb_sql2(
+ const std::array &p0,
+ const std::array &d,
+ const std::array &e) noexcept -> DataT
+ {
+ const std::array ne = {-e[0], -e[1], -e[2]};
+
+ auto excess = [&](const DataT &t, std::array &q, std::array &ex)
+ {
+ for (auto k = 0U; k < 3; ++k)
+ {
+ q[k] = p0[k] + d[k] * t;
+ ex[k] = q[k] - clamp(q[k], ne[k], e[k]);
+ }
+ };
+
+ DataT lo(0.F);
+ DataT hi(1.F);
+
+ std::array q;
+ std::array ex;
+ for (auto i = 0U; i < Iterations; ++i)
+ {
+ const auto mid = (lo + hi) * 0.5F;
+ excess(mid, q, ex);
+
+ // Derivative at mid > 0 => minimizer is left of mid
+ const auto grad = dot_3(d[0], d[1], d[2], ex[0], ex[1], ex[2]);
+ hi = hi.blend(mid, grad > 0.F);
+ lo = lo.blend(mid, grad <= 0.F);
+ }
+
+ const auto t = (lo + hi) * 0.5F;
+ excess(t, q, ex);
+ return dot_3(ex[0], ex[1], ex[2], ex[0], ex[1], ex[2]);
+ }
+
+ template
+ inline auto cuboid_segment_sql2(
+ const BoxT &c,
+ const DataT &x1,
+ const DataT &y1,
+ const DataT &z1,
+ const DataT &xv,
+ const DataT &yv,
+ const DataT &zv) noexcept -> DataT
+ {
+ const auto xs = x1 - c.x;
+ const auto ys = y1 - c.y;
+ const auto zs = z1 - c.z;
+
+ const std::array p0 = {
+ dot_3(c.axis_1_x, c.axis_1_y, c.axis_1_z, xs, ys, zs),
+ dot_3(c.axis_2_x, c.axis_2_y, c.axis_2_z, xs, ys, zs),
+ dot_3(c.axis_3_x, c.axis_3_y, c.axis_3_z, xs, ys, zs)};
+
+ const std::array d = {
+ dot_3(c.axis_1_x, c.axis_1_y, c.axis_1_z, xv, yv, zv),
+ dot_3(c.axis_2_x, c.axis_2_y, c.axis_2_z, xv, yv, zv),
+ dot_3(c.axis_3_x, c.axis_3_y, c.axis_3_z, xv, yv, zv)};
+
+ const std::array e = {c.axis_1_r, c.axis_2_r, c.axis_3_r};
+
+ return segment_aabb_sql2(p0, d, e);
+ }
+ } // namespace detail
+
+ // Robot box `c` vs. environment capsule. Negative in lanes that collide.
+ //
+ // This is exact up to the bisection tolerance documented in detail::segment_aabb_sql2.
+ template
+ inline auto cuboid_capsule(const BoxT &c, const Capsule &cap) noexcept -> DataT
+ {
+ const auto sql2 = detail::cuboid_segment_sql2(
+ c, cap.x1, cap.y1, cap.z1, cap.xv, cap.yv, cap.zv);
+ return sql2 - cap.r * cap.r;
+ }
+
+ // As above, for a z-aligned capsule, whose axis is (0, 0, zv) from (x1, y1, z1); only z1 and zv are
+ // read from the vector, matching sphere_z_aligned_capsule.
+ template
+ inline auto cuboid_z_aligned_capsule(const BoxT &c, const Capsule &cap) noexcept -> DataT
+ {
+ const DataT zero(0.F);
+ const auto sql2 =
+ detail::cuboid_segment_sql2(c, cap.x1, cap.y1, cap.z1, zero, zero, cap.zv);
+ return sql2 - cap.r * cap.r;
+ }
+} // namespace vamp::collision
diff --git a/src/impl/vamp/collision/cuboid_cuboid.hh b/src/impl/vamp/collision/cuboid_cuboid.hh
new file mode 100644
index 00000000..e8c76694
--- /dev/null
+++ b/src/impl/vamp/collision/cuboid_cuboid.hh
@@ -0,0 +1,154 @@
+#pragma once
+
+#include
+
+#include
+#include
+
+// Oriented box vs. oriented box collision checking via the separating axis theorem (SAT).
+//
+// Convention (shared with all kernels in this directory): the returned vector is NEGATIVE in lanes
+// where the shapes overlap, so `not result.test_zero()` means "some lane is in collision".
+//
+// NOTE: Unlike the sphere kernels, the magnitude is NOT a distance. It is the largest signed gap over
+// all 15 candidate axes, and the nine edge-edge axes are not normalized, so only the sign is
+// meaningful.
+namespace vamp::collision
+{
+ namespace detail
+ {
+ // Added to |R| so that nearly-parallel edge pairs (whose cross product axis degenerates to ~0)
+ // are never reported as separating because of floating point noise. This makes the test
+ // slightly conservative: boxes within ~eps * (sum of half-lengths) of touching are reported as
+ // colliding.
+ inline constexpr float sat_epsilon = 1e-5F;
+
+ // Core of the SAT test, following Ericson, Real-Time Collision Detection, 4.4.1.
+ //
+ // - `ea`, `eb`: half-lengths of boxes A and B along their own axes.
+ // - `R[i][j]`: dot(A axis i, B axis j), i.e., B's axes expressed in A's frame.
+ // - `t[i]`: dot(B center - A center, A axis i), i.e., the center offset in A's frame.
+ template
+ inline auto box_box_separation(
+ const std::array &ea,
+ const std::array &eb,
+ const std::array, 3> &R,
+ const std::array &t) noexcept -> DataT
+ {
+ std::array, 3> abs_r;
+ for (auto i = 0U; i < 3; ++i)
+ {
+ for (auto j = 0U; j < 3; ++j)
+ {
+ abs_r[i][j] = R[i][j].abs() + sat_epsilon;
+ }
+ }
+
+ // Face axes of A
+ DataT gap = t[0].abs() - (ea[0] + eb[0] * abs_r[0][0] + eb[1] * abs_r[0][1] + eb[2] * abs_r[0][2]);
+ for (auto i = 1U; i < 3; ++i)
+ {
+ gap = gap.max(
+ t[i].abs() -
+ (ea[i] + eb[0] * abs_r[i][0] + eb[1] * abs_r[i][1] + eb[2] * abs_r[i][2]));
+ }
+
+ // Face axes of B
+ for (auto j = 0U; j < 3; ++j)
+ {
+ const auto proj = t[0] * R[0][j] + t[1] * R[1][j] + t[2] * R[2][j];
+ const auto ra = ea[0] * abs_r[0][j] + ea[1] * abs_r[1][j] + ea[2] * abs_r[2][j];
+ gap = gap.max(proj.abs() - (ra + eb[j]));
+ }
+
+ // Edge-edge axes: A axis i x B axis j
+ for (auto i = 0U; i < 3; ++i)
+ {
+ const auto i1 = (i + 1) % 3;
+ const auto i2 = (i + 2) % 3;
+
+ for (auto j = 0U; j < 3; ++j)
+ {
+ const auto j1 = (j + 1) % 3;
+ const auto j2 = (j + 2) % 3;
+
+ const auto ra = ea[i1] * abs_r[i2][j] + ea[i2] * abs_r[i1][j];
+ const auto rb = eb[j1] * abs_r[i][j2] + eb[j2] * abs_r[i][j1];
+ const auto proj = t[i2] * R[i1][j] - t[i1] * R[i2][j];
+ gap = gap.max(proj.abs() - (ra + rb));
+ }
+ }
+
+ return gap;
+ }
+ } // namespace detail
+
+ // Collision between a (robot) box `a` and an (environment) cuboid `b`. Either may be an
+ // OrientedBox or a Cuboid; they only need the shared field layout and the same DataT.
+ template
+ inline auto cuboid_cuboid(const BoxA &a, const BoxB &b) noexcept -> decltype(a.x)
+ {
+ using DataT = decltype(a.x);
+
+ const std::array ea = {a.axis_1_r, a.axis_2_r, a.axis_3_r};
+ const std::array eb = {b.axis_1_r, b.axis_2_r, b.axis_3_r};
+
+ const std::array, 3> R = {{
+ {dot_3(a.axis_1_x, a.axis_1_y, a.axis_1_z, b.axis_1_x, b.axis_1_y, b.axis_1_z),
+ dot_3(a.axis_1_x, a.axis_1_y, a.axis_1_z, b.axis_2_x, b.axis_2_y, b.axis_2_z),
+ dot_3(a.axis_1_x, a.axis_1_y, a.axis_1_z, b.axis_3_x, b.axis_3_y, b.axis_3_z)},
+ {dot_3(a.axis_2_x, a.axis_2_y, a.axis_2_z, b.axis_1_x, b.axis_1_y, b.axis_1_z),
+ dot_3(a.axis_2_x, a.axis_2_y, a.axis_2_z, b.axis_2_x, b.axis_2_y, b.axis_2_z),
+ dot_3(a.axis_2_x, a.axis_2_y, a.axis_2_z, b.axis_3_x, b.axis_3_y, b.axis_3_z)},
+ {dot_3(a.axis_3_x, a.axis_3_y, a.axis_3_z, b.axis_1_x, b.axis_1_y, b.axis_1_z),
+ dot_3(a.axis_3_x, a.axis_3_y, a.axis_3_z, b.axis_2_x, b.axis_2_y, b.axis_2_z),
+ dot_3(a.axis_3_x, a.axis_3_y, a.axis_3_z, b.axis_3_x, b.axis_3_y, b.axis_3_z)},
+ }};
+
+ const auto dx = b.x - a.x;
+ const auto dy = b.y - a.y;
+ const auto dz = b.z - a.z;
+
+ const std::array t = {
+ dot_3(dx, dy, dz, a.axis_1_x, a.axis_1_y, a.axis_1_z),
+ dot_3(dx, dy, dz, a.axis_2_x, a.axis_2_y, a.axis_2_z),
+ dot_3(dx, dy, dz, a.axis_3_x, a.axis_3_y, a.axis_3_z)};
+
+ return detail::box_box_separation(ea, eb, R, t);
+ }
+
+ // Same as cuboid_cuboid, but `b` is a z-aligned cuboid (see Environment::z_aligned_cuboids): its
+ // third axis is exactly +z and the other two lie in the xy-plane, so only their x/y components are
+ // read, matching sphere_z_aligned_cuboid. This makes the rotation matrix cheaper to form.
+ template
+ inline auto cuboid_z_aligned_cuboid(const BoxA &a, const BoxB &b) noexcept -> decltype(a.x)
+ {
+ using DataT = decltype(a.x);
+
+ const std::array ea = {a.axis_1_r, a.axis_2_r, a.axis_3_r};
+ const std::array eb = {b.axis_1_r, b.axis_2_r, b.axis_3_r};
+
+ const std::array, 3> R = {{
+ {dot_2(a.axis_1_x, a.axis_1_y, b.axis_1_x, b.axis_1_y),
+ dot_2(a.axis_1_x, a.axis_1_y, b.axis_2_x, b.axis_2_y),
+ a.axis_1_z},
+ {dot_2(a.axis_2_x, a.axis_2_y, b.axis_1_x, b.axis_1_y),
+ dot_2(a.axis_2_x, a.axis_2_y, b.axis_2_x, b.axis_2_y),
+ a.axis_2_z},
+ {dot_2(a.axis_3_x, a.axis_3_y, b.axis_1_x, b.axis_1_y),
+ dot_2(a.axis_3_x, a.axis_3_y, b.axis_2_x, b.axis_2_y),
+ a.axis_3_z},
+ }};
+
+ const auto dx = b.x - a.x;
+ const auto dy = b.y - a.y;
+ const auto dz = b.z - a.z;
+
+ const std::array t = {
+ dot_3(dx, dy, dz, a.axis_1_x, a.axis_1_y, a.axis_1_z),
+ dot_3(dx, dy, dz, a.axis_2_x, a.axis_2_y, a.axis_2_z),
+ dot_3(dx, dy, dz, a.axis_3_x, a.axis_3_y, a.axis_3_z)};
+
+ return detail::box_box_separation(ea, eb, R, t);
+ }
+} // namespace vamp::collision
diff --git a/src/impl/vamp/collision/cuboid_heightfield.hh b/src/impl/vamp/collision/cuboid_heightfield.hh
new file mode 100644
index 00000000..85254ab2
--- /dev/null
+++ b/src/impl/vamp/collision/cuboid_heightfield.hh
@@ -0,0 +1,56 @@
+#pragma once
+
+#include
+
+#include
+#include
+#include
+
+namespace vamp::collision
+{
+ // Robot box `c` vs. heightfield. Negative in lanes that collide.
+ //
+ // APPROXIMATE. sphere_heightfield only compares one height sample (the cell under the query point)
+ // against the query point, so a box is tested by posing a regular lattice of `Samples` points per
+ // axis over the box's volume (Samples = 2 is just the 8 corners; the default of 3 adds edge
+ // midpoints, face centers and the center) and taking the lowest clearance over all of them.
+ //
+ // This can miss thin terrain features that fit between lattice points, e.g., a narrow bump under the
+ // middle of a large flat face. Raise `Samples` for large links or rough terrain; the cost is
+ // Samples^3 gathers.
+ template
+ inline auto cuboid_heightfield(const BoxT &c, const HeightField &h) noexcept -> DataT
+ {
+ static_assert(Samples >= 2, "Need at least the two extremes along each axis");
+
+ const DataT zero(0.F);
+ DataT result(std::numeric_limits::max());
+
+ for (auto i = 0U; i < Samples; ++i)
+ {
+ const float si = -1.F + 2.F * static_cast(i) / static_cast(Samples - 1);
+ for (auto j = 0U; j < Samples; ++j)
+ {
+ const float sj = -1.F + 2.F * static_cast(j) / static_cast(Samples - 1);
+ for (auto k = 0U; k < Samples; ++k)
+ {
+ const float sk = -1.F + 2.F * static_cast(k) / static_cast(Samples - 1);
+
+ const auto a = c.axis_1_r * si;
+ const auto b = c.axis_2_r * sj;
+ const auto d = c.axis_3_r * sk;
+
+ const auto px = c.x + c.axis_1_x * a + c.axis_2_x * b + c.axis_3_x * d;
+ const auto py = c.y + c.axis_1_y * a + c.axis_2_y * b + c.axis_3_y * d;
+ const auto pz = c.z + c.axis_1_z * a + c.axis_2_z * b + c.axis_3_z * d;
+
+ // Elementwise min(result, clearance), via max on the negation
+ const auto clearance = sphere_heightfield(h, px, py, pz, zero);
+ result = -((-result).max(-clearance));
+ }
+ }
+ }
+
+ return result;
+ }
+} // namespace vamp::collision
diff --git a/src/impl/vamp/collision/cuboid_sphere.hh b/src/impl/vamp/collision/cuboid_sphere.hh
new file mode 100644
index 00000000..9c41e3a6
--- /dev/null
+++ b/src/impl/vamp/collision/cuboid_sphere.hh
@@ -0,0 +1,39 @@
+#pragma once
+
+#include
+#include
+
+namespace vamp::collision
+{
+ // Squared distance from the point (x, y, z) to the (solid) box; zero inside the box.
+ template
+ inline auto
+ point_cuboid_sql2(const BoxT &c, const DataT &x, const DataT &y, const DataT &z) noexcept -> DataT
+ {
+ const auto xs = x - c.x;
+ const auto ys = y - c.y;
+ const auto zs = z - c.z;
+
+ const auto a1 = (dot_3(c.axis_1_x, c.axis_1_y, c.axis_1_z, xs, ys, zs).abs() - c.axis_1_r).max(0.);
+ const auto a2 = (dot_3(c.axis_2_x, c.axis_2_y, c.axis_2_z, xs, ys, zs).abs() - c.axis_2_r).max(0.);
+ const auto a3 = (dot_3(c.axis_3_x, c.axis_3_y, c.axis_3_z, xs, ys, zs).abs() - c.axis_3_r).max(0.);
+
+ return dot_3(a1, a2, a3, a1, a2, a3);
+ }
+
+ // Robot box `c` vs. environment sphere with center (x, y, z) and radius r.
+ // Negative in lanes that collide.
+ template
+ inline auto
+ cuboid_sphere(const BoxT &c, const DataT &x, const DataT &y, const DataT &z, const DataT &r) noexcept
+ -> DataT
+ {
+ return point_cuboid_sql2(c, x, y, z) - r * r;
+ }
+
+ template
+ inline auto cuboid_sphere(const BoxT &c, const Sphere &s) noexcept -> DataT
+ {
+ return cuboid_sphere(c, s.x, s.y, s.z, s.r);
+ }
+} // namespace vamp::collision
diff --git a/src/impl/vamp/collision/shapes.hh b/src/impl/vamp/collision/shapes.hh
index 19b001ba..96d77c0a 100644
--- a/src/impl/vamp/collision/shapes.hh
+++ b/src/impl/vamp/collision/shapes.hh
@@ -126,6 +126,98 @@ namespace vamp::collision
}
};
+ // A lightweight oriented box meant for *robot* collision geometry, i.e., a link cuboid posed by
+ // forward kinematics. It has the same field layout as Cuboid (center, three unit axes, three
+ // half-lengths) so the cuboid_* collision kernels accept either, but it is a plain aggregate: it
+ // carries no name and does not precompute min_distance, which is wasted work for geometry that is
+ // re-posed on every configuration.
+ //
+ // All fields are DataT so, as with the environment's shapes, each SIMD lane can hold a different
+ // pose.
+ template
+ struct OrientedBox
+ {
+ DataT x;
+ DataT y;
+ DataT z;
+
+ DataT axis_1_x;
+ DataT axis_1_y;
+ DataT axis_1_z;
+ DataT axis_2_x;
+ DataT axis_2_y;
+ DataT axis_2_z;
+ DataT axis_3_x;
+ DataT axis_3_y;
+ DataT axis_3_z;
+
+ DataT axis_1_r;
+ DataT axis_2_r;
+ DataT axis_3_r;
+
+ OrientedBox() = default;
+
+ explicit OrientedBox(
+ DataT x,
+ DataT y,
+ DataT z, //
+ DataT axis_1_x,
+ DataT axis_1_y,
+ DataT axis_1_z, //
+ DataT axis_2_x,
+ DataT axis_2_y,
+ DataT axis_2_z, //
+ DataT axis_3_x,
+ DataT axis_3_y,
+ DataT axis_3_z, //
+ DataT axis_1_r,
+ DataT axis_2_r,
+ DataT axis_3_r)
+ : x(x)
+ , y(y)
+ , z(z)
+ , axis_1_x(axis_1_x)
+ , axis_1_y(axis_1_y)
+ , axis_1_z(axis_1_z)
+ , axis_2_x(axis_2_x)
+ , axis_2_y(axis_2_y)
+ , axis_2_z(axis_2_z)
+ , axis_3_x(axis_3_x)
+ , axis_3_y(axis_3_y)
+ , axis_3_z(axis_3_z)
+ , axis_1_r(axis_1_r)
+ , axis_2_r(axis_2_r)
+ , axis_3_r(axis_3_r)
+ {
+ }
+
+ explicit OrientedBox(const Cuboid &c)
+ : OrientedBox(
+ c.x,
+ c.y,
+ c.z,
+ c.axis_1_x,
+ c.axis_1_y,
+ c.axis_1_z,
+ c.axis_2_x,
+ c.axis_2_y,
+ c.axis_2_z,
+ c.axis_3_x,
+ c.axis_3_y,
+ c.axis_3_z,
+ c.axis_1_r,
+ c.axis_2_r,
+ c.axis_3_r)
+ {
+ }
+
+ // Radius of the smallest sphere centered at (x, y, z) that contains the box.
+ inline constexpr auto bounding_radius() const noexcept -> DataT
+ {
+ return sqrt(dot_3(axis_1_r, axis_2_r, axis_3_r, axis_1_r, axis_2_r, axis_3_r));
+ }
+ };
+
// A cylinder shape oriented in an arbitrary frame. The cylinder is defined by
// two endpoints, which we store as the first point (x1, y1, z1) and the vector
// from the first point to the second point (xv, yv, zv), and its radius (r)
diff --git a/src/impl/vamp/collision/validity.hh b/src/impl/vamp/collision/validity.hh
index 32576d04..25371e27 100644
--- a/src/impl/vamp/collision/validity.hh
+++ b/src/impl/vamp/collision/validity.hh
@@ -6,8 +6,14 @@
#include
#include
#include
+#include
+#include
+#include
+#include
#include
+#include
+
namespace vamp
{
template <
@@ -248,9 +254,308 @@ namespace vamp
return objects;
}
+ // Robot cuboid vs. environment collision checking.
+ //
+ // Pointclouds (CAPT) are not supported: the CAPT affordance tree is built for sphere queries of a
+ // bounded radius and has no meaningful query for a box. Rather than silently ignoring the pointcloud
+ // (which would report free space where there is none), these throw if the environment has one. Call
+ // check_cuboid_environment_supported once up front (e.g., in bindings) so the error surfaces
+ // cleanly: robots' fkcc functions are noexcept, so a throw from inside one terminates the program.
template
- inline constexpr auto attachment_environment_collision(const collision::Environment &e) noexcept
- -> bool
+ inline void check_cuboid_environment_supported(const collision::Environment &e)
+ {
+ if (not e.pointclouds.empty())
+ {
+ throw std::runtime_error(
+ "Cuboid collision geometry (on the robot or in an attachment) does not support pointcloud (CAPT) "
+ "environments.");
+ }
+ }
+
+ template
+ inline auto cuboid_environment_in_collision(
+ const collision::Environment &e,
+ const collision::OrientedBox &box) -> bool
+ {
+ check_cuboid_environment_supported(e);
+
+ // Bounding sphere about the origin of the box, for early-out against the sorted environment
+ const auto max_extent =
+ collision::sqrt(collision::dot_3(box.x, box.y, box.z, box.x, box.y, box.z)) +
+ box.bounding_radius();
+
+ for (const auto &es : e.spheres)
+ {
+ if ((es.min_distance - max_extent).test_zero())
+ {
+ break;
+ }
+
+ if (not collision::cuboid_sphere(box, es).test_zero())
+ {
+ return true;
+ }
+ }
+
+ for (const auto &ec : e.capsules)
+ {
+ if ((ec.min_distance - max_extent).test_zero())
+ {
+ break;
+ }
+
+ if (not collision::cuboid_capsule(box, ec).test_zero())
+ {
+ return true;
+ }
+ }
+
+ for (const auto &ec : e.z_aligned_capsules)
+ {
+ if ((ec.min_distance - max_extent).test_zero())
+ {
+ break;
+ }
+
+ if (not collision::cuboid_z_aligned_capsule(box, ec).test_zero())
+ {
+ return true;
+ }
+ }
+
+ for (const auto &ec : e.cuboids)
+ {
+ if ((ec.min_distance - max_extent).test_zero())
+ {
+ break;
+ }
+
+ if (not collision::cuboid_cuboid(box, ec).test_zero())
+ {
+ return true;
+ }
+ }
+
+ for (const auto &ec : e.z_aligned_cuboids)
+ {
+ if ((ec.min_distance - max_extent).test_zero())
+ {
+ break;
+ }
+
+ if (not collision::cuboid_z_aligned_cuboid(box, ec).test_zero())
+ {
+ return true;
+ }
+ }
+
+ for (const auto &eh : e.heightfields)
+ {
+ if (not collision::cuboid_heightfield(box, eh).test_zero())
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ template
+ inline auto cuboid_environment_get_collisions(
+ const collision::Environment &e,
+ const collision::OrientedBox &box) -> std::vector
+ {
+ check_cuboid_environment_supported(e);
+
+ std::vector objects;
+
+ const auto max_extent =
+ collision::sqrt(collision::dot_3(box.x, box.y, box.z, box.x, box.y, box.z)) +
+ box.bounding_radius();
+
+ for (const auto &es : e.spheres)
+ {
+ if ((es.min_distance - max_extent).test_zero())
+ {
+ break;
+ }
+
+ if (not collision::cuboid_sphere(box, es).test_zero())
+ {
+ objects.emplace_back(es.name);
+ }
+ }
+
+ for (const auto &ec : e.capsules)
+ {
+ if ((ec.min_distance - max_extent).test_zero())
+ {
+ break;
+ }
+
+ if (not collision::cuboid_capsule(box, ec).test_zero())
+ {
+ objects.emplace_back(ec.name);
+ }
+ }
+
+ for (const auto &ec : e.z_aligned_capsules)
+ {
+ if ((ec.min_distance - max_extent).test_zero())
+ {
+ break;
+ }
+
+ if (not collision::cuboid_z_aligned_capsule(box, ec).test_zero())
+ {
+ objects.emplace_back(ec.name);
+ }
+ }
+
+ for (const auto &ec : e.cuboids)
+ {
+ if ((ec.min_distance - max_extent).test_zero())
+ {
+ break;
+ }
+
+ if (not collision::cuboid_cuboid(box, ec).test_zero())
+ {
+ objects.emplace_back(ec.name);
+ }
+ }
+
+ for (const auto &ec : e.z_aligned_cuboids)
+ {
+ if ((ec.min_distance - max_extent).test_zero())
+ {
+ break;
+ }
+
+ if (not collision::cuboid_z_aligned_cuboid(box, ec).test_zero())
+ {
+ objects.emplace_back(ec.name);
+ }
+ }
+
+ for (const auto &eh : e.heightfields)
+ {
+ if (not collision::cuboid_heightfield(box, eh).test_zero())
+ {
+ objects.emplace_back(eh.name);
+ }
+ }
+
+ return objects;
+ }
+
+ // Robot self-collision checks involving cuboids. Both bodies are robot geometry, so (unlike the
+ // environment checks) neither throws and both are safe to call from noexcept code.
+ template
+ inline auto sphere_cuboid_self_collision(
+ const collision::OrientedBox &box,
+ const DataT &sx,
+ const DataT &sy,
+ const DataT &sz,
+ const DataT &sr) noexcept -> bool
+ {
+ return not collision::cuboid_sphere(box, sx, sy, sz, sr).test_zero();
+ }
+
+ template
+ inline auto cuboid_cuboid_self_collision(
+ const collision::OrientedBox &a,
+ const collision::OrientedBox &b) noexcept -> bool
+ {
+ return not collision::cuboid_cuboid(a, b).test_zero();
+ }
+
+ // Robot cuboid vs. the objects attached to end-effector `end_effector` (their spheres and cuboids)
+ template
+ inline auto attachment_cuboid_collision(
+ const collision::Environment &e,
+ std::size_t end_effector,
+ const collision::OrientedBox &box) noexcept -> bool
+ {
+ for (const auto &attachment : e.attachments)
+ {
+ if (attachment.end_effector != end_effector)
+ {
+ continue;
+ }
+
+ for (const auto &att_s : attachment.posed_spheres)
+ {
+ if (not collision::cuboid_sphere(box, att_s.x, att_s.y, att_s.z, att_s.r).test_zero())
+ {
+ return true;
+ }
+ }
+
+ for (const auto &att_c : attachment.posed_cuboids)
+ {
+ if (not collision::cuboid_cuboid(box, att_c).test_zero())
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ // As above for robot link `link`: attachments that are allowed to touch that link are skipped.
+ template
+ inline auto attachment_cuboid_collision(
+ const collision::Environment &e,
+ std::size_t end_effector,
+ std::size_t link,
+ const collision::OrientedBox &box) noexcept -> bool
+ {
+ for (const auto &attachment : e.attachments)
+ {
+ if (attachment.end_effector != end_effector or attachment.allows(link))
+ {
+ continue;
+ }
+
+ for (const auto &att_s : attachment.posed_spheres)
+ {
+ if (not collision::cuboid_sphere(box, att_s.x, att_s.y, att_s.z, att_s.r).test_zero())
+ {
+ return true;
+ }
+ }
+
+ for (const auto &att_c : attachment.posed_cuboids)
+ {
+ if (not collision::cuboid_cuboid(box, att_c).test_zero())
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ // Single-attachment form of the previous generators: checks against the attachments of end-effector 0.
+ template
+ inline auto attachment_cuboid_collision(
+ const collision::Environment &e,
+ const collision::OrientedBox &box) noexcept -> bool
+ {
+ return attachment_cuboid_collision(e, std::size_t{0}, box);
+ }
+
+ // Attached objects vs. the environment.
+ //
+ // As for robot cuboids, attached cuboids do not support pointcloud (CAPT) environments (see
+ // check_cuboid_environment_supported), and as everything that calls this is noexcept, an attachment
+ // with cuboids in such an environment terminates the program. Callers (e.g., bindings) should check
+ // ahead of time.
+ template
+ inline auto attachment_environment_collision(const collision::Environment &e) noexcept -> bool
{
for (const auto &attachment : e.attachments)
{
@@ -265,14 +570,23 @@ namespace vamp
return true;
}
}
+
+ for (const auto &c : attachment.posed_cuboids)
+ {
+ if (cuboid_environment_in_collision(e, c))
+ {
+ return true;
+ }
+ }
}
return false;
}
- // Checks a robot sphere against every attachment riding on end-effector `end_effector`.
+ // Checks a robot sphere against every attachment riding on end-effector `end_effector` (spheres and
+ // cuboids).
template
- inline constexpr auto attachment_sphere_collision(
+ inline auto attachment_sphere_collision(
const collision::Environment &e,
std::size_t end_effector,
ArgT1 sx_,
@@ -300,6 +614,14 @@ namespace vamp
return true;
}
}
+
+ for (const auto &att_c : attachment.posed_cuboids)
+ {
+ if (not collision::cuboid_sphere(att_c, sx, sy, sz, sr).test_zero())
+ {
+ return true;
+ }
+ }
}
return false;
@@ -307,7 +629,7 @@ namespace vamp
// As above for robot link `link`: attachments that are allowed to touch that link are skipped.
template
- inline constexpr auto attachment_sphere_collision(
+ inline auto attachment_sphere_collision(
const collision::Environment &e,
std::size_t end_effector,
std::size_t link,
@@ -335,6 +657,14 @@ namespace vamp
return true;
}
}
+
+ for (const auto &att_c : attachment.posed_cuboids)
+ {
+ if (not collision::cuboid_sphere(att_c, sx, sy, sz, sr).test_zero())
+ {
+ return true;
+ }
+ }
}
return false;
@@ -352,11 +682,10 @@ namespace vamp
return attachment_sphere_collision(e, std::size_t{0}, sx_, sy_, sz_, sr_);
}
- // Checks attachments on different end-effectors against each other; attachments riding
- // on the same end-effector move rigidly together and are never tested.
+ // Checks attachments on different end-effectors against each other (spheres and cuboids); attachments
+ // riding on the same end-effector move rigidly together and are never tested.
template
- inline constexpr auto attachment_attachment_collision(const collision::Environment &e) noexcept
- -> bool
+ inline auto attachment_attachment_collision(const collision::Environment &e) noexcept -> bool
{
for (auto i = 0U; i < e.attachments.size(); ++i)
{
@@ -379,6 +708,33 @@ namespace vamp
return true;
}
}
+
+ for (const auto &cb : b.posed_cuboids)
+ {
+ if (not collision::cuboid_sphere(cb, sa.x, sa.y, sa.z, sa.r).test_zero())
+ {
+ return true;
+ }
+ }
+ }
+
+ for (const auto &ca : a.posed_cuboids)
+ {
+ for (const auto &sb : b.posed_spheres)
+ {
+ if (not collision::cuboid_sphere(ca, sb.x, sb.y, sb.z, sb.r).test_zero())
+ {
+ return true;
+ }
+ }
+
+ for (const auto &cb : b.posed_cuboids)
+ {
+ if (not collision::cuboid_cuboid(ca, cb).test_zero())
+ {
+ return true;
+ }
+ }
}
}
}
diff --git a/src/impl/vamp/robots/kmriiwa_tool.hh b/src/impl/vamp/robots/kmriiwa_tool.hh
new file mode 100644
index 00000000..828fdf4c
--- /dev/null
+++ b/src/impl/vamp/robots/kmriiwa_tool.hh
@@ -0,0 +1,48054 @@
+#pragma once
+
+#include
+#include
+#include
+#include
+
+// NOLINTBEGIN(*-magic-numbers)
+namespace vamp::robots
+{
+struct KMRIiwaTool
+{
+ static constexpr const char *name = "kmriiwatool";
+ static constexpr std::size_t dimension = 10;
+ static constexpr std::size_t sample_dimension = 10;
+ static constexpr std::size_t n_spheres = 52;
+ static constexpr std::size_t n_cuboids = 1;
+ static constexpr float min_radius = 0.02334415912628174;
+ static constexpr float max_radius = 0.10876917093992233;
+ static constexpr float min_radius_mobile = 0.02334415912628174;
+ static constexpr float max_radius_mobile = 0.10876917093992233;
+ static constexpr float min_bounding_radius_mobile = 0.0662180483341217;
+ static constexpr float max_bounding_radius_mobile = 0.7391563653945923;
+ static constexpr std::array base_position = { 0.0, 0.0, 0.0 };
+ static constexpr std::size_t resolution = 32;
+ static constexpr bool euclidean = true;
+
+ static constexpr std::array joint_names = {"kmr_base/x", "kmr_base/y", "kmr_base/theta", "iiwa/iiwa_joint_1", "iiwa/iiwa_joint_2", "iiwa/iiwa_joint_3", "iiwa/iiwa_joint_4", "iiwa/iiwa_joint_5", "iiwa/iiwa_joint_6", "iiwa/iiwa_joint_7"};
+ static constexpr const char *end_effector = "wsg/tool";
+
+ using Configuration = FloatVector;
+ using ConfigurationArray = std::array;
+ using Sample = FloatVector;
+
+ static constexpr std::array so3_offsets = { };
+
+ struct alignas(FloatVectorAlignment) ConfigurationBuffer
+ : std::array
+ {
+ };
+
+ template
+ using ConfigurationBlock = FloatVector;
+
+ template
+ struct Spheres
+ {
+ FloatVector x;
+ FloatVector y;
+ FloatVector z;
+ FloatVector r;
+ };
+
+
+ // Cuboid collision geometry, one row per cuboid. The layout matches vamp::collision::OrientedBox:
+ // center, three unit axes, and half-lengths along each axis.
+ template
+ struct Cuboids
+ {
+ FloatVector x;
+ FloatVector y;
+ FloatVector z;
+ FloatVector axis_1_x;
+ FloatVector axis_1_y;
+ FloatVector axis_1_z;
+ FloatVector axis_2_x;
+ FloatVector axis_2_y;
+ FloatVector axis_2_z;
+ FloatVector axis_3_x;
+ FloatVector axis_3_y;
+ FloatVector axis_3_z;
+ FloatVector axis_1_r;
+ FloatVector axis_2_r;
+ FloatVector axis_3_r;
+ };
+
+
+ alignas(Configuration::S::Alignment) static constexpr std::array s_m{
+ 4.0, 4.0, 6.2831854820251465, 5.93411922454834, 4.188790321350098, 5.93411922454834, 4.188790321350098, 5.93411922454834, 4.188790321350098, 6.108652591705322
+ };
+
+ alignas(Configuration::S::Alignment) static constexpr std::array s_a{
+ -2.0, -2.0, -3.1415927410125732, -2.96705961227417, -2.094395160675049, -2.96705961227417, -2.094395160675049, -2.96705961227417, -2.094395160675049, -3.054326295852661
+ };
+
+ alignas(Configuration::S::Alignment) static constexpr std::array d_m{
+ 0.25, 0.25, 0.15915493667125702, 0.16851699352264404, 0.23873241245746613, 0.16851699352264404, 0.23873241245746613, 0.16851699352264404, 0.23873241245746613, 0.16370223462581635
+ };
+
+ static inline void scale_configuration(Configuration& q) noexcept
+ {
+ q = q * Configuration(s_m) + Configuration(s_a);
+ }
+
+ static inline void descale_configuration(Configuration& q) noexcept
+ {
+ q = (q - Configuration(s_a)) * Configuration(d_m);
+ }
+
+ template
+ static inline void scale_configuration_block(ConfigurationBlock &q) noexcept
+ {
+ q[0] = -2.0 + (q[0] * 4.0);
+q[1] = -2.0 + (q[1] * 4.0);
+q[2] = -3.1415927410125732 + (q[2] * 6.2831854820251465);
+q[3] = -2.96705961227417 + (q[3] * 5.93411922454834);
+q[4] = -2.094395160675049 + (q[4] * 4.188790321350098);
+q[5] = -2.96705961227417 + (q[5] * 5.93411922454834);
+q[6] = -2.094395160675049 + (q[6] * 4.188790321350098);
+q[7] = -2.96705961227417 + (q[7] * 5.93411922454834);
+q[8] = -2.094395160675049 + (q[8] * 4.188790321350098);
+q[9] = -3.054326295852661 + (q[9] * 6.108652591705322);
+
+ }
+
+ template
+ static inline void descale_configuration_block(ConfigurationBlock & q) noexcept
+ {
+ q[0] = 0.25 * (q[0] - -2.0);
+q[1] = 0.25 * (q[1] - -2.0);
+q[2] = 0.15915493667125702 * (q[2] - -3.1415927410125732);
+q[3] = 0.16851699352264404 * (q[3] - -2.96705961227417);
+q[4] = 0.23873241245746613 * (q[4] - -2.094395160675049);
+q[5] = 0.16851699352264404 * (q[5] - -2.96705961227417);
+q[6] = 0.23873241245746613 * (q[6] - -2.094395160675049);
+q[7] = 0.16851699352264404 * (q[7] - -2.96705961227417);
+q[8] = 0.23873241245746613 * (q[8] - -2.094395160675049);
+q[9] = 0.16370223462581635 * (q[9] - -3.054326295852661);
+
+ }
+
+ inline static auto space_measure() noexcept -> float
+ {
+ return 9431482.0;
+ }
+
+ alignas(Configuration::S::Alignment) static constexpr std::array lower_bound{
+ -2.0, -2.0, -3.1415927410125732, -2.96705961227417, -2.094395160675049, -2.96705961227417, -2.094395160675049, -2.96705961227417, -2.094395160675049, -3.054326295852661
+ };
+
+ alignas(Configuration::S::Alignment) static constexpr std::array upper_bound{
+ 2.0, 2.0, 3.1415927410125732, 2.96705961227417, 2.094395160675049, 2.96705961227417, 2.094395160675049, 2.96705961227417, 2.094395160675049, 3.054326295852661
+ };
+
+ static inline auto in_bounds(const Configuration &x) -> bool
+ {
+ return (x <= Configuration(upper_bound)).all() and (x >= Configuration(lower_bound)).all();
+ }
+
+ static inline auto sample(const Sample &x_in) -> Configuration
+ {
+
+ // Euclidean fast path: same affine map as scale_configuration,
+ // operating on the packed FloatVector in one SIMD step. Sample and
+ // Configuration alias to the same FloatVector type when Euclidean.
+ Configuration q = x_in;
+ scale_configuration(q);
+ return q;
+
+ }
+
+ static inline auto distance(const Configuration &a_in, const Configuration &b_in) -> float
+ {
+
+ return a_in.distance(b_in);
+
+ }
+
+ static inline auto interpolate(const Configuration &a_in, const Configuration &b_in, float t) -> Configuration
+ {
+
+ return a_in.interpolate(b_in, t);
+
+ }
+
+ template
+ static inline void interpolate_block(
+ const Configuration &a,
+ const Configuration &b,
+ const FloatVector &t,
+ ConfigurationBlock &out) noexcept
+ {
+ // V is referenced by the SIMD-mask form emitted by LanguageCVampBlock
+ // for non-Euclidean robots; constants and operands get wrapped as
+ // V(x).blend(V(y), (V(...) CMP V(...))) so .blend() always has a
+ // vector receiver.
+ using V = FloatVector;
+
+ out[0] = a.broadcast(0) + t * (b.broadcast(0) - a.broadcast(0));
+ out[1] = a.broadcast(1) + t * (b.broadcast(1) - a.broadcast(1));
+ out[2] = a.broadcast(2) + t * (b.broadcast(2) - a.broadcast(2));
+ out[3] = a.broadcast(3) + t * (b.broadcast(3) - a.broadcast(3));
+ out[4] = a.broadcast(4) + t * (b.broadcast(4) - a.broadcast(4));
+ out[5] = a.broadcast(5) + t * (b.broadcast(5) - a.broadcast(5));
+ out[6] = a.broadcast(6) + t * (b.broadcast(6) - a.broadcast(6));
+ out[7] = a.broadcast(7) + t * (b.broadcast(7) - a.broadcast(7));
+ out[8] = a.broadcast(8) + t * (b.broadcast(8) - a.broadcast(8));
+ out[9] = a.broadcast(9) + t * (b.broadcast(9) - a.broadcast(9));
+
+ }
+
+ template
+ static inline void sphere_fk(const ConfigurationBlock &x, Spheres &out) noexcept
+ {
+ std::array, 20> v;
+ std::array, 208> y;
+
+ v[0] = cos(x[2]);
+ v[1] = sin(x[2]);
+ v[2] = 0. - v[1];
+ y[0] = 0.307172973342773 * v[0] + -0.121481533535459 * v[2] + x[0];
+ y[1] = 0.307172973342773 * v[1] + -0.121481533535459 * v[0] + x[1];
+ y[4] = 0.415429674515036 * v[0] + -0.110381817784451 * v[2] + x[0];
+ y[5] = 0.415429674515036 * v[1] + -0.110381817784451 * v[0] + x[1];
+ y[8] = 0.314667495389766 * v[0] + -0.233605154765132 * v[2] + x[0];
+ y[9] = 0.314667495389766 * v[1] + -0.233605154765132 * v[0] + x[1];
+ y[12] = 0.410164418246151 * v[0] + -0.234597274644923 * v[2] + x[0];
+ y[13] = 0.410164418246151 * v[1] + -0.234597274644923 * v[0] + x[1];
+ v[3] = cos(x[3]);
+ v[4] = sin(x[3]);
+ v[5] = -3.67320510363811e-06 * v[3] + 0.999999999993254 * v[4];
+ v[4] = -0.999999999993254 * v[3] + -3.67320510363811e-06 * v[4];
+ v[3] = v[0] * v[5] + v[2] * v[4];
+ v[6] = 0. - v[4];
+ v[7] = v[0] * v[6] + v[2] * v[5];
+ v[2] = x[0] + 0.363 * v[0] + -0.184 * v[2];
+ y[16] = -0.00670360634 * v[3] + -0.040784236 * v[7] + v[2];
+ v[4] = v[1] * v[5] + v[0] * v[4];
+ v[6] = v[1] * v[6] + v[0] * v[5];
+ v[1] = x[1] + 0.363 * v[1] + -0.184 * v[0];
+ y[17] = -0.00670360634 * v[4] + -0.040784236 * v[6] + v[1];
+ y[20] = -0.0413965359 * v[3] + 0.0353018492 * v[7] + v[2];
+ y[21] = -0.0413965359 * v[4] + 0.0353018492 * v[6] + v[1];
+ y[24] = 0.0434982888 * v[3] + 0.0338222235 * v[7] + v[2];
+ y[25] = 0.0434982888 * v[4] + 0.0338222235 * v[6] + v[1];
+ y[28] = -0.0286719389 * v[3] + -0.0307200272 * v[7] + v[2];
+ y[29] = -0.0286719389 * v[4] + -0.0307200272 * v[6] + v[1];
+ y[32] = 0.0291171353 * v[3] + -0.0286210664 * v[7] + v[2];
+ y[33] = 0.0291171353 * v[4] + -0.0286210664 * v[6] + v[1];
+ v[0] = cos(x[4]);
+ v[5] = sin(x[4]);
+ v[8] = -1. * v[0] + 1.01273331923549e-24 * v[5];
+ v[9] = -2.06823107110214e-13 * v[0] + -4.89652762780679e-12 * v[5];
+ v[10] = v[3] * v[8] + v[7] * v[9];
+ v[5] = -1.26217744835362e-29 * v[0] + v[5];
+ v[0] = v[5] - 4.89663865010925e-12 * v[9];
+ v[11] = 4.89663865010925e-12 * v[8] - -2.06823107110214e-13 * v[5];
+ v[12] = v[3] * v[0] + v[7] * v[11];
+ v[7] = -2.06823107110214e-13 * v[3] + v[7];
+ y[36] = -0.0275839921 * v[10] + 0.00695568835 * v[12] + 0.0358454175 * v[7] + v[2];
+ v[3] = v[4] * v[8] + v[6] * v[9];
+ v[11] = v[4] * v[0] + v[6] * v[11];
+ v[6] = -2.06823107110214e-13 * v[4] + v[6];
+ y[37] = -0.0275839921 * v[3] + 0.00695568835 * v[11] + 0.0358454175 * v[6] + v[1];
+ v[9] = -2.06823107110214e-13 * v[9] - v[8];
+ y[38] = 1.06 + -0.0275839921 * v[5] + 1.75522056759803e-13 + 0.00695568835 * v[9];
+ y[40] = 0.0381424949 * v[10] + -0.00326349423 * v[12] + 0.00337630603 * v[7] + v[2];
+ y[41] = 0.0381424949 * v[3] + -0.00326349423 * v[11] + 0.00337630603 * v[6] + v[1];
+ y[42] = 1.06 + 0.0381424949 * v[5] + 1.65325506010949e-14 + -0.00326349423 * v[9];
+ y[44] = 0.0390098318 * v[10] + -0.0166952536 * v[12] + 0.0721063614 * v[7] + v[2];
+ y[45] = 0.0390098318 * v[3] + -0.0166952536 * v[11] + 0.0721063614 * v[6] + v[1];
+ y[46] = 1.06 + 0.0390098318 * v[5] + 3.53078796149986e-13 + -0.0166952536 * v[9];
+ y[48] = -0.0479581319 * v[10] + 0.135490835 * v[12] + -0.0236044228 * v[7] + v[2];
+ y[49] = -0.0479581319 * v[3] + 0.135490835 * v[11] + -0.0236044228 * v[6] + v[1];
+ y[50] = 1.06 + -0.0479581319 * v[5] + -1.15582328996e-13 + 0.135490835 * v[9];
+ y[52] = 0.044604823 * v[10] + 0.141876876 * v[12] + -0.0252158232 * v[7] + v[2];
+ y[53] = 0.044604823 * v[3] + 0.141876876 * v[11] + -0.0252158232 * v[6] + v[1];
+ y[54] = 1.06 + 0.044604823 * v[5] + -1.23472774475442e-13 + 0.141876876 * v[9];
+ y[56] = 0.00448482111 * v[10] + 0.133491784 * v[12] + 0.0454720892 * v[7] + v[2];
+ y[57] = 0.00448482111 * v[3] + 0.133491784 * v[11] + 0.0454720892 * v[6] + v[1];
+ y[58] = 1.06 + 0.00448482111 * v[5] + 2.22660389477936e-13 + 0.133491784 * v[9];
+ v[8] = cos(x[5]);
+ v[4] = sin(x[5]);
+ v[0] = -1. * v[8] + 1.01273331923549e-24 * v[4];
+ v[13] = -2.06823107110214e-13 * v[8] + -4.89652762780679e-12 * v[4];
+ v[4] = -1.26217744835362e-29 * v[8] + v[4];
+ v[8] = v[10] * v[0] + v[12] * v[13] + v[7] * v[4];
+ v[14] = v[4] - 4.89663865010925e-12 * v[13];
+ v[15] = 4.89663865010925e-12 * v[0] - -2.06823107110214e-13 * v[4];
+ v[16] = -2.06823107110214e-13 * v[13] - v[0];
+ v[17] = v[10] * v[14] + v[12] * v[15] + v[7] * v[16];
+ v[7] = -2.06823107110214e-13 * v[10] + v[12] + 4.89663865010925e-12 * v[7];
+ v[12] = v[2] + 0.2045 * v[12];
+ y[60] = -0.0350460745 * v[8] + -0.0190181732 * v[17] + 0.0581251271 * v[7] + v[12];
+ v[2] = v[3] * v[0] + v[11] * v[13] + v[6] * v[4];
+ v[10] = v[3] * v[14] + v[11] * v[15] + v[6] * v[16];
+ v[6] = -2.06823107110214e-13 * v[3] + v[11] + 4.89663865010925e-12 * v[6];
+ v[11] = v[1] + 0.2045 * v[11];
+ y[61] = -0.0350460745 * v[2] + -0.0190181732 * v[10] + 0.0581251271 * v[6] + v[11];
+ v[4] = v[5] * v[0] + v[9] * v[13] + 4.89663865010925e-12 * v[4];
+ v[16] = v[5] * v[14] + v[9] * v[15] + 4.89663865010925e-12 * v[16];
+ v[5] = -2.06823107110214e-13 * v[5] + 2.39770700697438e-23 + v[9];
+ v[9] = 1.06 + 0.2045 * v[9];
+ y[62] = -0.0350460745 * v[4] + -0.0190181732 * v[16] + 0.0581251271 * v[5] + v[9];
+ y[64] = 0.0322795846 * v[8] + -0.0246098693 * v[17] + 0.056578014 * v[7] + v[12];
+ y[65] = 0.0322795846 * v[2] + -0.0246098693 * v[10] + 0.056578014 * v[6] + v[11];
+ y[66] = 0.0322795846 * v[4] + -0.0246098693 * v[16] + 0.056578014 * v[5] + v[9];
+ y[68] = -0.00398691883 * v[8] + 0.0367862359 * v[17] + 0.0647328869 * v[7] + v[12];
+ y[69] = -0.00398691883 * v[2] + 0.0367862359 * v[10] + 0.0647328869 * v[6] + v[11];
+ y[70] = -0.00398691883 * v[4] + 0.0367862359 * v[16] + 0.0647328869 * v[5] + v[9];
+ y[72] = -0.0275567286 * v[8] + -0.00744893728 * v[17] + 0.200702325 * v[7] + v[12];
+ y[73] = -0.0275567286 * v[2] + -0.00744893728 * v[10] + 0.200702325 * v[6] + v[11];
+ y[74] = -0.0275567286 * v[4] + -0.00744893728 * v[16] + 0.200702325 * v[5] + v[9];
+ y[76] = 0.0250032749 * v[8] + -0.0018542636 * v[17] + 0.21203202 * v[7] + v[12];
+ y[77] = 0.0250032749 * v[2] + -0.0018542636 * v[10] + 0.21203202 * v[6] + v[11];
+ y[78] = 0.0250032749 * v[4] + -0.0018542636 * v[16] + 0.21203202 * v[5] + v[9];
+ y[80] = 0.00511604687 * v[8] + 0.0607575327 * v[17] + 0.190712363 * v[7] + v[12];
+ y[81] = 0.00511604687 * v[2] + 0.0607575327 * v[10] + 0.190712363 * v[6] + v[11];
+ y[82] = 0.00511604687 * v[4] + 0.0607575327 * v[16] + 0.190712363 * v[5] + v[9];
+ v[15] = cos(x[6]);
+ v[14] = sin(x[6]);
+ v[13] = 4.89663865010925e-12 * v[14];
+ v[0] = v[8] * v[15] + v[17] * v[13] + v[7] * v[14];
+ v[1] = -1. * v[14] - 4.89663865010925e-12 * v[13];
+ v[3] = 4.89663865010925e-12 * v[15];
+ v[18] = 0. - -1. * v[15];
+ v[8] = v[8] * v[1] + v[17] * v[3] + v[7] * v[18];
+ v[17] = -1. * v[17] + 4.89663865010925e-12 * v[7];
+ v[12] = v[12] + 0.2155 * v[7];
+ y[84] = -0.00111977418 * v[0] + 0.0118555762 * v[8] + 0.00941696949 * v[17] + v[12];
+ v[7] = v[2] * v[15] + v[10] * v[13] + v[6] * v[14];
+ v[2] = v[2] * v[1] + v[10] * v[3] + v[6] * v[18];
+ v[10] = -1. * v[10] + 4.89663865010925e-12 * v[6];
+ v[11] = v[11] + 0.2155 * v[6];
+ y[85] = -0.00111977418 * v[7] + 0.0118555762 * v[2] + 0.00941696949 * v[10] + v[11];
+ v[13] = v[4] * v[15] + v[16] * v[13] + v[5] * v[14];
+ v[18] = v[4] * v[1] + v[16] * v[3] + v[5] * v[18];
+ v[16] = -1. * v[16] + 4.89663865010925e-12 * v[5];
+ v[9] = v[9] + 0.2155 * v[5];
+ y[86] = -0.00111977418 * v[13] + 0.0118555762 * v[18] + 0.00941696949 * v[16] + v[9];
+ y[88] = -0.00235470245 * v[0] + 0.018166434 * v[8] + 0.0623908974 * v[17] + v[12];
+ y[89] = -0.00235470245 * v[7] + 0.018166434 * v[2] + 0.0623908974 * v[10] + v[11];
+ y[90] = -0.00235470245 * v[13] + 0.018166434 * v[18] + 0.0623908974 * v[16] + v[9];
+ y[92] = -0.0276735798 * v[0] + 0.133258656 * v[8] + -0.0282651521 * v[17] + v[12];
+ y[93] = -0.0276735798 * v[7] + 0.133258656 * v[2] + -0.0282651521 * v[10] + v[11];
+ y[94] = -0.0276735798 * v[13] + 0.133258656 * v[18] + -0.0282651521 * v[16] + v[9];
+ y[96] = 0.0351202637 * v[0] + 0.133368567 * v[8] + -0.0246097278 * v[17] + v[12];
+ y[97] = 0.0351202637 * v[7] + 0.133368567 * v[2] + -0.0246097278 * v[10] + v[11];
+ y[98] = 0.0351202637 * v[13] + 0.133368567 * v[18] + -0.0246097278 * v[16] + v[9];
+ y[100] = 0.00478787348 * v[0] + 0.128053457 * v[8] + 0.0396239161 * v[17] + v[12];
+ y[101] = 0.00478787348 * v[7] + 0.128053457 * v[2] + 0.0396239161 * v[10] + v[11];
+ y[102] = 0.00478787348 * v[13] + 0.128053457 * v[18] + 0.0396239161 * v[16] + v[9];
+ v[5] = cos(x[7]);
+ v[3] = sin(x[7]);
+ v[1] = -1. * v[5] + 2.06823107110214e-13 * v[3];
+ v[4] = 1.26217744835362e-29 * v[5] + 4.89663865010925e-12 * v[3];
+ v[3] = 2.06823107110214e-13 * v[5] + v[3];
+ v[5] = v[0] * v[1] + v[8] * v[4] + v[17] * v[3];
+ v[14] = v[3] - -4.89652762780679e-12 * v[4];
+ v[15] = -4.89652762780679e-12 * v[1] - -1.01273331923549e-24 * v[3];
+ v[6] = -1.01273331923549e-24 * v[4] - v[1];
+ v[19] = v[0] * v[14] + v[8] * v[15] + v[17] * v[6];
+ v[17] = -1.01273331923549e-24 * v[0] + v[8] + -4.89652762780679e-12 * v[17];
+ v[12] = v[12] + 0.1845 * v[8];
+ y[104] = -0.0356699154 * v[5] + -0.0249995645 * v[19] + 0.0463778712 * v[17] + v[12];
+ v[8] = v[7] * v[1] + v[2] * v[4] + v[10] * v[3];
+ v[0] = v[7] * v[14] + v[2] * v[15] + v[10] * v[6];
+ v[10] = -1.01273331923549e-24 * v[7] + v[2] + -4.89652762780679e-12 * v[10];
+ v[11] = v[11] + 0.1845 * v[2];
+ y[105] = -0.0356699154 * v[8] + -0.0249995645 * v[0] + 0.0463778712 * v[10] + v[11];
+ v[3] = v[13] * v[1] + v[18] * v[4] + v[16] * v[3];
+ v[6] = v[13] * v[14] + v[18] * v[15] + v[16] * v[6];
+ v[16] = -1.01273331923549e-24 * v[13] + v[18] + -4.89652762780679e-12 * v[16];
+ v[9] = v[9] + 0.1845 * v[18];
+ y[106] = -0.0356699154 * v[3] + -0.0249995645 * v[6] + 0.0463778712 * v[16] + v[9];
+ y[108] = 0.0313357636 * v[5] + -0.0212659426 * v[19] + 0.0494020917 * v[17] + v[12];
+ y[109] = 0.0313357636 * v[8] + -0.0212659426 * v[0] + 0.0494020917 * v[10] + v[11];
+ y[110] = 0.0313357636 * v[3] + -0.0212659426 * v[6] + 0.0494020917 * v[16] + v[9];
+ y[112] = -0.0299466494 * v[5] + 0.0447016619 * v[19] + 0.0520964824 * v[17] + v[12];
+ y[113] = -0.0299466494 * v[8] + 0.0447016619 * v[0] + 0.0520964824 * v[10] + v[11];
+ y[114] = -0.0299466494 * v[3] + 0.0447016619 * v[6] + 0.0520964824 * v[16] + v[9];
+ y[116] = 0.029219823 * v[5] + 0.0443405733 * v[19] + 0.048995398 * v[17] + v[12];
+ y[117] = 0.029219823 * v[8] + 0.0443405733 * v[0] + 0.048995398 * v[10] + v[11];
+ y[118] = 0.029219823 * v[3] + 0.0443405733 * v[6] + 0.048995398 * v[16] + v[9];
+ y[120] = -0.0214249473 * v[5] + 0.0306897257 * v[19] + 0.143539861 * v[17] + v[12];
+ y[121] = -0.0214249473 * v[8] + 0.0306897257 * v[0] + 0.143539861 * v[10] + v[11];
+ y[122] = -0.0214249473 * v[3] + 0.0306897257 * v[6] + 0.143539861 * v[16] + v[9];
+ y[124] = 0.0225597732 * v[5] + 0.0320144668 * v[19] + 0.145415813 * v[17] + v[12];
+ y[125] = 0.0225597732 * v[8] + 0.0320144668 * v[0] + 0.145415813 * v[10] + v[11];
+ y[126] = 0.0225597732 * v[3] + 0.0320144668 * v[6] + 0.145415813 * v[16] + v[9];
+ y[128] = -0.00358597096 * v[5] + 0.0582895167 * v[19] + 0.213347182 * v[17] + v[12];
+ y[129] = -0.00358597096 * v[8] + 0.0582895167 * v[0] + 0.213347182 * v[10] + v[11];
+ y[130] = -0.00358597096 * v[3] + 0.0582895167 * v[6] + 0.213347182 * v[16] + v[9];
+ v[18] = cos(x[8]);
+ v[13] = sin(x[8]);
+ v[15] = 4.89663865010925e-12 * v[13];
+ v[14] = v[5] * v[18] + v[19] * v[15] + v[17] * v[13];
+ v[4] = -1. * v[13] - 4.89663865010925e-12 * v[15];
+ v[1] = 4.89663865010925e-12 * v[18];
+ v[2] = 0. - -1. * v[18];
+ v[5] = v[5] * v[4] + v[19] * v[1] + v[17] * v[2];
+ v[19] = -1. * v[19] + 4.89663865010925e-12 * v[17];
+ v[12] = v[12] + 0.2155 * v[17];
+ y[132] = 0.005392408 * v[14] + -0.0226636101 * v[5] + -0.0220694076 * v[19] + v[12];
+ v[17] = v[8] * v[18] + v[0] * v[15] + v[10] * v[13];
+ v[8] = v[8] * v[4] + v[0] * v[1] + v[10] * v[2];
+ v[0] = -1. * v[0] + 4.89663865010925e-12 * v[10];
+ v[11] = v[11] + 0.2155 * v[10];
+ y[133] = 0.005392408 * v[17] + -0.0226636101 * v[8] + -0.0220694076 * v[0] + v[11];
+ v[15] = v[3] * v[18] + v[6] * v[15] + v[16] * v[13];
+ v[2] = v[3] * v[4] + v[6] * v[1] + v[16] * v[2];
+ v[6] = -1. * v[6] + 4.89663865010925e-12 * v[16];
+ v[9] = v[9] + 0.2155 * v[16];
+ y[134] = 0.005392408 * v[15] + -0.0226636101 * v[2] + -0.0220694076 * v[6] + v[9];
+ y[136] = -0.00528397737 * v[14] + -0.0275940727 * v[5] + 0.0237722136 * v[19] + v[12];
+ y[137] = -0.00528397737 * v[17] + -0.0275940727 * v[8] + 0.0237722136 * v[0] + v[11];
+ y[138] = -0.00528397737 * v[15] + -0.0275940727 * v[2] + 0.0237722136 * v[6] + v[9];
+ y[140] = -0.00421259739 * v[14] + 0.0283862222 * v[5] + -0.0275253206 * v[19] + v[12];
+ y[141] = -0.00421259739 * v[17] + 0.0283862222 * v[8] + -0.0275253206 * v[0] + v[11];
+ y[142] = -0.00421259739 * v[15] + 0.0283862222 * v[2] + -0.0275253206 * v[6] + v[9];
+ y[144] = -0.00487661408 * v[14] + 0.0298155136 * v[5] + 0.0194632504 * v[19] + v[12];
+ y[145] = -0.00487661408 * v[17] + 0.0298155136 * v[8] + 0.0194632504 * v[0] + v[11];
+ y[146] = -0.00487661408 * v[15] + 0.0298155136 * v[2] + 0.0194632504 * v[6] + v[9];
+ v[16] = cos(x[9]);
+ v[1] = sin(x[9]);
+ v[4] = -1. * v[16] + 2.06823107110214e-13 * v[1];
+ v[3] = 1.26217744835362e-29 * v[16] + 4.89663865010925e-12 * v[1];
+ v[1] = 2.06823107110214e-13 * v[16] + v[1];
+ v[16] = v[14] * v[4] + v[5] * v[3] + v[19] * v[1];
+ v[13] = v[1] - -4.89652762780679e-12 * v[3];
+ v[18] = -4.89652762780679e-12 * v[4] - -1.01273331923549e-24 * v[1];
+ v[10] = -1.01273331923549e-24 * v[3] - v[4];
+ v[7] = v[14] * v[13] + v[5] * v[18] + v[19] * v[10];
+ v[19] = -1.01273331923549e-24 * v[14] + v[5] + -4.89652762780679e-12 * v[19];
+ v[12] = v[12] + 0.081 * v[5];
+ y[148] = -0.0202615093 * v[16] + -0.0196781531 * v[7] + 0.0199483912 * v[19] + v[12];
+ v[5] = v[17] * v[4] + v[8] * v[3] + v[0] * v[1];
+ v[14] = v[17] * v[13] + v[8] * v[18] + v[0] * v[10];
+ v[0] = -1.01273331923549e-24 * v[17] + v[8] + -4.89652762780679e-12 * v[0];
+ v[11] = v[11] + 0.081 * v[8];
+ y[149] = -0.0202615093 * v[5] + -0.0196781531 * v[14] + 0.0199483912 * v[0] + v[11];
+ v[1] = v[15] * v[4] + v[2] * v[3] + v[6] * v[1];
+ v[10] = v[15] * v[13] + v[2] * v[18] + v[6] * v[10];
+ v[6] = -1.01273331923549e-24 * v[15] + v[2] + -4.89652762780679e-12 * v[6];
+ v[9] = v[9] + 0.081 * v[2];
+ y[150] = -0.0202615093 * v[1] + -0.0196781531 * v[10] + 0.0199483912 * v[6] + v[9];
+ y[152] = -0.0202767439 * v[16] + 0.0225605387 * v[7] + 0.017036628 * v[19] + v[12];
+ y[153] = -0.0202767439 * v[5] + 0.0225605387 * v[14] + 0.017036628 * v[0] + v[11];
+ y[154] = -0.0202767439 * v[1] + 0.0225605387 * v[10] + 0.017036628 * v[6] + v[9];
+ y[156] = 0.0184995625 * v[16] + -0.0198227968 * v[7] + 0.017659599 * v[19] + v[12];
+ y[157] = 0.0184995625 * v[5] + -0.0198227968 * v[14] + 0.017659599 * v[0] + v[11];
+ y[158] = 0.0184995625 * v[1] + -0.0198227968 * v[10] + 0.017659599 * v[6] + v[9];
+ y[160] = 0.0236416645 * v[16] + 0.0248110201 * v[7] + 0.00482575502 * v[19] + v[12];
+ y[161] = 0.0236416645 * v[5] + 0.0248110201 * v[14] + 0.00482575502 * v[0] + v[11];
+ y[162] = 0.0236416645 * v[1] + 0.0248110201 * v[10] + 0.00482575502 * v[6] + v[9];
+ y[164] = 0.022031378 * v[16] + 0.0222504102 * v[7] + 0.0300341975 * v[19] + v[12];
+ y[165] = 0.022031378 * v[5] + 0.0222504102 * v[14] + 0.0300341975 * v[0] + v[11];
+ y[166] = 0.022031378 * v[1] + 0.0222504102 * v[10] + 0.0300341975 * v[6] + v[9];
+ y[168] = -0.015658172586783 * v[16] + -0.0346750904362699 * v[7] + 0.0720993076999925 * v[19] + v[12];
+ y[169] = -0.015658172586783 * v[5] + -0.0346750904362699 * v[14] + 0.0720993076999925 * v[0] + v[11];
+ y[170] = -0.015658172586783 * v[1] + -0.0346750904362699 * v[10] + 0.0720993076999925 * v[6] + v[9];
+ y[172] = -0.0132045435762382 * v[16] + -0.0361020286844062 * v[7] + 0.108550422000006 * v[19] + v[12];
+ y[173] = -0.0132045435762382 * v[5] + -0.0361020286844062 * v[14] + 0.108550422000006 * v[0] + v[11];
+ y[174] = -0.0132045435762382 * v[1] + -0.0361020286844062 * v[10] + 0.108550422000006 * v[6] + v[9];
+ y[176] = 0.0123596995840355 * v[16] + 0.0369113474901499 * v[7] + 0.0721580964999884 * v[19] + v[12];
+ y[177] = 0.0123596995840355 * v[5] + 0.0369113474901499 * v[14] + 0.0721580964999884 * v[0] + v[11];
+ y[178] = 0.0123596995840355 * v[1] + 0.0369113474901499 * v[10] + 0.0721580964999884 * v[6] + v[9];
+ y[180] = 0.0132084821989163 * v[16] + 0.0378580159764132 * v[7] + 0.107748506699991 * v[19] + v[12];
+ y[181] = 0.0132084821989163 * v[5] + 0.0378580159764132 * v[14] + 0.107748506699991 * v[0] + v[11];
+ y[182] = 0.0132084821989163 * v[1] + 0.0378580159764132 * v[10] + 0.107748506699991 * v[6] + v[9];
+ y[184] = -0.0244217062435585 * v[16] + -0.0630382859136408 * v[7] + 0.166333455900005 * v[19] + v[12];
+ y[185] = -0.0244217062435585 * v[5] + -0.0630382859136408 * v[14] + 0.166333455900005 * v[0] + v[11];
+ y[186] = -0.0244217062435585 * v[1] + -0.0630382859136408 * v[10] + 0.166333455900005 * v[6] + v[9];
+ y[188] = -0.0250853566427006 * v[16] + -0.0610237247173512 * v[7] + 0.191859339699998 * v[19] + v[12];
+ y[189] = -0.0250853566427006 * v[5] + -0.0610237247173512 * v[14] + 0.191859339699998 * v[0] + v[11];
+ y[190] = -0.0250853566427006 * v[1] + -0.0610237247173512 * v[10] + 0.191859339699998 * v[6] + v[9];
+ y[192] = -0.0229067249938562 * v[16] + -0.0535261317799037 * v[7] + 0.238779624299994 * v[19] + v[12];
+ y[193] = -0.0229067249938562 * v[5] + -0.0535261317799037 * v[14] + 0.238779624299994 * v[0] + v[11];
+ y[194] = -0.0229067249938562 * v[1] + -0.0535261317799037 * v[10] + 0.238779624299994 * v[6] + v[9];
+ y[196] = 0.026222567675647 * v[16] + 0.0623106906659901 * v[7] + 0.166333455900005 * v[19] + v[12];
+ y[197] = 0.026222567675647 * v[5] + 0.0623106906659901 * v[14] + 0.166333455900005 * v[0] + v[11];
+ y[198] = 0.026222567675647 * v[1] + 0.0623106906659901 * v[10] + 0.166333455900005 * v[6] + v[9];
+ y[200] = 0.0243457457322366 * v[16] + 0.0613225469220892 * v[7] + 0.191859339699998 * v[19] + v[12];
+ y[201] = 0.0243457457322366 * v[5] + 0.0613225469220892 * v[14] + 0.191859339699998 * v[0] + v[11];
+ y[202] = 0.0243457457322366 * v[1] + 0.0613225469220892 * v[10] + 0.191859339699998 * v[6] + v[9];
+ y[204] = 0.0207046564952889 * v[16] + 0.0544158252044005 * v[7] + 0.238779624299994 * v[19] + v[12];
+ y[205] = 0.0207046564952889 * v[5] + 0.0544158252044005 * v[14] + 0.238779624299994 * v[0] + v[11];
+ y[206] = 0.0207046564952889 * v[1] + 0.0544158252044005 * v[10] + 0.238779624299994 * v[6] + v[9];
+ // dependent variables without operations
+ y[2] = 0.7664566755;
+ y[3] = 0.108769170939922;
+ y[6] = 0.7796212777;
+ y[7] = 0.106834217905998;
+ y[10] = 0.7626648366;
+ y[11] = 0.107287794351578;
+ y[14] = 0.7635768548;
+ y[15] = 0.106913693249226;
+ y[18] = 0.9269997832;
+ y[19] = 0.103888273239136;
+ y[22] = 0.9124508631;
+ y[23] = 0.0820827409625053;
+ y[26] = 0.9115827774;
+ y[27] = 0.0806328281760216;
+ y[30] = 1.044288425;
+ y[31] = 0.0977101102471352;
+ y[34] = 1.045187114;
+ y[35] = 0.096952922642231;
+ y[39] = 0.0977827161550522;
+ y[43] = 0.083485372364521;
+ y[47] = 0.0828254744410515;
+ y[51] = 0.0824512913823128;
+ y[55] = 0.0832970216870308;
+ y[59] = 0.0979365333914757;
+ y[63] = 0.0766579061746597;
+ y[67] = 0.0747903659939766;
+ y[71] = 0.0910450890660286;
+ y[75] = 0.0840748995542526;
+ y[79] = 0.0863684490323067;
+ y[83] = 0.0896069183945656;
+ y[87] = 0.0825057029724121;
+ y[91] = 0.0828549563884735;
+ y[95] = 0.0719889253377914;
+ y[99] = 0.0681954920291901;
+ y[103] = 0.0868047699332237;
+ y[107] = 0.0665318816900253;
+ y[111] = 0.0665315315127373;
+ y[115] = 0.0698557272553444;
+ y[119] = 0.0707721784710884;
+ y[123] = 0.070766493678093;
+ y[127] = 0.0698088854551315;
+ y[131] = 0.0610034838318825;
+ y[135] = 0.0709031224250793;
+ y[139] = 0.0694830790162086;
+ y[143] = 0.0725750476121902;
+ y[147] = 0.0718023180961609;
+ y[151] = 0.0379333384335041;
+ y[155] = 0.037326630204916;
+ y[159] = 0.037082627415657;
+ y[163] = 0.0334806852042675;
+ y[167] = 0.0327432975172997;
+ y[171] = 0.0450715161859989;
+ y[175] = 0.0445709452033043;
+ y[179] = 0.0439092442393303;
+ y[183] = 0.0451358743011951;
+ y[187] = 0.0239227917045355;
+ y[191] = 0.0233441591262817;
+ y[195] = 0.0354296341538429;
+ y[199] = 0.0239227917045355;
+ y[203] = 0.0233441591262817;
+ y[207] = 0.0354296341538429;
+
+
+ for (auto i = 0U; i < 52; ++i)
+ {
+ out.x[i] = y[i * 4 + 0];
+ out.y[i] = y[i * 4 + 1];
+ out.z[i] = y[i * 4 + 2];
+ out.r[i] = y[i * 4 + 3];
+ }
+ }
+
+
+ template
+ static inline void cuboid_fk(const ConfigurationBlock &x, Cuboids &out) noexcept
+ {
+ std::array, 0> v;
+ std::array, 15> y;
+
+ y[3] = cos(x[2]);
+ y[4] = sin(x[2]);
+ y[6] = 0. - y[4];
+ y[0] = 0.0201999992 * y[3] + 0.000199999995 * y[6] + x[0];
+ y[1] = 0.0201999992 * y[4] + 0.000199999995 * y[3] + x[1];
+ // variable duplicates: 1
+ y[7] = y[3];
+ // dependent variables without operations
+ y[2] = 0.358600014;
+ y[5] = 0.;
+ y[8] = 0.;
+ y[9] = 0.;
+ y[10] = 0.;
+ y[11] = 1.;
+ y[12] = 0.572016000747681;
+ y[13] = 0.32150399684906;
+ y[14] = 0.340272009372711;
+
+
+ for (auto i = 0U; i < 1; ++i)
+ {
+ out.x[i] = y[i * 15 + 0];
+ out.y[i] = y[i * 15 + 1];
+ out.z[i] = y[i * 15 + 2];
+ out.axis_1_x[i] = y[i * 15 + 3];
+ out.axis_1_y[i] = y[i * 15 + 4];
+ out.axis_1_z[i] = y[i * 15 + 5];
+ out.axis_2_x[i] = y[i * 15 + 6];
+ out.axis_2_y[i] = y[i * 15 + 7];
+ out.axis_2_z[i] = y[i * 15 + 8];
+ out.axis_3_x[i] = y[i * 15 + 9];
+ out.axis_3_y[i] = y[i * 15 + 10];
+ out.axis_3_z[i] = y[i * 15 + 11];
+ out.axis_1_r[i] = y[i * 15 + 12];
+ out.axis_2_r[i] = y[i * 15 + 13];
+ out.axis_3_r[i] = y[i * 15 + 14];
+ }
+ }
+
+
+ // For fkcc_debug: the first element has one entry per sphere, followed by one per cuboid. The second
+ // element lists colliding pairs of robot geometry; indices < n_spheres are spheres and
+ // n_spheres + i is cuboid i.
+ using Debug = std::pair>, std::vector>>;
+
+ template
+ static inline auto fkcc_debug(
+ const vamp::collision::Environment