How do I track the centroid of a set of frames in simscape multibody?

2 views (last 30 days)
I have a bunch of frames that move in the simulation by the application of force. I want to create a frame at the centroid of all these frames and use this to apply forces on other bodies.
Any help to implement this is highly appreciated.

Accepted Answer

Ashok
Ashok on 19 Sep 2024
Edited: Ashok on 19 Sep 2024
Hey dst,
I understand that your main objective is to create a frame in “Simscape Multibody” located at the centroid of few other frames. One can later specify external forces in the newly created frame. The centroid calculation and frame creation can be achieved as follows:
  1. Firstly, to calculate the centroid, the positions of the existing frames is required which can be obtained using the “Transform Sensor block. You can find more information about the block in the following link. https://www.mathworks.com/help/sm/ref/transformsensor.html
  2. Once the translational positions of all the frames (x, y, z) are available, the centroid can be calculated within a “MATLAB Function block. The “MATLAB Function” block makes the centroid calculation scalable to a large number of frames.
  3. Finally, the “6-DOF Joint” block can be used to create a frame at the centroid location. You can read more about the “6-DOF Joint” block in the documentation linked below. https://www.mathworks.com/help/sm/ref/6dofjoint.html
The attached Simulink model demonstrates the above procedure for the case where a cubic body is to be created at the centroid of two existing frames. A screenshot of the model is shown below.
In the above Simulink model, the function, calculateCentroidtakes a concatenated array of position of the frames as input and produces the centroid location as output. For instance, if the vector represents the co-ordinates of the first frame and is the co-ordinates of the second frame, the input to the “MATLAB Function” would be . In Simulink, the concatenation is achieved via “Mux” blocks.
Alternatively, one can create a Simulink subsystem which has similar functionality as the “calculateCentroid” function, using PS Add” and “PS Gain blocks. You can read more about PS Add” and “PS Gain” blocks through the following links.
I hope this answers your query!

More Answers (0)

Products


Release

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!