Tabnine Logo
FrameConvexPolygon2d.getCentroid
Code IndexAdd Tabnine to your IDE (free)

How to use
getCentroid
method
in
us.ihmc.robotics.geometry.FrameConvexPolygon2d

Best Java code snippets using us.ihmc.robotics.geometry.FrameConvexPolygon2d.getCentroid (Showing top 20 results out of 315)

origin: us.ihmc/IHMCRoboticsToolkit

public FramePoint2d getCentroid()
{
 getCentroid(temporaryCentroid);
 return temporaryCentroid;
}
origin: us.ihmc/CommonWalkingControlModules

public void getShrunkPolygonCentroid(FramePoint2d centroidToPack)
{
 shrunkFootPolygon.getCentroid(centroidToPack);
}
origin: us.ihmc/IHMCRoboticsToolkit

public FramePoint2d getCentroidCopy()
{
 FramePoint2d centroidToReturn = new FramePoint2d();
 getCentroid(centroidToReturn);
 return centroidToReturn;
}
origin: us.ihmc/CommonWalkingControlModules

public void setContactFramePoints(List<FramePoint2d> contactPointLocations)
{
 int contactPointLocationsSize = contactPointLocations.size();
 if (contactPointLocationsSize != totalNumberOfContactPoints)
   throw new RuntimeException("contactPointLocationsSize != totalNumberOfContactPoints");
 for (int i = 0; i < contactPointLocationsSize; i++)
 {
   FramePoint2d contactPointLocation = contactPointLocations.get(i);
   YoContactPoint yoContactPoint = contactPoints.get(i);
   yoContactPoint.setPosition(contactPointLocation);
 }
 contactPointsPolygon.setIncludingFrameAndUpdate(contactPointLocations);
 this.contactPointCentroid.set(contactPointsPolygon.getCentroid());
}
origin: us.ihmc/CommonWalkingControlModules

public void setContactPoints(List<Point2d> contactPointLocations)
{
 int contactPointLocationsSize = contactPointLocations.size();
 if (contactPointLocationsSize != totalNumberOfContactPoints)
   throw new RuntimeException("contactPointLocationsSize != totalNumberOfContactPoints");
 for (int i = 0; i < contactPointLocationsSize; i++)
 {
   Point2d contactPointLocation = contactPointLocations.get(i);
   YoContactPoint yoContactPoint = contactPoints.get(i);
   yoContactPoint.setPosition2d(contactPointLocation);
 }
 contactPointsPolygon.setIncludingFrameAndUpdate(planeFrame, contactPointLocations);
 this.contactPointCentroid.set(contactPointsPolygon.getCentroid());
}
origin: us.ihmc/CommonWalkingControlModules

private void computeFootstepCentroid(FramePoint2d centroidToPack, Footstep footstep)
{
 predictedSupportPolygon.clear(footstep.getSoleReferenceFrame());
 addPredictedContactPointsToPolygon(footstep, predictedSupportPolygon);
 predictedSupportPolygon.update();
 predictedSupportPolygon.getCentroid(centroidToPack);
}
origin: us.ihmc/CommonWalkingControlModules

private void computePredictedSupportCentroid(FramePoint2d centroidToPack, Footstep footstep, Footstep nextFootstep)
{
 predictedSupportPolygon.clear(worldFrame);
 addPredictedContactPointsToPolygon(footstep, predictedSupportPolygon);
 addPredictedContactPointsToPolygon(nextFootstep, predictedSupportPolygon);
 predictedSupportPolygon.update();
 predictedSupportPolygon.getCentroid(centroidToPack);
}
origin: us.ihmc/CommonWalkingControlModules

private void computeFinalCMPBetweenSupportFeet(int cmpIndex, FrameConvexPolygon2d footA, FrameConvexPolygon2d footB)
{
 footA.getCentroid(tempCentroid);
 firstCMP.setXYIncludingFrame(tempCentroid);
 firstCMP.changeFrame(worldFrame);
 footB.getCentroid(tempCentroid);
 secondCMP.setXYIncludingFrame(tempCentroid);
 secondCMP.changeFrame(worldFrame);
 upcomingSupport.clear(worldFrame);
 tempFootPolygon.setIncludingFrame(footA);
 tempFootPolygon.changeFrameAndProjectToXYPlane(worldFrame);
 upcomingSupport.addVertices(tempFootPolygon);
 tempFootPolygon.setIncludingFrame(footB);
 tempFootPolygon.changeFrameAndProjectToXYPlane(worldFrame);
 upcomingSupport.addVertices(tempFootPolygon);
 upcomingSupport.update();
 entryCMPs.get(cmpIndex).switchCurrentReferenceFrame(worldFrame);
 exitCMPs.get(cmpIndex).switchCurrentReferenceFrame(worldFrame);
 upcomingSupport.getCentroid(tempCentroid);
 tempCentroid3d.setXYIncludingFrame(tempCentroid);
 double chicken = MathTools.clipToMinMax(percentageChickenSupport.getDoubleValue(), 0.0, 1.0);
 if (chicken <= 0.5)
   entryCMPs.get(cmpIndex).interpolate(firstCMP, tempCentroid3d, chicken * 2.0);
 else
   entryCMPs.get(cmpIndex).interpolate(tempCentroid3d, secondCMP, (chicken-0.5) * 2.0);
 exitCMPs.get(cmpIndex).set(entryCMPs.get(cmpIndex));
}
origin: us.ihmc/CommonWalkingControlModules

private void computeReferenceCMPsWithUpcomingFootsteps(RobotSide firstSupportSide, int numberOfUpcomingFootsteps, int cmpIndex)
 FramePoint2d centroidInSoleFrameOfPreviousSupportFoot = supportFootPolygonsInSoleZUpFrame.get(firstSupportSide).getCentroid();
origin: us.ihmc/CommonWalkingControlModules

private void projectCMPIntoSupportPolygonIfOutsideLocal(FrameConvexPolygon2d supportPolygon, FramePoint2d desiredCMPToPack)
{
 cmpProjected.set(false);
 if (supportPolygon.getArea() < 1.0e-3)
 {
   supportPolygon.getCentroid(desiredCMPToPack);
   return;
 }
 if (supportPolygon.isPointInside(projectedCMP))
 {
   return;
 }
 else
 {
   supportPolygon.getClosestVertex(projectedCMP, projectedCMP);
   cmpProjected.set(true);
 }
 desiredCMPToPack.setX(projectedCMP.getX());
}
origin: us.ihmc/CommonWalkingControlModules

private void putExitCMPOnToes(FrameConvexPolygon2d footSupportPolygon, FramePoint2d exitCMPToPack)
{
 // Set x to have the CMP slightly inside the support polygon
 exitCMPToPack.setToZero(footSupportPolygon.getReferenceFrame());
 exitCMPToPack.setX(footSupportPolygon.getMaxX() - 1.6e-2);
 exitCMPToPack.setY(footSupportPolygon.getCentroid().getY());
 // Then constrain the computed CMP to be inside a safe support region
 tempSupportPolygonForShrinking.setIncludingFrameAndUpdate(footSupportPolygon);
 convexPolygonShrinker.shrinkConstantDistanceInto(tempSupportPolygonForShrinking, safeDistanceFromCMPToSupportEdgesWhenSteppingDown.getDoubleValue(),
    footSupportPolygon);
 footSupportPolygon.orthogonalProjection(exitCMPToPack);
}
origin: us.ihmc/CommonWalkingControlModules

private void constrainCMPAccordingToSupportPolygonAndUserOffsets(FramePoint2d cmpToPack, FrameConvexPolygon2d footSupportPolygon,
   FramePoint2d centroidOfFootstepToConsider, YoFrameVector2d cmpOffset, double minForwardCMPOffset, double maxForwardCMPOffset)
{
 // First constrain the computed CMP to the given min/max along the x-axis.
 FramePoint2d footSupportCentroid = footSupportPolygon.getCentroid();
 double cmpXOffsetFromCentroid = stepLengthToCMPOffsetFactor.getDoubleValue() * (centroidOfFootstepToConsider.getX() - footSupportCentroid.getX()) + cmpOffset.getX();
 cmpXOffsetFromCentroid = MathTools.clipToMinMax(cmpXOffsetFromCentroid, minForwardCMPOffset, maxForwardCMPOffset);
 cmpToPack.setIncludingFrame(footSupportCentroid);
 cmpToPack.add(cmpXOffsetFromCentroid, cmpOffset.getY());
 // Then constrain the computed CMP to be inside a safe support region
 tempSupportPolygonForShrinking.setIncludingFrameAndUpdate(footSupportPolygon);
 convexPolygonShrinker.shrinkConstantDistanceInto(tempSupportPolygonForShrinking, safeDistanceFromCMPToSupportEdges.getDoubleValue(), footSupportPolygon);
 footSupportPolygon.orthogonalProjection(cmpToPack);
}
origin: us.ihmc/CommonWalkingControlModules

private void computeEntryCMP(FramePoint entryCMPToPack, RobotSide robotSide, ReferenceFrame soleFrame, FrameConvexPolygon2d footSupportPolygon, FramePoint2d centroidInSoleFrameOfPreviousSupportFoot,
   YoFramePoint previousExitCMP)
{
 if (useTwoCMPsPerSupport)
 {
   if (centroidInSoleFrameOfPreviousSupportFoot != null)
    centroidOfFootstepToConsider.setIncludingFrame(centroidInSoleFrameOfPreviousSupportFoot);
   else
    centroidOfFootstepToConsider.setToZero(soleFrame);
   centroidOfFootstepToConsider.changeFrameAndProjectToXYPlane(soleFrame);
   if (previousExitCMP != null)
   {
    previousExitCMP.getFrameTuple2dIncludingFrame(previousExitCMP2d);
    previousExitCMP2d.changeFrameAndProjectToXYPlane(soleFrame);
    // Choose the laziest option
    if (Math.abs(previousExitCMP2d.getX()) < Math.abs(centroidOfFootstepToConsider.getX()))
      centroidOfFootstepToConsider.set(previousExitCMP2d);
   }
   constrainCMPAccordingToSupportPolygonAndUserOffsets(cmp2d, footSupportPolygon, centroidOfFootstepToConsider, entryCMPUserOffsets.get(robotSide),
      minForwardEntryCMPOffset.getDoubleValue(), maxForwardEntryCMPOffset.getDoubleValue());
 }
 else
 {
   cmp2d.setIncludingFrame(footSupportPolygon.getCentroid());
   YoFrameVector2d offset = entryCMPUserOffsets.get(robotSide);
   cmp2d.add(offset.getX(), offset.getY());
 }
 entryCMPToPack.setXYIncludingFrame(cmp2d);
 entryCMPToPack.changeFrame(worldFrame);
}
origin: us.ihmc/CommonWalkingControlModules

@Override
public void projectCMPIntoSupportPolygonIfOutside(FramePoint2d capturePoint, FrameConvexPolygon2d supportPolygon,
   FramePoint2d finalDesiredCapturePoint, FramePoint2d desiredCMPToPack)
{
 ReferenceFrame returnFrame = desiredCMPToPack.getReferenceFrame();
 desiredCMPToPack.changeFrame(supportPolygon.getReferenceFrame());
 capturePoint.changeFrame(supportPolygon.getReferenceFrame());
 projectedCMP.setToZero(supportPolygon.getReferenceFrame());
 projectedCMP.setX(desiredCMPToPack.getX());
 projectedCMP.setY(supportPolygon.getCentroid().getY());
 projectCMPIntoSupportPolygonIfOutsideLocal(supportPolygon, desiredCMPToPack);
 desiredCMPToPack.changeFrame(returnFrame);
 capturePoint.changeFrame(returnFrame);
}
origin: us.ihmc/CommonWalkingControlModules

@Override
public void doTransitionIntoAction()
{
 super.doTransitionIntoAction();
 footPolygon.clear(soleFrame);
 for (int i = 0; i < contactPoints.size(); i++)
 {
   contactPoints.get(i).getPosition2d(toeOffContactPoint2d);
   footPolygon.addVertex(toeOffContactPoint2d);
 }
 footPolygon.update();
 FramePoint2d rayOrigin;
 if (!exitCMP2d.containsNaN() && footPolygon.isPointInside(exitCMP2d))
   rayOrigin = exitCMP2d;
 else
   rayOrigin = footPolygon.getCentroid();
 rayThroughExitCMP.set(rayOrigin, exitCMPRayDirection2d);
 frameConvexPolygonWithRayIntersector2d.intersectWithRay(footPolygon, rayThroughExitCMP);
 toeOffContactPoint2d.set(frameConvexPolygonWithRayIntersector2d.getIntersectionPointOne());
 contactPointPosition.setXYIncludingFrame(toeOffContactPoint2d);
 contactPointPosition.changeFrame(contactableFoot.getRigidBody().getBodyFixedFrame());
 pointFeedbackControlCommand.setBodyFixedPointToControl(contactPointPosition);
 desiredContactPointPosition.setXYIncludingFrame(toeOffContactPoint2d);
 desiredContactPointPosition.changeFrame(worldFrame);
 desiredOrientation.setToZero(contactableFoot.getFrameAfterParentJoint());
 desiredOrientation.changeFrame(worldFrame);
 desiredYawToHold = desiredOrientation.getYaw();
 desiredRollToHold = desiredOrientation.getRoll();
}
origin: us.ihmc/CommonWalkingControlModules

public void checkIfRobotIsFalling(FramePoint2d capturePoint2d, FramePoint2d desiredCapturePoint2d)
{
 updateCombinedPolygon();
 if (isUsingNextFootstep.getBooleanValue())
   icpDistanceFromFootPolygon.set(combinedFootPolygonWithNextFootstep.distance(capturePoint2d));
 else
   icpDistanceFromFootPolygon.set(combinedFootPolygon.distance(capturePoint2d));
 // TODO need to investigate this method, seems to be buggy
 //      boolean isCapturePointCloseToFootPolygon = combinedFootPolygon.isPointInside(capturePoint, icpDistanceFromFootPolygonThreshold.getDoubleValue());
 boolean isCapturePointCloseToFootPolygon = icpDistanceFromFootPolygon.getDoubleValue() < icpDistanceFromFootPolygonThreshold.getDoubleValue();
 boolean isCapturePointCloseToDesiredCapturePoint = desiredCapturePoint2d.distance(capturePoint2d) < icpDistanceFromFootPolygonThreshold.getDoubleValue();
 isRobotFalling.set(!isCapturePointCloseToFootPolygon && !isCapturePointCloseToDesiredCapturePoint);
 if (isRobotFalling.getBooleanValue())
 {
   tempFallingDirection.set(capturePoint2d);
   FramePoint2d footCenter = combinedFootPolygon.getCentroid();
   tempFallingDirection.changeFrame(ReferenceFrame.getWorldFrame());
   footCenter.changeFrame(ReferenceFrame.getWorldFrame());
   tempFallingDirection.sub(footCenter);
   fallingDirection.set(tempFallingDirection);
 }
}
origin: us.ihmc/CommonWalkingControlModules

FramePoint2d centroid = supportPolygon.getCentroid();
origin: us.ihmc/CommonWalkingControlModules

/** 
* This function projects the footstep midpoint in the capture region.
* Might be a bit conservative it should be sufficient to slightly overlap the capture region
* and the touch-down polygon.
*/
private void projectFootstepInCaptureRegion(Footstep footstep, FramePoint2d projectionPoint, FrameConvexPolygon2d captureRegion)
{
 projection.setIncludingFrame(projectionPoint);
 projection.changeFrame(footstep.getParentFrame());
 // move the position of the footstep to the capture region centroid
 nextStep2d.setIncludingFrame(captureRegion.getCentroid());
 nextStep2d.changeFrame(footstep.getParentFrame());
 // move the position as far away from the projectionPoint as possible
 direction.setIncludingFrame(nextStep2d);
 direction.sub(projection);
 direction.normalize();
 direction.scale(10.0);
 nextStep2d.add(direction);
 nextStep2d.changeFrame(captureRegion.getReferenceFrame());
 captureRegion.orthogonalProjection(nextStep2d);
 nextStep2d.changeFrame(footstep.getParentFrame());
 footstep.setPositionChangeOnlyXY(nextStep2d);
 calculateTouchdownFootPolygon(footstep, captureRegion.getReferenceFrame(), touchdownFootPolygon);
}
origin: us.ihmc/CommonWalkingControlModules

double rotationOnEdge = edgeVector.dot(desiredRotationVector);
if (closestEdgeToCoP.isPointOnLeftSideOfLineSegment(footPolygon.getCentroid()))
origin: us.ihmc/CommonWalkingControlModules

projectedCapturePoint2d.setByProjectionOntoXYPlaneIncludingFrame(projectedCapturePoint);
distanceICPToFeet.get(robotSide).set(projectedCapturePoint2d.distance(footPolygon.getCentroid()));
isRobotBackToSafeState.set(false);
us.ihmc.robotics.geometryFrameConvexPolygon2dgetCentroid

Popular methods of FrameConvexPolygon2d

  • <init>
    Creates an empty convex polygon attached to a reference frame, adds N new vertices using an array of
  • getNumberOfVertices
  • changeFrameAndProjectToXYPlane
  • getFrameVertex
  • isPointInside
    isPointInside Determines whether a point is inside the convex polygon (point in polygon test). Uses
  • getConvexPolygon2d
  • getVertex
  • intersectionWith
  • setIncludingFrameAndUpdate
    This method does: 1- clear(referenceFrame); 2- addVertices(vertices); 3- update().
  • addVertex
    Add a vertex to this polygon. Note that this method recycles memory.
  • addVertexByProjectionOntoXYPlane
    Add a vertex to this polygon after doing newVertex2d.changeFrameAndProjectToXYPlane(this.referenceFr
  • addVertices
  • addVertexByProjectionOntoXYPlane,
  • addVertices,
  • clear,
  • getReferenceFrame,
  • isEmpty,
  • orthogonalProjection,
  • scale,
  • update,
  • addVertexAndChangeFrame

Popular in Java

  • Making http requests using okhttp
  • notifyDataSetChanged (ArrayAdapter)
  • requestLocationUpdates (LocationManager)
  • onCreateOptionsMenu (Activity)
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • JOptionPane (javax.swing)
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • Runner (org.openjdk.jmh.runner)
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now