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

[mapping] new component (BeamProjectionDifferenceMultiMapping) #113

Merged
merged 2 commits into from
Oct 26, 2023

Conversation

EulalieCoevoet
Copy link
Collaborator

This PR adds a new component with an example and test.

BeamProjectionDifferenceMultiMapping : This mapping takes some points and a beam as inputs, and outputs the difference between the points and their projection on the beam. The output difference is expressed in the local frame (wrt the beam), allowing the set up of constraints such as a fixing constraint (ex: attach a beam to another model) and sliding constraint (ex: constrain an object to slide on a beam).

Example of usage :
(you can also try the example examples/python3/component/BeamProjectionDifferenceMultiMapping.py)

# This will constrain a particle (a rigid frame) to slide along a beam
  sliding = particle.addChild('SlidingConstraint')
  beam.addChild(sliding)
  sliding.addObject('MechanicalObject', template='Rigid3', position=[0, 0, 0, 0, 0, 0, 0])  
  sliding.addObject('RestShapeSpringsForceField', stiffness=1e6)  # Put a spring on the difference to maintain it to zero
  sliding.addObject('BeamProjectionDifferenceMultiMapping',
                    directions=[0, 1, 1, 0, 0, 0, 0],  # The directions to compute
                    # Here only y, z positions to allow the particle to slide on the beam's principal direction, x
                    input1=particle.getMechanicalState().linkpath,  # The particle (a rigid frame)
                    indicesInput1=[0],  # Indices to use in the input1 model
                    input2=beam.getMechanicalState().linkpath,  # The beam on which to project the particle
                    interpolationInput2=beam.BeamInterpolation.linkpath,
                    output=sliding.getMechanicalState().linkpath  # This will contain the difference (in local frame) between the particle and its projection on the beam
                    )

The test has not been added to the project because it crashes. I didn't manage to debug it yet, although it was working not so long ago. I would still like to merge it to avoid losing it.

@EulalieCoevoet EulalieCoevoet added the enhancement New feature or request label Oct 9, 2023
Copy link
Contributor

@epernod epernod left a comment

Choose a reason for hiding this comment

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

Could you describe a bit more when this component can be used?
If you have 2 points and a beam of 10 nodes. Does it project the 2 points on each node or only on the closest?

The points to be projected can only be in rigid?

@EulalieCoevoet
Copy link
Collaborator Author

When this component can be used?
Well, as I said if you want to attach a Rigid (can be another beam) to a beam, or if you want to constrain a Rigid to slide on a beam (only in position, only in rotation, or both in position and rotation). I show different usages in the example.

If you have 2 points and a beam of 10 nodes. Does it project the 2 points on each node or only on the closest?
It's the orthogonal projection of the points on the beam (can be none).

The points to be projected can only be in rigid?
I've only implemented the Rigid template yes.

@epernod epernod added the pr: status ready Approved a pull-request, ready to be squashed label Oct 26, 2023
@epernod epernod merged commit 3b856ad into sofa-framework:master Oct 26, 2023
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pr: status ready Approved a pull-request, ready to be squashed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants