Simscape forces and torques: Centrifugal, gravitational, accelerative

Goodafternoon 'u all,
I'm actually working with simscape and I was wondering if any way exist to get from a multibody model acting forces components, ad function of kinematic conditions. In simpler words, how can I get centrifugal, coriolis, gravitations, and accelerative forces components action on a mass or body of the system? Let's assume as first approximation we're working with rigid body (but I imagine would be in any case a good approximation also for other cases). I don't see any evident methd for getting them easily, unless repeating all required onerous calculations (futile to say I'm not going for :-D). In robotic toolbox all these components are directly derived from internal jacobians and kinematcs conditions. I was guessing any similar feature also exist in simscape. Remarks, I'm currently using simscape under simulink environment.
Suggestions?
Best regards

11 Comments

Hi @Enrico,

To address your query regarding, “I'm actually working with simscape and I was wondering if any way exist to get from a multibody model acting forces components, ad function of kinematic conditions. In simpler words, how can I get centrifugal, coriolis, gravitations, and accelerative forces components action on a mass or body of the system? Let's assume as first approximation we're working with rigid body (but I imagine would be in any case a good approximation also for other cases). I don't see any evident methd for getting them easily, unless repeating all required onerous calculations (futile to say I'm not going for :-D). In robotic toolbox all these components are directly derived from internal jacobians and kinematcs conditions. I was guessing any similar feature also exist in simscape. Remarks, I'm currently using simscape under simulink environment.Suggestions?”

Please see my response to your comments below.

The documentation provided by clicking link below provides information regarding modeling a manipulator arm using Simscape. It demonstrates various modeling techniques that can help you understand how to structure your models effectively for control and simulation purposes.

https://www.mathworks.com/help/robotics/ug/model-and-control-a-manipulator-arm-with-simscape.html

Here is another link below to documentation where you can use the jointPrimitivePaths method to identify joints involved in motion and by utilizing State objects returned by computeState,you can analyze joint velocities and positions.

https://www.mathworks.com/help/sm/ug/joints_matlab_class.html

Hope this helps. Please let me know if you have any further questions.

First, thanks for replying. I'm already able to simulate a simscape model programmatically or by simulink design, on the other side, as mentioned in my orginal request, I'm not just looking for kinematics of the system, but analyzing forces and torques respose,at joints or frame level. I was noticing that differently from robotic toolbox, whose I'm trying to reproduce some simscape copy, I can't get different components of force on joints like gravitational, velocity dependent and inertia matrix dependent components, I'd use for a detailed analysis I need for some further purpose.

Hi @Enrico,

The documentation provided in the link below does effectively answer your question regarding measuring forces and torques at joints within Simscape models. By leveraging the outlined procedures for sensing actuator torque, constraint forces, and total torque, you should be able to conduct a comprehensive analysis that meets your needs for detailed force characterization.

https://www.mathworks.com/help/releases/R2023b/sm/ug/sense-forces-and-torques-at-joints.html?searchHighlight=Simscape%20joints&s_tid=doc_srchtitle

In addition, the following documentation provides essential tools for measuring various forces and torques at joints within a Simscape model.

https://www.mathworks.com/help/sm/ug/sense-forces-and-torques-at-joints.html

The link below is an interesting tutorial which should help you understand the concept of “Controlling Robot Manipulator Joints”,

https://www.mathworks.com/support/search.html/videos/matlab-and-simulink-robotics-arena-controlling-robot-manipulator-joints-1521714030608.html?fq%5B%5D=asset_type_name:video&fq%5B%5D=category:sm/index&page=1

Hope this answers your question.

Maybe they replies to to the question which are total forces and torques actiong, but they do not respond to the original question: how to find forces and torques components associated to centrifugal, coriolis, gravitational and acceleratve componenets. If I need or I desire to analyze them separatedly there's no easy or straight forward way to have them in separated components of total acting resultants.

Hi @Enrico,

To address your inquiry regarding the separation of force and torque components—centrifugal, Coriolis, gravitational, and accelerative—in Simscape Multibody, it is important to note that while the built-in sensing capabilities can measure total forces and torques at joints, isolating these specific components requires a more nuanced approach.So, this is what I would suggest, in Simscape Multibody, you can utilize blocks for force and torque sensing alongside custom calculations to separate these components. Below is an example code snippet that demonstrates how you might set up a model to compute these forces:

% Define parameters
mass = 5; % Mass in kg
g = 9.81; % Acceleration due to gravity in m/s^2
angular_velocity = [0; 0; 2]; % Angular velocity vector in rad/s
linear_velocity = [1; 0; 0]; % Linear velocity vector in m/s
% Calculate forces
F_gravity = mass * g; % Gravitational force
F_centrifugal = mass * (angular_velocity(3)^2 * 1); % Assuming radius of   
rotation is 1m
F_coriolis = 2 * mass * cross(linear_velocity, angular_velocity); % 
Coriolis force
F_acceleration = mass * [0; 0; 2]; % Example acceleration in z-direction
% Total force calculation (as an example)
F_total = F_gravity + F_centrifugal + F_coriolis + F_acceleration;
% Display results
disp('Gravitational Force:');
disp(F_gravity);
disp('Centrifugal Force:');
disp(F_centrifugal);
disp('Coriolis Force:');
disp(F_coriolis);
disp('Accelerative Force:');
disp(F_acceleration);
disp('Total Force:');
disp(F_total);

Please bear in mind when working with complex mechanical systems in Simscape, it’s beneficial to simulate various scenarios where these forces act independently to better understand their interactions. By utilizing visualization tools within Simulink or MATLAB, you can gain insights into how changes in one component affect others. Moreover, consider integrating sensor blocks that allow you to monitor joint forces directly while also implementing custom calculations for more detailed analysis. This dual approach will help you achieve a comprehensive understanding of your system dynamics.

Thus, you're confrming me that I must do some calculation apart in simulink or matlab environment. I was guessing something like this, but I'd prefer to avoid it, since I need to include more infrastructure to my work, and in some case, when many bodies are involved, that could be work demanding and error prone. Indeed in multibody systems with multiple masses and inertia associated to diffferent rigidly connected frames, I need to use Eulero equations in body frame to calcualte components forces for each body (using transformations between frames) in each respective frame, summing them up for every body connected (in a chain for example) keeping separated each contribute. That's not so easy and I think Simscape could do it more effciently. We could avoid it using Jacobian approach or inertia matrix, but basing on my understanding these are not accessible so far.
Hi @Enrico,
Based on your recent comments, I will suggest strategic use of custom blocks and systematic modeling approaches which can help significantly streamline your workflow. Balancing between built-in functionalities and custom computations will ultimately lead to a more robust simulation framework tailored to your specific needs. Hope this helps.
Eventually I guess this is short term likely strategy, though in my opinion considering generality of the issue would be better to propose it as default functionality for simscape multibody, I guess would be much usefula for all user community! I'd prefer to find a bunch of developers willing to collaborate on this project more than just do it by myself and maybe, never use it anymore in future...

Hi @Enrico,

There are bunch of robotics examples using Simscape provided in the link below, have you thoroughly reviewed them and tried to manipulate the parameters to find out the solution you are seeking.

https://www.mathworks.com/help/sm/examples.html?category=sm-robotics&s_tid=CRUX_topnav

I studied some of them and was able to implement code snippet which demonstrates how to extract these forces in Simscape:

% Load your Simscape model
mdl = 'your_model_name'; 
load_system(mdl);
% Create KinematicsSolver object
kinSolver = simscape.multibody.KinematicsSolver(mdl);

For more information on simscape.multibody.KinematicsSolver, please refer to,

https://www.mathworks.com/help/sm/ref/simscape.multibody.kinematicssolver.html?searchHighlight=simscape.multibody.KinematicsSolver&s_tid=srchtitle_support_results_1_simscape.multibody.KinematicsSolver

% Define your rigid body (replace 'RigidBody' with your actual body 
name)
bodyName = 'your_body_name';
body = simscape.multibody.RigidBody(bodyName);

For more information regarding simscape.multibody.RigidBody, please refer to, https://www.mathworks.com/help/sm/ref/simscape.multibody.rigidbody-class.html?searchHighlight=simscape.multibody.RigidBody&s_tid=srchtitle_support_results_1_simscape.multibody.RigidBody

% Get current state information
state = getState(kinSolver);

For more information regarding getState, please refer to, https://www.mathworks.com/help/aerotbx/ug/aero.fixedwing.state.getstate.html?searchHighlight=getState&s_tid=srchtitle_support_results_1_getState

% Extract parameters
m = body.Mass; % Mass of the body
g = 9.81; % Acceleration due to gravity
% Calculate Gravitational Force
F_gravity = [0; 0; -m * g]; % Assuming downward gravity
% Calculate Centrifugal and Coriolis Forces
v = state.Velocity; % Linear velocity vector from state
omega = state.AngularVelocity; % Angular velocity vector from state
r = norm(state.Position); % Radius from axis (example)
F_centrifugal = m * (norm(v)^2 / r);
F_coriolis = 2 * m * cross(v, omega);
% Display Forces
disp('Gravitational Force:');
disp(F_gravity);
disp('Centrifugal Force:');
disp(F_centrifugal);
disp('Coriolis Force:');
disp(F_coriolis);

I would encourage you to consider the examples provided in the link above. Try to build your code in small steps, then go for solving challenging debug phases encountered in the code and the more you learn from your mistakes, the more you will learn. Hope, this helps.

Well, to be honest, my point wasn't to find speeds and positions already given by sensors and joints sensing. I find much tricky the need to perform all calculations in a script that should run separatedly. I can take my measure in simulink and provide blocks to perform all requred calacualtions directly in simulink itself. But honestly I'd just do what simscape already do internally... in my opinion a waste of time and risk of error. Would be better to have something directly from the model if possible. Besides there are many additional complexity due to the presence of multiple bodies, inertia tensors and frames connected to same branch of compound systems, would make all not ideal for an applicative use. In addition sensor provided in simscape allow to chose preferred frame for resolving componenets of forces and speeds...
Hi @Enrico,
Why not consider using Simulink blocks that directly interface with your Simscape model. This approach not only minimizes the risk of errors but also enhances the efficiency of your simulations. Like I was trying to tell you that you can utilize the built-in sensors and components to extract necessary data without manually coding each calculation. For instance, if you need to analyze forces or velocities, you can directly connect Simscape sensors to your model and configure them to output data in your preferred reference frame. This way, you can maintain clarity and reduce the overhead of managing multiple scripts and leveraging the capabilities of Simscape and Simulink together will provide solution for your robotics applications.

Sign in to comment.

Answers (1)

For Multibody modelling using the Simscape library there are currently no straightforward ways similar to the Robotics Toolbox for extracting force components such as centrifugal and Coriolis accelerative forces. In these cases, you need to write custom code in addition to using the Simscape Multibody features such as the transform sensors to measure the relative spatial relationships between two frames.
However, for measuring the force components for gravitational forces you can use the "Mechanism Configuration" block (https://www.mathworks.com/help/sm/ref/mechanismconfiguration.html) which adjusts the gravitational forces acting in an environment. As an alternative you can also use the "Gravitational Field" block (https://www.mathworks.com/help/sm/ref/gravitationalfield.html) to represent gravitational field for a point mass in the environment.
For more information regarding sensing composite forces using Simscape, refer to the following example: https://www.mathworks.com/help/sm/ug/sensing-composite-forces-and-torques-in-joints-potter-s-wheel.html
For more information regarding modelling gravity using Simscape, refer to this documentation: https://www.mathworks.com/help/sm/ug/gravity.html

2 Comments

I shall remark that what one get from Mechanism Configuration is not a measure of gravitational forces but a measure of acceleration from basis, that's not necessarily gravitational force acting, although in most cases can be used for. Anyway is not a measure (neither as virtual measure). In addition I underline the point what I'm looking for is not actually the composite force acting I can direclty measure (on joints only, so I need to add some fixed joint in case, modifying my model in a slightly unnatural way for). but I can anyway chose a suitable frame for my measure (that's very good for my puposes!).
So unfortunately your answer is, first not complete (only gravitational terms are considered), second partially satisfying. In the contrary, I agree with you that's what actual Simscape offer as meas to acheve my task, and matching robotic toolbox response with simscape could result tricky.
Hi @ENRICO, I suggested the "Mechanism Configuration" block for a measure of gravitational forces since that is a popular use case for the block, you are correct in asserting that it is not only a measure of said forces but you can use it as a measure of acceleration from basis.
The functionality you expect from Simscape is not available hence I provided you with the next best solutions I knew/could find.
If you figure out a solution, do share with us.

Sign in to comment.

Categories

Products

Release

R2023b

Asked:

on 25 Aug 2024

Commented:

on 5 Sep 2024

Community Treasure Hunt

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

Start Hunting!