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

Feature/add missing tools #20

Merged
merged 27 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
73c826f
Renamed subsprojects to kebab-case. Moved all src and test directorie…
Sep 7, 2017
4a97e25
Minor in cleanup the InverseDynamicsCalculator.
Jan 30, 2018
c9ac494
Cleaned up some the rate limited yo-variables.
Feb 1, 2018
24a9709
Renamed getExpressedInFrame() to getReferenceFrame().
Nov 2, 2018
fb12fdb
Renamed SpatialAccelerationVector and SpatialForceVector.
Nov 2, 2018
fdee16c
:arrow_up: mecano 0.0.3.
Nov 5, 2018
fbfef5b
Reshaping the joints API.
Nov 6, 2018
3dcd268
Removing desired accelerations, started w/ SpatialAccelCalculator.
Nov 6, 2018
0dc7f4b
Changed the returned type for getChildrenJoints.
Nov 7, 2018
95df1fb
Fixed a reference frame mismatch.
Nov 7, 2018
079f64d
Switched to mecano's CoM calculator.
Nov 7, 2018
e6b1fb4
Modified the feedback controller toolbox to provide mutable frame obj…
Apr 4, 2019
c22d075
Adding new getter in coriolis matrix calculator
stephenmcc Oct 8, 2019
b291874
Maintaining state of joints in GravityCoriolisExternalWrenchMatrixCal…
stephenmcc Oct 8, 2019
34db866
Switched MatrixTools.
Dec 5, 2019
411f1d9
Re-implemented the gravity/coriolis/external-wrench calculator.
Jan 24, 2020
4f491d8
:arrow_up: EJML, GeoRegression, DDogleg, BoofCV.
Jun 9, 2020
16c2616
Applied cleanup.
Jul 19, 2020
b538f8c
First version of momentum estimator
Oct 15, 2021
f7c8809
set up a whole-body inertia calculator
rjgriffin42 Sep 24, 2021
17105c5
Addressed some frame mismatch exceptions.
SylvainBertrand Aug 9, 2022
45f2cdd
Fixed the gravity calculator for the cross 4 bar joint.
SylvainBertrand Aug 16, 2023
2a5c7bc
New twist calculator that is more flexible
SylvainBertrand Mar 5, 2024
cb0fb6d
deleted minimum jerk trajectory and deprecated trapesoidal velocity t…
rjgriffin42 Aug 6, 2024
611cc9a
identified a bug in the FBRD Calculator for the force jacobian sign. …
rjgriffin42 Oct 2, 2024
e447d79
started moving a bunch of packages to allow extracting the whole-body…
rjgriffin42 Oct 14, 2024
a47a947
:arrow_up: ihmc-yovariables 0.13.3 :arrow_up: euclid 0.22.2
rjgriffin42 Oct 29, 2024
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Top level files to ignore
gradlew
gradlew.bat

# Top level directories to ignore
/gradle
/build
/classes
/bin
Expand Down
14 changes: 10 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ mainDependencies {
api("org.ejml:ejml-core:0.39")
api("org.ejml:ejml-ddense:0.39")

api("us.ihmc:euclid:0.21.0")
api("us.ihmc:euclid-frame:0.21.0")
api("us.ihmc:euclid-geometry:0.21.0")
api("us.ihmc:euclid:0.22.2")
api("us.ihmc:euclid-frame:0.22.2")
api("us.ihmc:euclid-geometry:0.22.2")
}

testDependencies {
Expand Down Expand Up @@ -47,5 +47,11 @@ graphvizDependencies {
yovariablesDependencies {
api(ihmc.sourceSetProject("main"))

api("us.ihmc:ihmc-yovariables:0.12.2")
api("us.ihmc:ihmc-yovariables:0.13.3")
}

yovariablesFiltersDependencies {
api(ihmc.sourceSetProject("yovariables"))

api("us.ihmc:ihmc-yovariables-filters:0.13.3")
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
title = Mecano
extraSourceSets = ["test", "graphviz", "yovariables"]
extraSourceSets = ["test", "graphviz", "yovariables", "yovariables-filters"]
compositeSearchHeight = 0
excludeFromCompositeBuild = false
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
package us.ihmc.mecano.algorithms;

import java.util.LinkedHashMap;

import org.ejml.data.DMatrixRMaj;
import org.ejml.dense.row.CommonOps_DDRM;

import us.ihmc.euclid.referenceFrame.ReferenceFrame;
import us.ihmc.mecano.algorithms.interfaces.MassMatrixCalculator;
import us.ihmc.mecano.multiBodySystem.interfaces.JointBasics;
import us.ihmc.mecano.multiBodySystem.interfaces.RigidBodyBasics;
import us.ihmc.mecano.spatial.SpatialForce;
import us.ihmc.mecano.spatial.Wrench;
import us.ihmc.mecano.spatial.interfaces.SpatialAccelerationReadOnly;
import us.ihmc.mecano.tools.JointStateType;
import us.ihmc.mecano.tools.MecanoFactories;
import us.ihmc.mecano.tools.MultiBodySystemTools;

/**
* Very inefficient. Should only be used for verification of better methods in unit tests
*/
public class DifferentialIDMassMatrixCalculator implements MassMatrixCalculator
{
private final InverseDynamicsCalculator idCalculator;
private final JointBasics[] jointsInOrder;
private final DMatrixRMaj massMatrix;
private final DMatrixRMaj storedJointDesiredAccelerations;
private final DMatrixRMaj tmpDesiredJointAccelerationsMatrix;
private final DMatrixRMaj tmpTauMatrix;
private final LinkedHashMap<JointBasics, Wrench> storedJointWrenches = new LinkedHashMap<JointBasics, Wrench>();
private final DMatrixRMaj storedJointVelocities;

private final int totalNumberOfDoFs;

public DifferentialIDMassMatrixCalculator(ReferenceFrame inertialFrame, RigidBodyBasics rootBody)
{
SpatialAccelerationReadOnly zeroRootAcceleration = MecanoFactories.newGravitationalSpatialAcceleration(rootBody, 0.0);

idCalculator = new InverseDynamicsCalculator(rootBody);
idCalculator.setConsiderCoriolisAndCentrifugalForces(false);
idCalculator.setConsiderJointAccelerations(true);
idCalculator.setRootAcceleration(zeroRootAcceleration);
jointsInOrder = MultiBodySystemTools.collectSubtreeJoints(rootBody);
totalNumberOfDoFs = MultiBodySystemTools.computeDegreesOfFreedom(jointsInOrder);
massMatrix = new DMatrixRMaj(totalNumberOfDoFs, totalNumberOfDoFs);

storedJointDesiredAccelerations = new DMatrixRMaj(totalNumberOfDoFs, 1);
storedJointVelocities = new DMatrixRMaj(totalNumberOfDoFs, 1);
tmpDesiredJointAccelerationsMatrix = new DMatrixRMaj(totalNumberOfDoFs, 1);
tmpTauMatrix = new DMatrixRMaj(totalNumberOfDoFs, 1);

for (JointBasics joint : jointsInOrder)
{
ReferenceFrame bodyFixedFrame = joint.getSuccessor().getBodyFixedFrame();
Wrench jointWrench = new Wrench(bodyFixedFrame, bodyFixedFrame);
storedJointWrenches.put(joint, jointWrench);
}
}

@Override
public void compute()
{
storeJointState();
setDesiredAccelerationsToZero();

int column = 0;

for (int i = 0 ; i < totalNumberOfDoFs; i++)
{
tmpDesiredJointAccelerationsMatrix.set(i, 0, 1.0);
MultiBodySystemTools.insertJointsState(jointsInOrder, JointStateType.ACCELERATION, tmpDesiredJointAccelerationsMatrix);

idCalculator.compute();
tmpTauMatrix.set(idCalculator.getJointTauMatrix());
CommonOps_DDRM.extract(tmpTauMatrix, 0, totalNumberOfDoFs, 0, 1, massMatrix, 0, column);
column++;

tmpDesiredJointAccelerationsMatrix.set(i, 0, 0.0);
}

restoreJointState();
}

private void setDesiredAccelerationsToZero()
{
for (JointBasics joint : jointsInOrder)
{
joint.setJointAccelerationToZero();
joint.setJointVelocity(0, new DMatrixRMaj(joint.getDegreesOfFreedom(), 1));
}
}

private void storeJointState()
{
MultiBodySystemTools.extractJointsState(jointsInOrder, JointStateType.ACCELERATION, storedJointDesiredAccelerations);
MultiBodySystemTools.extractJointsState(jointsInOrder, JointStateType.VELOCITY, storedJointVelocities);
for (JointBasics joint : jointsInOrder)
{
DMatrixRMaj tauMatrix = new DMatrixRMaj(joint.getDegreesOfFreedom(), 1);
joint.getJointTau(0, tauMatrix);
DMatrixRMaj spatialForce = new DMatrixRMaj(SpatialForce.SIZE, 1);
DMatrixRMaj motionSubspace = new DMatrixRMaj(6, joint.getDegreesOfFreedom());
joint.getMotionSubspace(motionSubspace);
CommonOps_DDRM.mult(motionSubspace, tauMatrix, spatialForce);
Wrench jointWrench = storedJointWrenches.get(joint);
jointWrench.setIncludingFrame(joint.getFrameAfterJoint(), spatialForce);
jointWrench.changeFrame(joint.getFrameAfterJoint());
}
}

private void restoreJointState()
{
MultiBodySystemTools.insertJointsState(jointsInOrder, JointStateType.ACCELERATION, storedJointDesiredAccelerations);
MultiBodySystemTools.insertJointsState(jointsInOrder, JointStateType.VELOCITY, storedJointVelocities);

for (JointBasics joint : jointsInOrder)
{
joint.setJointWrench(storedJointWrenches.get(joint));
}
}

@Override
public DMatrixRMaj getMassMatrix()
{
return massMatrix;
}

@Override
public void getMassMatrix(DMatrixRMaj massMatrixToPack)
{
massMatrixToPack.set(massMatrix);
}

@Override
public JointBasics[] getJointsInOrder()
{
return jointsInOrder;
}
}
Loading
Loading