feat: arm now checks all joints for collisions
This commit is contained in:
+7
-6
@@ -76,15 +76,16 @@ bool Arm::isMoving() const noexcept
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Arm::isEFPositionValid(std::span<const AxisAlignedBoundingBox> deadzones) const noexcept
|
bool Arm::checkJointCollisions(std::span<const AxisAlignedBoundingBox> deadzones) const noexcept
|
||||||
{
|
{
|
||||||
// Otherwise: check for endeffector position
|
// TODO: Perform this check within the FK loop to prevent redundant operations
|
||||||
const Vector3d ef = joints.back().getTargetedGlobalEndpoint();
|
|
||||||
|
|
||||||
// If any deadzone intersects with the EF pos, fai
|
// If any deadzone intersects with the EF pos, fai
|
||||||
for (const AxisAlignedBoundingBox& aabb : deadzones) {
|
for (const AxisAlignedBoundingBox& aabb : deadzones) {
|
||||||
if (aabb.doesIntersect(ef)) {
|
|
||||||
return false;
|
for (auto& joint : joints) {
|
||||||
|
if (aabb.doesIntersect(joint.getTargetedGlobalEndpoint())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -23,12 +23,13 @@ public:
|
|||||||
void rollbackPose() noexcept;
|
void rollbackPose() noexcept;
|
||||||
bool isMoving() const noexcept;
|
bool isMoving() const noexcept;
|
||||||
|
|
||||||
// Will test if the end effectors current target (or staged) position is not within a collider
|
// Will test if the joints target position is not within a collider
|
||||||
bool isEFPositionValid(std::span<const AxisAlignedBoundingBox> deadzones) const noexcept;
|
bool checkJointCollisions(std::span<const AxisAlignedBoundingBox> deadzones) const noexcept;
|
||||||
// Will roll back individual joints if their angles exceed their limits. Returns true if no rollbacks were made.
|
// Will roll back individual joints if their angles exceed their limits. Returns true if no rollbacks were made.
|
||||||
bool rollbackJointsBasedOnValidRange() noexcept;
|
bool rollbackJointsBasedOnValidRange() noexcept;
|
||||||
|
|
||||||
const std::array<ArmSegment, NUM_JOINTS>& getJoints() const { return joints; };
|
const std::array<ArmSegment, NUM_JOINTS>& getJoints() const { return joints; };
|
||||||
|
std::array<ArmSegment, NUM_JOINTS>& getJoints() { return joints; };
|
||||||
const ArmSegment& getEndEffectorJoint() const { return joints.back(); };
|
const ArmSegment& getEndEffectorJoint() const { return joints.back(); };
|
||||||
|
|
||||||
void update(double frametime);
|
void update(double frametime);
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ void Scene_JointSpaceControl::update(double frametime)
|
|||||||
|
|
||||||
// Stage the new pose and keep it if it is good
|
// Stage the new pose and keep it if it is good
|
||||||
arm.stagePose({ j0Pos, j1Pos, j2Pos, j3Pos, j4Pos, j5Pos });
|
arm.stagePose({ j0Pos, j1Pos, j2Pos, j3Pos, j4Pos, j5Pos });
|
||||||
if (arm.isEFPositionValid(deadzones)) {
|
if (arm.checkJointCollisions(deadzones)) {
|
||||||
// Roll back individual joints if their angles are out of range
|
// Roll back individual joints if their angles are out of range
|
||||||
arm.rollbackJointsBasedOnValidRange();
|
arm.rollbackJointsBasedOnValidRange();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user