Main Content

simscape.multibody.ExternalForceTorqueDictionary Class

Namespace: simscape.multibody

Dictionary that stores external forces and torques

Since R2025a

Description

Use an object of the simscape.multibody.ExternalForceTorqueDictionary class to store external forces and torques to apply to a compiled multibody model. This object functions like a dictionary in that you can store the forces and torques and their corresponding frame connectors as key-value pairs. The keys are the paths to the frame connectors, appended with the letter f for force or t for torque, respectively. To construct external forces and torques, use these classes:

Class Attributes

Sealed
true
ConstructOnLoad
true
RestrictsSubclassing
true

For information on class attributes, see Class Attributes.

Creation

Description

dict = simscape.multibody.ExternalForceTorqueDictionary creates an external force and torque dictionary.

You can use dict(keys) = Values to pair an external force or torque with the path of corresponding frame connector as the key-value pair. If you assign multiple values to the same key, the last value you assign overwrites the previous values of the key.

Examples

collapse all

  1. Create an external force and torque dictionary.

    dict = simscape.multibody.ExternalForceTorqueDictionary
    
    dict = 
    
      ExternalForceTorqueDictionary with no external forces or torques.
  2. Construct a force and a torque for the frame connectors. Create a force of 5 N resolved along the x-axis of the world frame, and a torque of [2 1 0] N*m resolved about the world frame.

    force = simscape.multibody.ExternalForce(...
                         simscape.Value([5 0 0],"N"),"World");
    torque = simscape.multibody.ExternalTorque(...
                         simscape.Value([2 1 0],"N*m"),"World");
    
  3. Use the dict dictionary to store the force and torque for the frame connectors as key-value pairs. The keys are the paths of the joint primitive appended with the letters f or t.

    dict("Bottom_arm/Tip/f") = force;
    dict("Base_arm/Base/t") = torque
    
    dict = 
    
      ExternalForceTorqueDictionary with external forces and torques:
    
      ExternalForce:
    
      Frame Path          Value    Unit
      __________________  _______  ____
    
      "Bottom_arm/Tip/f"  [5 0 0]  N   
    
      ExternalTorque:
    
      Frame Path         Value    Unit
      _________________  _______  ____
    
      "Base_arm/Base/t"  [2 1 0]  N*m 

    You can change the applied force and torque. For example, to replace the torque applied on Base_arm with a new torque, enter:

    torque_new = simscape.multibody.ExternalTorque(...
                         simscape.Value([5 0 0],"N*m"),"Attached");
    
    dict("Base_arm/Base/t") = torque_new
    
    dict = 
    
      ExternalForceTorqueDictionary with external forces and torques:
    
      ExternalForce:
    
      Frame Path          Value    Unit
      __________________  _______  ____
    
      "Bottom_arm/Tip/f"  [5 0 0]  N   
    
      ExternalTorque:
    
      Frame Path         Value    Unit
      _________________  _______  ____
    
      "Base_arm/Base/t"  [5 0 0]  N*m 

Version History

Introduced in R2025a