@@ -100,11 +100,13 @@ If `axisflange`, flange connectors for ModelicaStandardLibrary.Mechanics.Transla
100
100
The function returns an ODESystem representing the prismatic joint.
101
101
"""
102
102
@component function Prismatic (; name, n = Float64[0 , 0 , 1 ], axisflange = false ,
103
- isroot = true , iscut = false , s0 = 0 , v0 = 0 , radius = 0.05 , color = [0 ,0.8 ,1 ,1 ])
104
- norm (n) ≈ 1 || error (" Axis of motion must be a unit vector" )
103
+ s0 = 0 , v0 = 0 , radius = 0.05 , color = [0 ,0.8 ,1 ,1 ], state_priority= 10 , iscut= false )
104
+ if ! (eltype (n) <: Num )
105
+ norm (n) ≈ 1 || error (" Prismatic axis of motion must be a unit vector, got norm(n) = $(norm (n)) " )
106
+ end
105
107
@named frame_a = Frame ()
106
108
@named frame_b = Frame ()
107
- @parameters n[1 : 3 ]= n [description = " axis of motion" ]
109
+ @parameters n[1 : 3 ]= _normalize (n) [description = " axis of motion" ]
108
110
n = collect (n)
109
111
110
112
pars = @parameters begin
@@ -113,15 +115,15 @@ The function returns an ODESystem representing the prismatic joint.
113
115
end
114
116
115
117
@variables s (t)= s0 [
116
- state_priority = 10 ,
118
+ state_priority = state_priority ,
117
119
description = " Relative distance between frame_a and frame_b" ,
118
120
]
119
121
@variables v (t)= v0 [
120
- state_priority = 10 ,
122
+ state_priority = state_priority ,
121
123
description = " Relative velocity between frame_a and frame_b" ,
122
124
]
123
125
@variables a (t)= 0 [
124
- state_priority = 10 ,
126
+ state_priority = state_priority ,
125
127
description = " Relative acceleration between frame_a and frame_b" ,
126
128
]
127
129
@variables f (t)= 0 [
849
851
850
852
LinearAlgebra. normalize (a:: Vector{Num} ) = a / norm (a)
851
853
854
+
855
+ """
856
+ Planar(; n = [0,0,1], n_x = [1,0,0], cylinderlength = 0.1, cylinderdiameter = 0.05, cylindercolor = [1, 0, 1, 1], boxwidth = 0.3*cylinderdiameter, boxheight = boxwidth, boxcolor = [0, 0, 1, 1])
857
+
858
+ Joint where frame_b can move in a plane and can rotate around an
859
+ axis orthogonal to the plane. The plane is defined by
860
+ vector `n` which is perpendicular to the plane and by vector `n_x`,
861
+ which points in the direction of the x-axis of the plane.
862
+ frame_a and frame_b coincide when s_x=prismatic_x.s=0,
863
+ s_y=prismatic_y.s=0 and phi=revolute.phi=0.
864
+ """
865
+ @mtkmodel Planar begin
866
+ @structural_parameters begin
867
+ state_priority = 1 # , [description = "Priority used to choose whether the joint state variables are selected"]
868
+ n
869
+ n_x
870
+ end
871
+ begin
872
+ cylindercolor = [1 , 0 , 1 , 1 ]
873
+ boxcolor = [0 , 0 , 1 , 1 ]
874
+ radius = 0.05
875
+ end
876
+ @parameters begin
877
+ # (n[1:3]), [description = "Axis orthogonal to unconstrained plane, resolved in frame_a (= same as in frame_b)"]
878
+ # (n_x[1:3]), [description = "Vector in direction of x-axis of plane, resolved in frame_a (n_x shall be orthogonal to n)"]
879
+ cylinderlength = 0.1 , [description = " Length of revolute cylinder" ]
880
+ cylinderdiameter = 0.05 , [description = " Diameter of revolute cylinder" ]
881
+ # cylindercolor[1:4] = cylindercolordefault, [description = "Color of revolute cylinder"] # Endless bugs with array parameters
882
+ boxwidth = 0.3 * cylinderdiameter, [description = " Width of prismatic joint boxes" ]
883
+ boxheight = boxwidth, [description = " Height of prismatic joint boxes" ]
884
+ # boxcolor[1:4] = boxcolordefault, [description = "Color of prismatic joint boxes"]
885
+ end
886
+ begin
887
+ n = collect (n)
888
+ n_x = collect (n_x)
889
+ end
890
+ # @defaults begin
891
+ # n .=> [0, 0, 1]
892
+ # n_x .=> [1, 0, 0]
893
+ # cylindercolor .=> [1, 0, 1, 1]
894
+ # boxcolor .=> [0, 0, 1, 1]
895
+ # end
896
+
897
+ @components begin
898
+ frame_a = Frame ()
899
+ frame_b = Frame ()
900
+ prismatic_x = Prismatic (; state_priority= 2.1 , n= cross (cross (n, n_x), n), color= boxcolor)
901
+ prismatic_y = Prismatic (; state_priority= 2.1 , n= cross (n, n_x), color= boxcolor)
902
+ revolute = Revolute (; state_priority= 2.1 , n, isroot= false , color= cylindercolor, radius)
903
+ end
904
+ @variables begin
905
+ (s_x (t) = 0 ), [state_priority = 3.0 , description = " Relative distance along first prismatic joint starting at frame_a" ]
906
+ (s_y (t) = 0 ), [state_priority = 3.0 , description = " Relative distance along second prismatic joint starting at first prismatic joint" ]
907
+ (phi (t) = 0 ), [state_priority = 3.0 , description = " Relative rotation angle from frame_a to frame_b" ]
908
+ (v_x (t) = 0 ), [state_priority = 3.0 , description = " Relative velocity along first prismatic joint" ]
909
+ (v_y (t) = 0 ), [state_priority = 3.0 , description = " Relative velocity along second prismatic joint" ]
910
+ (w (t) = 0 ), [state_priority = 3.0 , description = " Relative angular velocity around revolute joint" ]
911
+ (a_x (t) = 0 ), [description = " Relative acceleration along first prismatic joint" ]
912
+ (a_y (t) = 0 ), [description = " Relative acceleration along second prismatic joint" ]
913
+ (wd (t) = 0 ), [description = " Relative angular acceleration around revolute joint" ]
914
+ end
915
+ @equations begin
916
+ s_x ~ prismatic_x. s
917
+ s_y ~ prismatic_y. s
918
+ phi ~ revolute. phi
919
+ v_x ~ D (s_x)
920
+ v_y ~ D (s_y)
921
+ w ~ D (phi)
922
+ a_x ~ D (v_x)
923
+ a_y ~ D (v_y)
924
+ wd ~ D (w)
925
+ connect (frame_a, prismatic_x. frame_a)
926
+ connect (prismatic_x. frame_b, prismatic_y. frame_a)
927
+ connect (prismatic_y. frame_b, revolute. frame_a)
928
+ connect (revolute. frame_b, frame_b)
929
+ end
930
+ end
931
+
0 commit comments