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

Strandbeest example #13302

Merged
merged 11 commits into from
May 19, 2020
Merged

Conversation

joemasterjohn
Copy link
Contributor

@joemasterjohn joemasterjohn commented May 13, 2020

Adds a parameterized strandbeest example that tests out the new URDF parsing capabilities for creating LinearBushingRollPitchYaw (#13255).


This change is Reviewable

@jwnimmer-tri
Copy link
Collaborator

jwnimmer-tri commented May 13, 2020

We have @row_xacro available in our bazel workspace. Generally for new code we should use that as part of the BUILD rules, instead of committing its output into git. I can help with that integration.

The xacro data is large; did you write it on your own? Or was it copied from somewhere? (If so, we need to preserve its copyright and licensing.)

Copy link
Contributor Author

@joemasterjohn joemasterjohn left a comment

Choose a reason for hiding this comment

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

Ok thanks, I'd appreciate your help with the @xacrointegration.

I actually adapted the xacro from data from an old drake commit:
https://github.com/RobotLocomotion/drake/tree/last_sha_with_original_matlab/drake/examples/Strandbeest

Things like link names, dimensions and joint associations are the same. But there is a lot added for calculating mass/inertia accurately and the custom tags added to replace loop_joints.

Reviewable status: needs platform reviewer assigned, needs at least two assigned reviewers

@jwnimmer-tri
Copy link
Collaborator

Wow, see d87d931 -- maybe Robin actually wrote these by hand originally? I assumed we'd copied them from somewhere else. It might be nice to add Co-authored-by on the commit with the xacro, or even curate a first commit with just the file added unmodified from the few years ago. Then it would also call out your edits as diffs.

@amcastro-tri
Copy link
Contributor

@joemasterjohn did a lot of editing to this model to get physical properties such as mass and rotational inertias right (we found out a must to get time scales right). I agree though we should give both Joe and Robin credit for this model.

@jwnimmer-tri
Copy link
Collaborator

=> #13304 provides what I hope are sufficient bazel xacro macros to generate the sdf on demand.

Copy link
Contributor Author

@joemasterjohn joemasterjohn left a comment

Choose a reason for hiding this comment

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

+@avalenzu for feature review on Monday, please!

Reviewable status: LGTM missing from assignee avalenzu, needs platform reviewer assigned, needs at least two assigned reviewers (waiting on @avalenzu)

Copy link
Contributor

@avalenzu avalenzu left a comment

Choose a reason for hiding this comment

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

Review pass done. PTAL.

Reviewed 7 of 7 files at r1.
Reviewable status: 10 unresolved discussions, LGTM missing from assignee avalenzu, needs platform reviewer assigned, needs at least two assigned reviewers, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @joemasterjohn)


examples/multibody/strandbeest/BUILD.bazel, line 28 at r1 (raw file):

    test_rule_timeout = "moderate",
    deps = [
        "//common:find_resource",

nit: Could you add //common:add_text_logging_gflags to the deps here? That enables the --spdlog_level flag. See https://github.com/RobotLocomotion/drake/blob/master/common/add_text_logging_gflags.cc.


examples/multibody/strandbeest/BUILD.bazel, line 36 at r1 (raw file):

        "//multibody/tree",
        "//solvers",
        "//solvers:snopt_solver",

nit: This is redundant, as snopt_solver is already included in //solvers.


examples/multibody/strandbeest/README.md, line 1 at r1 (raw file):

# Strandbeest

This file should probably have an acknowledgment of Theo Jansen (the creator of the Strandbeest).


examples/multibody/strandbeest/README.md, line 4 at r1 (raw file):

## Change the model
Modfiy any relevant values in `model/Macros.xacro`. The Strandbeest model is 

nit: s/Modifiy/Modify


examples/multibody/strandbeest/README.md, line 9 at r1 (raw file):

## Run the example

bazel run --config snopt //examples/multibody/strandbeest:run_with_motor

Does the IK solve in run_with_motor only work with SNOPT? If not, it would be better to leave out the --config snopt.


examples/multibody/strandbeest/run_with_motor.cc, line 140 at r1 (raw file):

  }

  // Set the penetration allowand and stiction tolerance to values that make

nit: s/allowand/allowance


examples/multibody/strandbeest/run_with_motor.cc, line 162 at r1 (raw file):

  auto diagram = builder.Build();

  // Create a context for this system and context for the strandbeest system.

nit: This would probably be clearer as "... for the diagram and extract the context for the ..."


examples/multibody/strandbeest/run_with_motor.cc, line 207 at r1 (raw file):

        strandbeest.GetForceElement<LinearBushingRollPitchYaw>(bushing_index);

    ik.AddPointToPointDistanceConstraint(bushing.frameA(), Eigen::Vector3d(),

I thought that Eigen's default constructors left data uninitialized?


examples/multibody/strandbeest/model/LegAssembly.xacro, line 158 at r1 (raw file):

    <frame name="${prefix}_loop_f_g_bushing_frameA"
        link="${prefix}_bar_f"
        rpy="-1.5707963267948966 0 0"

Could these super precise constants be replaced with ${pi/2} as was done earlier in this file?


examples/multibody/strandbeest/model/LegPair.xacro, line 69 at r1 (raw file):

    <frame name="${prefix}_leg1_loop_a_c_bushing_frameA"
        link="${prefix}_bar_a"
        rpy="-1.5707963267948966 0 0"

Could this be ${-pi/2} here and below?

Copy link
Contributor Author

@joemasterjohn joemasterjohn left a comment

Choose a reason for hiding this comment

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

Thanks @avalenzu! The IK does solver with the default chosen solver without added --config snopt (which is IPOPT), but I have been running it with SNOPT because it is considerably faster. I thought that IPOPT might be causing the timeout failure I'm seeing in CI, but even after changing the test timeout to moderate it seems to timeout on two builds. Any ideas?

Reviewable status: 5 unresolved discussions, LGTM missing from assignee avalenzu, needs platform reviewer assigned, needs at least two assigned reviewers, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @avalenzu)


examples/multibody/strandbeest/BUILD.bazel, line 28 at r1 (raw file):

Previously, avalenzu (Andres Valenzuela) wrote…

nit: Could you add //common:add_text_logging_gflags to the deps here? That enables the --spdlog_level flag. See https://github.com/RobotLocomotion/drake/blob/master/common/add_text_logging_gflags.cc.

Done.


examples/multibody/strandbeest/BUILD.bazel, line 36 at r1 (raw file):

Previously, avalenzu (Andres Valenzuela) wrote…

nit: This is redundant, as snopt_solver is already included in //solvers.

Done.


examples/multibody/strandbeest/README.md, line 1 at r1 (raw file):

Previously, avalenzu (Andres Valenzuela) wrote…

This file should probably have an acknowledgment of Theo Jansen (the creator of the Strandbeest).

Done.


examples/multibody/strandbeest/README.md, line 9 at r1 (raw file):

Previously, avalenzu (Andres Valenzuela) wrote…

Does the IK solve in run_with_motor only work with SNOPT? If not, it would be better to leave out the --config snopt.

No, but it is considerably faster than the default chosen solver (Ipopt in my default setup. I've added running with SNOPT as an optional thing to do, with a link to Drake docs for SNOPT setup.


examples/multibody/strandbeest/run_with_motor.cc, line 207 at r1 (raw file):

Previously, avalenzu (Andres Valenzuela) wrote…

I thought that Eigen's default constructors left data uninitialized?

Oh good catch. Surprised that didn't cause havoc in the IK.


examples/multibody/strandbeest/model/LegAssembly.xacro, line 158 at r1 (raw file):

Previously, avalenzu (Andres Valenzuela) wrote…

Could these super precise constants be replaced with ${pi/2} as was done earlier in this file?

Done.


examples/multibody/strandbeest/model/LegPair.xacro, line 69 at r1 (raw file):

Previously, avalenzu (Andres Valenzuela) wrote…

Could this be ${-pi/2} here and below?

Done.

Copy link
Contributor

@avalenzu avalenzu left a comment

Choose a reason for hiding this comment

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

:lgtm: +@sammy-tri for platform review.

Reviewed 6 of 6 files at r2.
Reviewable status: LGTM missing from assignee sammy-tri(platform), commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @sammy-tri)


examples/multibody/strandbeest/README.md, line 9 at r1 (raw file):

Previously, joemasterjohn (Joe Masterjohn) wrote…

No, but it is considerably faster than the default chosen solver (Ipopt in my default setup. I've added running with SNOPT as an optional thing to do, with a link to Drake docs for SNOPT setup.

Perfect.


examples/multibody/strandbeest/run_with_motor.cc, line 207 at r1 (raw file):

Previously, joemasterjohn (Joe Masterjohn) wrote…

Oh good catch. Surprised that didn't cause havoc in the IK.

Yeah, I was surprised by that too ... ¯_(ツ)_/¯

Copy link
Contributor

@sammy-tri sammy-tri left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 7 files at r1, 6 of 6 files at r2.
Reviewable status: 5 unresolved discussions, LGTM missing from assignee sammy-tri(platform), commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @joemasterjohn)


examples/multibody/strandbeest/run_with_motor.cc, line 21 at r2 (raw file):

#include "drake/multibody/inverse_kinematics/inverse_kinematics.h"
#include "drake/multibody/parsing/parser.h"
#include "drake/multibody/plant/contact_results_to_lcm.h"

unused (at least directly)


examples/multibody/strandbeest/run_with_motor.cc, line 39 at r2 (raw file):

using multibody::BodyIndex;
using multibody::ForceElementIndex;
using multibody::Frame;

unused


examples/multibody/strandbeest/run_with_motor.cc, line 42 at r2 (raw file):

using multibody::InverseKinematics;
using multibody::Joint;
using multibody::JointIndex;

unused


examples/multibody/strandbeest/model/LegAssembly.xacro, line 118 at r2 (raw file):

    </joint>

    <joint name="${prefix}_joint_k_i" type="revolute">

Should the joint names match the names of the links being joined in all cases? This joint "k_i" joints bars "k" and "g". There are a couple others below which also don't match ("j_e" and "e_f").


examples/multibody/strandbeest/model/Macros.xacro, line 31 at r2 (raw file):

  <xacro:macro name="strandbeest_cylinder_inertial"
      params="xyz rpy length radius">

parameter radius is unused?

Copy link
Contributor Author

@joemasterjohn joemasterjohn left a comment

Choose a reason for hiding this comment

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

Reviewable status: 5 unresolved discussions, LGTM missing from assignee sammy-tri(platform), commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @sammy-tri)


examples/multibody/strandbeest/run_with_motor.cc, line 21 at r2 (raw file):

Previously, sammy-tri (Sam Creasey) wrote…

unused (at least directly)

Sorry, I'm confused on which include you're talking about here because I use ConnectContactResultsToDrakeVisualizer in do_main() and LinearBushingRollPitchYaw when constructing constraints for the IK.


examples/multibody/strandbeest/run_with_motor.cc, line 39 at r2 (raw file):

Previously, sammy-tri (Sam Creasey) wrote…

unused

Done.


examples/multibody/strandbeest/run_with_motor.cc, line 42 at r2 (raw file):

Previously, sammy-tri (Sam Creasey) wrote…

unused

Done.


examples/multibody/strandbeest/model/LegAssembly.xacro, line 118 at r2 (raw file):

Previously, sammy-tri (Sam Creasey) wrote…

Should the joint names match the names of the links being joined in all cases? This joint "k_i" joints bars "k" and "g". There are a couple others below which also don't match ("j_e" and "e_f").

Done.


examples/multibody/strandbeest/model/Macros.xacro, line 31 at r2 (raw file):

Previously, sammy-tri (Sam Creasey) wrote…

parameter radius is unused?

Done.

Copy link
Contributor

@sammy-tri sammy-tri left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 3 of 3 files at r3.
Reviewable status: commits need curation (https://drake.mit.edu/reviewable.html#curated-commits)


examples/multibody/strandbeest/run_with_motor.cc, line 21 at r2 (raw file):

Previously, joemasterjohn (Joe Masterjohn) wrote…

Sorry, I'm confused on which include you're talking about here because I use ConnectContactResultsToDrakeVisualizer in do_main() and LinearBushingRollPitchYaw when constructing constraints for the IK.

My bad, I forgot where that was defined. Sorry!

Copy link
Contributor Author

@joemasterjohn joemasterjohn left a comment

Choose a reason for hiding this comment

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

Reviewable status: commits need curation (https://drake.mit.edu/reviewable.html#curated-commits)


examples/multibody/strandbeest/run_with_motor.cc, line 21 at r2 (raw file):

Previously, sammy-tri (Sam Creasey) wrote…

My bad, I forgot where that was defined. Sorry!

Ok thanks!

@joemasterjohn joemasterjohn added the status: squashing now https://drake.mit.edu/reviewable.html#curated-commits label May 19, 2020
@joemasterjohn joemasterjohn merged commit 353a702 into RobotLocomotion:master May 19, 2020
@joemasterjohn joemasterjohn deleted the strandbeest branch June 16, 2020 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: squashing now https://drake.mit.edu/reviewable.html#curated-commits
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants