|
65 | 65 | m = 1 |
66 | 66 | j = 0.1 |
67 | 67 | ω = 10 |
| 68 | + resolve_in_frame = :world |
68 | 69 |
|
69 | 70 | # components |
70 | 71 | @named body = Body(; m, j, gy = 0.0) |
|
73 | 74 | @named revolute = Revolute(constant_ω = ω) |
74 | 75 |
|
75 | 76 | # sensors |
76 | | - @named abs_pos_sensor = AbsolutePosition() |
| 77 | + @named abs_v_sensor = AbsoluteVelocity(; resolve_in_frame) |
77 | 78 |
|
78 | 79 | eqs = [ |
79 | 80 | connect(fixed.frame, revolute.frame_a), |
80 | 81 | connect(revolute.frame_b, fixed_translation.frame_a), |
81 | 82 | connect(fixed_translation.frame_b, body.frame), |
82 | | - connect_sensor(abs_pos_sensor.frame_a, body.frame)..., |
| 83 | + connect_sensor(body.frame, abs_v_sensor.frame_a)..., |
83 | 84 | ] |
84 | 85 |
|
85 | 86 | @named model = ODESystem(eqs, |
|
91 | 92 | fixed_translation, |
92 | 93 | fixed, |
93 | 94 | revolute, |
94 | | - abs_pos_sensor, |
| 95 | + abs_v_sensor, |
95 | 96 | ]) |
96 | 97 | sys = structural_simplify(model) |
97 | 98 | u0 = [0.0, ω, 0.0] |
|
103 | 104 | @test all(sol[body.ω] .≈ ω) |
104 | 105 |
|
105 | 106 | test_points = [i / ω for i in 0:0.1:10] |
| 107 | + |
106 | 108 | # instantaneous linear velocity |
107 | 109 | v_singal(t) = -ω^2 * sin.(ω .* t) |
108 | | - @test all(v_singal.(test_points) .≈ sol.(test_points; idxs = body.vx)) |
| 110 | + @test all(v_singal.(test_points) .≈ sol.(test_points; idxs = abs_v_sensor.v_x.u)) |
109 | 111 |
|
110 | 112 | # instantaneous linear acceleration |
111 | 113 | a_singal(t) = -ω^3 * cos.(ω .* t) |
|
0 commit comments