@@ -7,18 +7,20 @@ using OrdinaryDiffEq
77using LinearAlgebra
88using JuliaSimCompiler
99
10- t = Multibody. t
11- D = Differential (t)
1210world = Multibody. world
1311W (args... ; kwargs... ) = Multibody. world
12+ t = Multibody. t
13+ D = Differential (t)
1414
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+ # ==============================================================================
1618@mtkmodel TestUSR begin
1719 @components begin
1820 world = W ()
1921 j1 = JointUSR (positive_branch= true , use_arrays= false )
2022 fixed = FixedTranslation (r= [1 ,0 ,0 ])
21- b1 = Body (m= 1 , isroot = false , neg_w = true )
23+ b1 = Body (m= 1 )
2224 p1 = Prismatic (state_priority= 100 , n = [1 , 0 , 0 ])
2325 end
2426 @equations begin
@@ -40,48 +42,33 @@ sol = solve(prob, FBDF(autodiff=true))
4042@test sol (1.0 , idxs= model. p1. s) ≈ - 2.8 rtol= 0.01 # test vs. OpenModelica
4143
4244
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())
7045
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
7164
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+ # #
8170
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
8774
0 commit comments