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

Fix #122 by enabling joints to connect rods and rigid bodies #149

Merged

Conversation

mstoelzle
Copy link
Contributor

@mstoelzle mstoelzle commented Jul 20, 2022

Features and Changes

This issue fixes #122 by implementing the following changes and features:

  1. Enables the connection of Cosserat rods and rigid bodies in any arbitrary combination for the following joint types: FreeJoint, HingeJoint, and FixedJoint
  2. The FreeJoint constrains the translational movement of both systems at the specified connection point. As the point of joint connection doesn't necessarily coincide with the center of mass of the rigid body or the node of the rod, the user can use the point_system_one and point_system_two parameters to specify how the connection point relates to the node / CoM in the local frame of the system.
  3. For the HingeJoint, the link_direction of the second system is now extracted from the director_collection instead of subtracting node positions
  4. The FixedJoint class now also accepts the point_system_one and point_system_two parameters and forwards them to the parent class FreeJoint

Examples of Usage

How to connect two Cosserat rods together using a spherical joint with a gap of 0.01 m in between.

simulator.connect(rod_one, rod_two).using(
    FreeJoint,
    k=1e4,
    nu=1,
    point_system_one=np.array([0.0, 0.0, 0.005]),
    point_system_two=np.array([0.0, 0.0, -0.005]),
)

How to connect the distal end of a CosseratRod with the base of a cylinder using a spherical joint.

simulator.connect(rod, cylinder).using(
    FreeJoint,
    k=1e4,
    nu=1,
    point_system_two=np.array([0.0, 0.0, -cylinder.length / 2.]),
)

How to connect a cosserat rod with the base of a cylinder using a fixed joint, where the cylinder is rotated by 45 degrees around the y-axis.

from scipy.spatial.transform import Rotation
simulator.connect(rod, cylinder).using(
      FixedJoint,
      k=1e5,
      nu=1e0,
      kt=1e3,
      nut=1e-3,
      point_system_two=np.array([0, 0, -cylinder.length / 2]),
      rest_rotation_matrix=Rotation.from_euler('y', np.pi / 4, degrees=False).as_matrix(),
)

Results from JointCases

Spherical joint:

System consisting of two rods and one cylinder connected with spherical joints. The sinusoidal force is applied to the second rod. Example can be run using:

python examples/JointCases/spherical_joint.py
spherical_joint_example.mp4

Fixed joint:

System consisting of two rods and one cylinder connected with fixed joints. The sinusoidal force is applied to the second rod. Example can be run using:

python examples/JointCases/fixed_joint.py
fixed_joint_example.mp4

TODOs

  • Write tests for connecting rods with cylinders, particularly for non-zero point_system_one and point_system_two parameters
  • Add cylinder to spherical_joint.py example as third element.
  • Add cylinder to fixed_joint.py example as third element

@codecov-commenter
Copy link

codecov-commenter commented Jul 20, 2022

Codecov Report

Merging #149 (24c69e6) into update-0.3.0 (d0cb959) will not change coverage.
The diff coverage is 100.00%.

@@              Coverage Diff              @@
##           update-0.3.0     #149   +/-   ##
=============================================
  Coverage         87.62%   87.62%           
=============================================
  Files                43       43           
  Lines              2820     2820           
  Branches            368      368           
=============================================
  Hits               2471     2471           
  Misses              328      328           
  Partials             21       21           
Impacted Files Coverage Δ
elastica/joint.py 26.34% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d0cb959...24c69e6. Read the comment docs.

@mstoelzle
Copy link
Contributor Author

@armantekinalp @skim0119 @bhosale2 Can you guys please do a first round of reviews of this PR? As soon as we have settled on the specifications of the class / function interfaces, I will implement the necessary tests for connecting rods with rigid bodies.

@bhosale2 bhosale2 linked an issue Jul 20, 2022 that may be closed by this pull request
@armantekinalp
Copy link
Contributor

@mstoelzle is the simulation in second video explodes ?

@bhosale2 bhosale2 added the enhancement New feature or request label Jul 21, 2022
@bhosale2 bhosale2 added this to the Version 0.3 milestone Jul 21, 2022
@bhosale2
Copy link
Collaborator

@mstoelzle we can focus on this one after #143 is completed, which is closer to completion.

@mstoelzle
Copy link
Contributor Author

mstoelzle commented Jul 31, 2022

Minor stuff, good work @mstoelzle, after this round it will be LGTM from my side.
Also based on #163, please pull latest update, then modify the rod damper class name ExponentialDamper to AnalyticalLinearDamper.

@bhosale2 Thanks for your suggestions. I addressed all of them and I also fixed a bug in the changes for the HingeJoint

Copy link
Collaborator

@bhosale2 bhosale2 left a comment

Choose a reason for hiding this comment

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

Super minor stuff.

mstoelzle and others added 2 commits July 31, 2022 20:23
…_joint.py

Co-authored-by: Yashraj Bhosale <yashraj.iitb@gmail.com>
…nt.py

Co-authored-by: Yashraj Bhosale <yashraj.iitb@gmail.com>
Copy link
Collaborator

@bhosale2 bhosale2 left a comment

Choose a reason for hiding this comment

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

LGTM. @skim0119 please take over.

@bhosale2 bhosale2 requested a review from skim0119 July 31, 2022 18:25
Copy link
Collaborator

@skim0119 skim0119 left a comment

Choose a reason for hiding this comment

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

@mstoelzle LGTM. Minor changes for documentation consistency.

@armantekinalp Do you think we should make a nightly doc page that includes experimental modules?

Copy link
Collaborator

@skim0119 skim0119 left a comment

Choose a reason for hiding this comment

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

Looks good. I haven't run the test and examples, but we'll check them before releasing v0.3

@skim0119 skim0119 merged commit c0b0b27 into GazzolaLab:update-0.3.0 Aug 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Topic that needs to be discussed. enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Joint between Rod and RigidBody
5 participants