@@ -7,18 +7,20 @@ using OrdinaryDiffEq
7
7
using LinearAlgebra
8
8
using JuliaSimCompiler
9
9
10
- t = Multibody. t
11
- D = Differential (t)
12
10
world = Multibody. world
13
11
W (args... ; kwargs... ) = Multibody. world
12
+ t = Multibody. t
13
+ D = Differential (t)
14
14
15
- # A JointUSR is connected to a prismatic joint, with a Body at their common tip
15
+ # ==============================================================================
16
+ # # A JointUSR is connected to a prismatic joint, with a Body at their common tip
17
+ # ==============================================================================
16
18
@mtkmodel TestUSR begin
17
19
@components begin
18
20
world = W ()
19
21
j1 = JointUSR (positive_branch= true , use_arrays= false )
20
22
fixed = FixedTranslation (r= [1 ,0 ,0 ])
21
- b1 = Body (m= 1 , isroot = false , neg_w = true )
23
+ b1 = Body (m= 1 )
22
24
p1 = Prismatic (state_priority= 100 , n = [1 , 0 , 0 ])
23
25
end
24
26
@equations begin
@@ -40,48 +42,33 @@ sol = solve(prob, FBDF(autodiff=true))
40
42
@test sol (1.0 , idxs= model. p1. s) ≈ - 2.8 rtol= 0.01 # test vs. OpenModelica
41
43
42
44
43
- # NOTE: I was working on trying to register the compute_angle function so that there are no symbolic arguments left in the generated code
44
-
45
- # foo(x::AbstractArray, p::AbstractArray) = sum(-p .* x .^ 2)
46
- # @register_symbolic foo(x::AbstractArray, p::AbstractArray)
47
- # onetwo = [1, 2]
48
-
49
- # @mtkmodel ArrayX begin
50
- # @variables begin
51
- # x(t)[1:2] = ones(2)
52
- # end
53
- # @parameters begin
54
- # p[1:2] = onetwo
55
- # end
56
- # begin
57
- # x = collect(x)
58
- # end
59
- # @equations begin
60
- # D(x[1]) ~ foo(x, p)
61
- # D(x[2]) ~ foo(x, p)
62
- # end
63
- # end
64
-
65
- # @named model = ArrayX()
66
- # model = complete(model)
67
- # ssys = structural_simplify(IRSystem(model))
68
- # prob = ODEProblem(ssys, [], (0.0, 1.0))
69
- # sol = solve(prob, FBDF())
70
45
46
+ # ==============================================================================
47
+ # # A JointRRR is connected to a prismatic joint, with a Body at their common tip
48
+ # ==============================================================================
49
+ @mtkmodel TestRRR begin
50
+ @components begin
51
+ world = W ()
52
+ j1 = JointRRR (positive_branch= true )
53
+ fixed = FixedTranslation (r= [1 ,0 ,0 ])
54
+ b1 = Body (m= 1 )
55
+ p1 = Prismatic (state_priority= 100 , n = [1 , 0 , 0 ])
56
+ end
57
+ @equations begin
58
+ connect (world. frame_b, j1. frame_a, fixed. frame_a)
59
+ connect (fixed. frame_b, p1. frame_a)
60
+ connect (p1. frame_b, j1. frame_b)
61
+ connect (j1. frame_im, b1. frame_a)
62
+ end
63
+ end
71
64
72
- # @variables begin
73
- # x(t)[1:2] = 1
74
- # end
75
- # @parameters begin
76
- # p[1:2] = onetwo
77
- # end
78
- # begin
79
- # x = collect(x)
80
- # end
65
+ @named model = TestRRR ()
66
+ model = complete (model)
67
+ ssys = structural_simplify (IRSystem (model))
68
+ @test length (unknowns (ssys)) == 2
69
+ # #
81
70
82
- # foo(x, p)
83
- # # @equations begin
84
- # # D(x[1]) ~ foo(x, p)[1]
85
- # # D(x[2]) ~ foo(x, p)[2]
86
- # # end
71
+ prob = ODEProblem (ssys, [model. p1. v => 0.0 ], (0.0 , 1.4 ))
72
+ sol = solve (prob, FBDF (autodiff= true ))
73
+ @test sol (1.0 , idxs= model. p1. s) ≈ - 2.8 rtol= 0.01 # test vs. OpenModelica
87
74
0 commit comments