SensorsTest
IconSensorsTest
Tests for Position, Speed and Acceleration Absolute Sensors
Usage
SensorsTest()
Behavior
\[ \begin{equation} \left[ \begin{array}{c} \mathrm{connect}\left( constant1_{+}y(t), force_{+}f(t) \right) \\ \mathrm{connect}\left( force_{+}flange_{b}, body_{+}flange_{a} \right) \\ \mathrm{connect}\left( force_{+}flange_{a}, ground_{+}flange \right) \\ \mathrm{connect}\left( body_{+}flange_{b}, speed_{sensor_{+}flange}, position_{sensor_{+}flange}, acceleration_{sensor_{+}flange} \right) \\ \mathtt{body.flange\_a.s}\left( t \right) = - \frac{1}{2} \mathtt{body.L} + \mathtt{body.s}\left( t \right) \\ \mathtt{body.flange\_b.s}\left( t \right) = \frac{1}{2} \mathtt{body.L} + \mathtt{body.s}\left( t \right) \\ \mathtt{body.v}\left( t \right) = \frac{\mathrm{d} \mathtt{body.s}\left( t \right)}{\mathrm{d}t} \\ \mathtt{body.a}\left( t \right) = \frac{\mathrm{d} \mathtt{body.v}\left( t \right)}{\mathrm{d}t} \\ \left( \mathtt{body.a}\left( t \right) + \mathtt{body.g} \sin\left( \mathtt{body.theta} \right) \right) \mathtt{body.m} = \mathtt{body.flange\_b.f}\left( t \right) + \mathtt{body.flange\_a.f}\left( t \right) \\ \mathtt{force.flange\_a.f}\left( t \right) = \mathtt{force.f}\left( t \right) \\ \mathtt{force.flange\_b.f}\left( t \right) = - \mathtt{force.f}\left( t \right) \\ \mathtt{constant1.y}\left( t \right) = \mathtt{constant1.k} \\ \mathtt{ground.flange.s}\left( t \right) = \mathtt{ground.s0} \\ 0 = \mathtt{speed\_sensor.flange.f}\left( t \right) \\ \mathtt{speed\_sensor.v}\left( t \right) = \frac{\mathrm{d} \mathtt{speed\_sensor.flange.s}\left( t \right)}{\mathrm{d}t} \\ 0 = \mathtt{position\_sensor.flange.f}\left( t \right) \\ \mathtt{position\_sensor.flange.s}\left( t \right) = \mathtt{position\_sensor.s}\left( t \right) \\ 0 = \mathtt{acceleration\_sensor.flange.f}\left( t \right) \\ \mathtt{acceleration\_sensor.v}\left( t \right) = \frac{\mathrm{d} \mathtt{acceleration\_sensor.flange.s}\left( t \right)}{\mathrm{d}t} \\ \mathtt{acceleration\_sensor.a}\left( t \right) = \frac{\mathrm{d} \mathtt{acceleration\_sensor.v}\left( t \right)}{\mathrm{d}t} \\ \end{array} \right] \end{equation} \]
Source
# Tests for Position, Speed and Acceleration Absolute Sensors
test component SensorsTest
body = Mass(m=1, L=0)
force = Force()
constant1 = BlockComponents.Constant(k=1)
ground = Fixed()
speed_sensor = SpeedSensor()
position_sensor = PositionSensor()
acceleration_sensor = AccelerationSensor()
relations
connect(constant1.y, force.f)
connect(force.flange_b, body.flange_a)
connect(force.flange_a, ground.flange)
connect(body.flange_b, speed_sensor.flange, position_sensor.flange, acceleration_sensor.flange)
metadata {
"JuliaSim": {
"tests": {
"case1": {
"stop": 5,
"initial": {"body.s": 0},
"expect": {
"final": {
"body.s": 12.49999999,
"body.v": 4.99999999,
"body.a": 1,
"position_sensor.s": 12.49999999,
"speed_sensor.v": 4.99999999,
"acceleration_sensor.a": 1
}
}
}
}
}
}
end
Flattened Source
# Tests for Position, Speed and Acceleration Absolute Sensors test component SensorsTest body = Mass(m=1, L=0) force = Force() constant1 = BlockComponents.Constant(k=1) ground = Fixed() speed_sensor = SpeedSensor() position_sensor = PositionSensor() acceleration_sensor = AccelerationSensor() relations connect(constant1.y, force.f) connect(force.flange_b, body.flange_a) connect(force.flange_a, ground.flange) connect(body.flange_b, speed_sensor.flange, position_sensor.flange, acceleration_sensor.flange) metadata { "JuliaSim": { "tests": { "case1": { "stop": 5, "initial": {"body.s": 0}, "expect": { "final": { "body.s": 12.49999999, "body.v": 4.99999999, "body.a": 1, "position_sensor.s": 12.49999999, "speed_sensor.v": 4.99999999, "acceleration_sensor.a": 1 } } } } } } end
Test Cases
Test Case case1
Related
- Examples
- Experiments
- Analyses
- Tests