Opened 14 years ago
Last modified 14 years ago
#1281 closed defect (fixed)
Function Inlining: "MultiBody: SlidingJointTest.frame_b.r unbound?"
Reported by: | asodja | Owned by: | asodja |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Instantiation | Version: | 1.6.0 |
Keywords: | Cc: | asodja, |
Description
The field {{r_0}} of connector {{Modelica.Mechanics.MultiBody.Interfaces.Frame_b}} seems to remain unbound (always 0), although the force (field {{f}} in connector) is not and also the states' values (SlidingJoint.s and SlidingJoint.v) are OK (as expected).
Consequently, blocks like Sensors.AbsolutePosition or Sensors.AbsoluteVelocity do not work.
At the instantiation of the model (in the attachment), the following warrning are diplayed (although they are probably uncorrelated with the problem):
[SlidingJointTest.mo:23188:5-23191:76:readonly] Warning: Variable Cart.r_0: Non-array modification 'if Cart.enforceStates then StateSelect.always else StateSelect.avoid' for array component, possibly due to missing 'each'. [SlidingJointTest.mo:23192:5-23195:76:readonly] Warning: Variable Cart.v_0: Non-array modification 'if Cart.enforceStates then StateSelect.always else StateSelect.avoid' for array component, possibly due to missing 'each'. [SlidingJointTest.mo:22519:5-22522:76:readonly] Warning: Variable Cart.body.r_0: Non-array modification 'if Cart.body.enforceStates then StateSelect.always else StateSelect.avoid' for array component, possibly due to missing 'each'. [SlidingJointTest.mo:22523:5-22526:76:readonly] Warning: Variable Cart.body.v_0: Non-array modification 'if Cart.body.enforceStates then StateSelect.always else StateSelect.avoid' for array component, possibly due to missing 'each'. [SlidingJointTest.mo:22601:5-22605:65:readonly] Warning: Variable Cart.body.w_a: Non-array modification 'if Cart.body.enforceStates then if Cart.body.useQuaternions then StateSelect.always else StateSelect.never else StateSelect.avoid' for array component, possibly due to missing 'each'. [SlidingJointTest.mo:22616:5-22619:119:readonly] Warning: Variable Cart.body.Q: Non-array modification 'if Cart.body.enforceStates then if Cart.body.useQuaternions then StateSelect.prefer else StateSelect.never else StateSelect.avoid' for array component, possibly due to missing 'each'. [SlidingJointTest.mo:22627:5-22630:69:readonly] Warning: Variable Cart.body.phi: Non-array modification 'if Cart.body.enforceStates then if Cart.body.useQuaternions then StateSelect.never else StateSelect.always else StateSelect.avoid' for array component, possibly due to missing 'each'. [SlidingJointTest.mo:22631:5-22633:42:readonly] Warning: Variable Cart.body.phi_d: Non-array modification 'if Cart.body.enforceStates then if Cart.body.useQuaternions then StateSelect.never else StateSelect.always else StateSelect.avoid' for array component, possibly due to missing 'each'.
In the attachment, there is a test model with all the necessary Modelica Standard Library components included.
It was translated with {{omc +s SlidingJointTest.mo}} and simulated for 10 s.
Attachments (1)
Change History (5)
by , 14 years ago
Attachment: | SlidingJointTest.zip added |
---|
comment:1 by , 14 years ago
comment:2 by , 14 years ago
Additional note: code for {{Modelica.Mechanics.MultiBody.Frames.resolve1}} is still generated in SlidingTest_functions.cpp and seems OK.
So this might be solely an inlining issue (and then removing simple equations and subsequent variables replacing).
comment:3 by , 14 years ago
The warnings are as you suspected not correlated with the problem. It's simply that the standard library doesn't use 'each' where it should, but since it's used in the standard library we allow it anyway but display a warning.
It seems that something strange happens when inlining function {{Modelica.Mechanics.MultiBody.Frames.resolve1}}.
{{SlidingJoint.frame_b.r_0}} is assigned by calling this function(a line form a flattened-model):
SlidingJoint.frame_b.r_0 = SlidingJoint.frame_a.r_0 + Modelica.Mechanics.MultiBody.Frames.resolve1(SlidingJoint.frame_a.R,{SlidingJoint.s * SlidingJoint.e[1],SlidingJoint.s * SlidingJoint.e[2],SlidingJoint.s * SlidingJoint.e[3]});
All the input arguments' values are as they should be (in the results), but the function is never called, because it is inlined.
{{SlidingJoint.frame_b.r_0[1]}} is assigned to {{absoluteVelocity.der1[1].u}} and {{absoluteVelocity.der1[1].u}} is assigned to {{Cart.body.frame_a.r_0[1]}}.
The latter gets its value in the following lines:
{{{array_alloc_scalar_real_array(&tmp1, 3, (modelica_real)$PabsolutePosition$Pr$lB1$rB, (modelica_real)$PabsolutePosition$Pr$lB2$rB, (modelica_real)$PabsolutePosition$Pr$lB3$rB);
({{Cart.body.frame_a.r_0 := absolutePosition.r}}).
{{absolutePosition.r}} is not assigned any value in the whole SlidingTest.cpp and thus retains its initial values -- 0, of course.