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

Added tests for chains #351

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open

Conversation

danbarla
Copy link
Collaborator

@danbarla danbarla commented Apr 29, 2022

This PR adds tests to testChain.cpp.
The first test I added compares between classic analysis (wrench constraint for every link) of an A1 leg and kinematic chain analysis. This comes after I had trouble when comparing bigger factor graphs (classic way and chain way) and I had to go simple and follow the math. There is also an overleaf with detailed explanations.

The second test I added sets a basic graph for one leg of the A1 quadruped using DynamicsGraph, and another graph using Chain constraints. the test compares the results and checks them to be identical.

The third test I added compares a Dynamics Graph and a Chain graph for all 4 legs of the A1, for 1 time slice and 4 legs on the ground (robot standing still)

@danbarla danbarla requested a review from dellaert April 29, 2022 16:50
Copy link
Member

@dellaert dellaert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to read the overleaf but I am confused. I propose you

  1. use L, U, H, T for the link frames, not ABC. Hard enough to read without translating.
  2. when using a word in the text, always but symbol, and vice versa
  3. most importantly: I think the parent-child relationship should be consistent, from the trunk (great-grandparent) to hip (grandparent) to upper (parent) to lower (child). So, the wrench unknowns will be F^1_L, F^2_U, F^3_H.
  4. finally, do the joint numbers agree with A1 URDF? This is maybe the meta-advice: avoid introducing extra translation tables between symbols will make debugging and understanding more clear.

I'll take another look after you make those changes in doc and corresponding symbols in code. Hopefully just global replaces...

tests/testChain.cpp Outdated Show resolved Hide resolved
tests/testChain.cpp Outdated Show resolved Hide resolved
tests/testChain.cpp Outdated Show resolved Hide resolved
tests/testChain.cpp Outdated Show resolved Hide resolved
@danbarla
Copy link
Collaborator Author

danbarla commented May 6, 2022

adapted overleaf and symbols in code.

@danbarla danbarla requested a review from dellaert May 6, 2022 14:47
@dellaert
Copy link
Member

dellaert commented May 6, 2022

@danbarla can you give me write access on the overleaf? Mostly for commenting but when I see a typo I can immediately fix...

Copy link
Member

@dellaert dellaert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still puzzled, in both overleaf and code, where the wrench from the ground is. Ultimately, we need a force exerted by the ground to keep the robot from falling, right? In the youtube video I did that by creating a "virtual joint" at the contact point and then asserting (via a constraint) that there was no moment exteted by the joint on the child link. I think in that case the child link is the "floor".

tests/testChain.cpp Outdated Show resolved Hide resolved
@danbarla
Copy link
Collaborator Author

overleaf and code updated with the ground constraint.

@danbarla danbarla requested a review from dellaert May 11, 2022 20:18
Copy link
Member

@dellaert dellaert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I don't have cycles now to do a thorough review. If you think everything is correct, feel free to merge.

@varunagrawal
Copy link
Collaborator

@danbarla should we merge this?

@danbarla
Copy link
Collaborator Author

danbarla commented Jul 7, 2022

@danbarla should we merge this?

I am actively working on this branch. I will merge it next week.

@danbarla danbarla requested a review from dellaert June 1, 2023 18:10
@danbarla
Copy link
Collaborator Author

danbarla commented Jun 1, 2023

Hi @dellaert ,
I am ready to merge this PR.
It was opened and approved a year ago, but a lot has changed since then.
Most of the new code and constraints which I used for the paper and thesis was written and pushed to this PR after it was approved the first time. I realize it wasn't the best thing to do :) .
The hardcore changes are in the Chain and ChainDynamicsGraph classes.

/**
* @brief Create expression for child wrench adjoint from parent link
*/
gtsam::Vector6_ childAdjointWrench(gtsam::Vector6_ &wrench_p,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be named childWrenchAdjoint so it matches the docstring?

InsertTwist(&values, i, t, sampler.sample());
InsertTwistAccel(&values, i, t, sampler.sample());
const int i = link->id();
if (i==0 || i==3 || i==6 || i==9 || i==12)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what's happening here. The link IDs are not guaranteed to be consistent across robots. If these IDs are for the feet, they should be passed in as an argument.

JointVelKey(j, t), JointAccelKey(j, t)};
for (size_t i = 0; i < keys.size(); i++)
values.insert(keys[i], sampler.sample()[0]);
}

if (contact_points) {
for (auto&& cp : *contact_points) {
//if (contact_points) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason this is commented out?

const int i = link->id();
if (i==0 || i==3 || i==6 || i==9 || i==12)
InsertPose(&values, i, t, AddGaussianNoiseToPose(link->bMcom(), sampler));
//InsertTwist(&values, i, t, sampler.sample());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you've moved these lines outside the if statement, kill these commented out lines?

@@ -303,6 +308,310 @@ TEST(Chain, DynamicalEquality3_H_angles_chain1) {
}
}

// Test Chain Constraint Jacobians -AdjointWrenchEquality3 - H_angles - first type
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: doxygen comments should be

/// Single line docstring

or

/**
 * Multiline docstring
 */

#plt.show()
plt.show()
#plt.rc('pgf', texsystem='pdflatex')
#plt.savefig('/home/dan/Desktop/my_papers/thesis/create_simulation/pyb_sim.pgf')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please kill commented code if you're not using it.

@@ -12,11 +12,12 @@

_ = p.connect(p.GUI)
p.setAdditionalSearchPath(pybullet_data.getDataPath()) # To load plane SDF.
print(pybullet_data.getDataPath())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole file needs some cleaning up IMHO.


using namespace gtdynamics;

// Returns a Trajectory object for a single a1 walk cycle.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please run the formatter on this?

objectives.add(JointObjectives(joint->id(), k).angle(-1.4, prior_model_angles));
}

// Add prior on A1 lower joint angles
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please kill commented out code and run the formatter?

${WALK_FORWARD_COMBINED}.run
COMMAND ./${WALK_FORWARD_COMBINED}
DEPENDS ${WALK_FORWARD_COMBINED}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/examples/${PROJECT_NAME})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newline please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants