RelativeSensorsTest
IconRelativeSensorsTest
A test rig for sensors measuring relative translational motion between two independently forced masses.
This test component sets up a dynamic system to verify the behavior of relative motion sensors. It features two 1kg masses, body1
and body2
, initially at rest and starting from the same position. body1
is subjected to a constant force F_1 = 1\,\text{N}
and body2
is subjected to a constant force F_2 = 10\,\text{N}
. Both forces are applied with respect to a fixed inertial frame. Consequently, body1
experiences a constant acceleration math a_1 = F_1/m_1 = 1\,\text{m/s}^2
and body2
experiences a constant acceleration math a_2 = F_2/m_2 = 10\,\text{m/s}^2
. Three types of sensors measure the relative motion, defined as the motion of body2
with respect to body1
:
- Relative position:
math s_{rel}(t) = s_2(t) - s_1(t)
- Relative speed:
math v_{rel}(t) = v_2(t) - v_1(t) = \frac{d}{dt}s_{rel}(t)
- Relative acceleration:
math a_{rel}(t) = a_2(t) - a_1(t) = \frac{d}{dt}v_{rel}(t)
Usage
RelativeSensorsTest()
Behavior
\[ \begin{equation} \left[ \begin{array}{c} \mathtt{constant1.y}\left( t \right) = \mathtt{force1.f}\left( t \right) \\ \mathtt{constant2.y}\left( t \right) = \mathtt{force2.f}\left( t \right) \\ \mathrm{connect}\left( fixed_{+}flange, force1_{+}flange_{a}, force2_{+}flange_{a} \right) \\ \mathrm{connect}\left( force1_{+}flange_{b}, body1_{+}flange_{a} \right) \\ \mathrm{connect}\left( force2_{+}flange_{b}, body2_{+}flange_{a} \right) \\ \mathrm{connect}\left( body1_{+}flange_{b}, relative_{speed\_sensor_{+}flange\_a}, relative_{position\_sensor_{+}flange\_a}, relative_{acceleration\_sensor_{+}flange\_a} \right) \\ \mathrm{connect}\left( body2_{+}flange_{b}, relative_{speed\_sensor_{+}flange\_b}, relative_{position\_sensor_{+}flange\_b}, relative_{acceleration\_sensor_{+}flange\_b} \right) \\ \mathtt{body1.flange\_a.s}\left( t \right) = - \frac{1}{2} \mathtt{body1.L} + \mathtt{body1.s}\left( t \right) \\ \mathtt{body1.flange\_b.s}\left( t \right) = \frac{1}{2} \mathtt{body1.L} + \mathtt{body1.s}\left( t \right) \\ \mathtt{body1.v}\left( t \right) = \frac{\mathrm{d} \mathtt{body1.s}\left( t \right)}{\mathrm{d}t} \\ \mathtt{body1.a}\left( t \right) = \frac{\mathrm{d} \mathtt{body1.v}\left( t \right)}{\mathrm{d}t} \\ \left( \mathtt{body1.a}\left( t \right) + \mathtt{body1.g} \sin\left( \mathtt{body1.theta} \right) \right) \mathtt{body1.m} = \mathtt{body1.flange\_b.f}\left( t \right) + \mathtt{body1.flange\_a.f}\left( t \right) \\ \mathtt{body2.flange\_a.s}\left( t \right) = - \frac{1}{2} \mathtt{body2.L} + \mathtt{body2.s}\left( t \right) \\ \mathtt{body2.flange\_b.s}\left( t \right) = \frac{1}{2} \mathtt{body2.L} + \mathtt{body2.s}\left( t \right) \\ \mathtt{body2.v}\left( t \right) = \frac{\mathrm{d} \mathtt{body2.s}\left( t \right)}{\mathrm{d}t} \\ \mathtt{body2.a}\left( t \right) = \frac{\mathrm{d} \mathtt{body2.v}\left( t \right)}{\mathrm{d}t} \\ \left( \mathtt{body2.a}\left( t \right) + \mathtt{body2.g} \sin\left( \mathtt{body2.theta} \right) \right) \mathtt{body2.m} = \mathtt{body2.flange\_a.f}\left( t \right) + \mathtt{body2.flange\_b.f}\left( t \right) \\ \mathtt{force1.flange\_a.f}\left( t \right) = \mathtt{force1.f}\left( t \right) \\ \mathtt{force1.flange\_b.f}\left( t \right) = - \mathtt{force1.f}\left( t \right) \\ \mathtt{force2.flange\_a.f}\left( t \right) = \mathtt{force2.f}\left( t \right) \\ \mathtt{force2.flange\_b.f}\left( t \right) = - \mathtt{force2.f}\left( t \right) \\ \mathtt{fixed.flange.s}\left( t \right) = \mathtt{fixed.s0} \\ \mathtt{constant1.y}\left( t \right) = \mathtt{constant1.k} \\ \mathtt{constant2.y}\left( t \right) = \mathtt{constant2.k} \\ 0 = \mathtt{relative\_speed\_sensor.flange\_a.f}\left( t \right) + \mathtt{relative\_speed\_sensor.flange\_b.f}\left( t \right) \\ \mathtt{relative\_speed\_sensor.s\_rel}\left( t \right) = \mathtt{relative\_speed\_sensor.flange\_b.s}\left( t \right) - \mathtt{relative\_speed\_sensor.flange\_a.s}\left( t \right) \\ \mathtt{relative\_speed\_sensor.v\_rel}\left( t \right) = \frac{\mathrm{d} \mathtt{relative\_speed\_sensor.s\_rel}\left( t \right)}{\mathrm{d}t} \\ 0 = \mathtt{relative\_speed\_sensor.flange\_a.f}\left( t \right) \\ 0 = \mathtt{relative\_position\_sensor.flange\_b.f}\left( t \right) + \mathtt{relative\_position\_sensor.flange\_a.f}\left( t \right) \\ \mathtt{relative\_position\_sensor.s\_rel}\left( t \right) = \mathtt{relative\_position\_sensor.flange\_b.s}\left( t \right) - \mathtt{relative\_position\_sensor.flange\_a.s}\left( t \right) \\ 0 = \mathtt{relative\_position\_sensor.flange\_a.f}\left( t \right) \\ 0 = \mathtt{relative\_acceleration\_sensor.flange\_b.f}\left( t \right) + \mathtt{relative\_acceleration\_sensor.flange\_a.f}\left( t \right) \\ \mathtt{relative\_acceleration\_sensor.s\_rel}\left( t \right) = \mathtt{relative\_acceleration\_sensor.flange\_b.s}\left( t \right) - \mathtt{relative\_acceleration\_sensor.flange\_a.s}\left( t \right) \\ \mathtt{relative\_acceleration\_sensor.v\_rel}\left( t \right) = \frac{\mathrm{d} \mathtt{relative\_acceleration\_sensor.s\_rel}\left( t \right)}{\mathrm{d}t} \\ \mathtt{relative\_acceleration\_sensor.a\_rel}\left( t \right) = \frac{\mathrm{d} \mathtt{relative\_acceleration\_sensor.v\_rel}\left( t \right)}{\mathrm{d}t} \\ 0 = \mathtt{relative\_acceleration\_sensor.flange\_a.f}\left( t \right) \\ \end{array} \right] \end{equation} \]
Source
# A test rig for sensors measuring relative translational motion between two independently forced masses.
#
# This test component sets up a dynamic system to verify the behavior of relative motion sensors. It features two 1kg masses, `body1` and `body2`, initially at rest and starting from the same position.
# `body1` is subjected to a constant force `F_1 = 1\,\text{N}` and `body2` is subjected to a constant force `F_2 = 10\,\text{N}`. Both forces are applied with respect to a fixed inertial frame.
# Consequently, `body1` experiences a constant acceleration ```math a_1 = F_1/m_1 = 1\,\text{m/s}^2 ``` and `body2` experiences a constant acceleration ```math a_2 = F_2/m_2 = 10\,\text{m/s}^2 ```.
# Three types of sensors measure the relative motion, defined as the motion of `body2` with respect to `body1`:
# - Relative position: ```math s_{rel}(t) = s_2(t) - s_1(t) ```
# - Relative speed: ```math v_{rel}(t) = v_2(t) - v_1(t) = \frac{d}{dt}s_{rel}(t) ```
# - Relative acceleration: ```math a_{rel}(t) = a_2(t) - a_1(t) = \frac{d}{dt}v_{rel}(t) ```
test component RelativeSensorsTest
# First translational mass (1kg) in the test setup.
body1 = Mass(m=1, L=0)
# Second translational mass (1kg) in the test setup.
body2 = Mass(m=1, L=0)
# Force source applying force to body1.
force1 = Force()
# Force source applying force to body2.
force2 = Force()
# Fixed inertial reference frame for the applied forces.
fixed = Fixed()
# Constant signal (1.0, typically Force [N]) for force1.
constant1 = BlockComponents.Constant(k=1)
# Constant signal (10.0, typically Force [N]) for force2.
constant2 = BlockComponents.Constant(k=10)
# Sensor measuring the relative speed between body1 and body2 (v_body2 - v_body1).
relative_speed_sensor = RelativeSpeedSensor()
# Sensor measuring the relative position between body1 and body2 (s_body2 - s_body1).
relative_position_sensor = RelativePositionSensor()
# Sensor measuring the relative acceleration between body1 and body2 (a_body2 - a_body1).
relative_acceleration_sensor = RelativeAccelerationSensor()
relations
connect(constant1.y, force1.f)
connect(constant2.y, force2.f)
connect(fixed.flange, force1.flange_a, force2.flange_a)
connect(force1.flange_b, body1.flange_a)
connect(force2.flange_b, body2.flange_a)
connect(body1.flange_b, relative_speed_sensor.flange_a, relative_position_sensor.flange_a, relative_acceleration_sensor.flange_a)
connect(body2.flange_b, relative_speed_sensor.flange_b, relative_position_sensor.flange_b, relative_acceleration_sensor.flange_b)
metadata {
"Dyad": {
"tests": {
"case1": {
"stop": 5,
"initial": {"body1.s": 0, "body2.s": 0},
"expect": {
"final": {
"relative_position_sensor.s_rel": 112.5,
"relative_speed_sensor.v_rel": 44.99999999,
"relative_acceleration_sensor.a_rel": 9
}
}
}
}
}
}
end
Flattened Source
# A test rig for sensors measuring relative translational motion between two independently forced masses.
#
# This test component sets up a dynamic system to verify the behavior of relative motion sensors. It features two 1kg masses, `body1` and `body2`, initially at rest and starting from the same position.
# `body1` is subjected to a constant force `F_1 = 1\,\text{N}` and `body2` is subjected to a constant force `F_2 = 10\,\text{N}`. Both forces are applied with respect to a fixed inertial frame.
# Consequently, `body1` experiences a constant acceleration ```math a_1 = F_1/m_1 = 1\,\text{m/s}^2 ``` and `body2` experiences a constant acceleration ```math a_2 = F_2/m_2 = 10\,\text{m/s}^2 ```.
# Three types of sensors measure the relative motion, defined as the motion of `body2` with respect to `body1`:
# - Relative position: ```math s_{rel}(t) = s_2(t) - s_1(t) ```
# - Relative speed: ```math v_{rel}(t) = v_2(t) - v_1(t) = \frac{d}{dt}s_{rel}(t) ```
# - Relative acceleration: ```math a_{rel}(t) = a_2(t) - a_1(t) = \frac{d}{dt}v_{rel}(t) ```
test component RelativeSensorsTest
# First translational mass (1kg) in the test setup.
body1 = Mass(m=1, L=0)
# Second translational mass (1kg) in the test setup.
body2 = Mass(m=1, L=0)
# Force source applying force to body1.
force1 = Force()
# Force source applying force to body2.
force2 = Force()
# Fixed inertial reference frame for the applied forces.
fixed = Fixed()
# Constant signal (1.0, typically Force [N]) for force1.
constant1 = BlockComponents.Constant(k=1)
# Constant signal (10.0, typically Force [N]) for force2.
constant2 = BlockComponents.Constant(k=10)
# Sensor measuring the relative speed between body1 and body2 (v_body2 - v_body1).
relative_speed_sensor = RelativeSpeedSensor()
# Sensor measuring the relative position between body1 and body2 (s_body2 - s_body1).
relative_position_sensor = RelativePositionSensor()
# Sensor measuring the relative acceleration between body1 and body2 (a_body2 - a_body1).
relative_acceleration_sensor = RelativeAccelerationSensor()
relations
connect(constant1.y, force1.f)
connect(constant2.y, force2.f)
connect(fixed.flange, force1.flange_a, force2.flange_a)
connect(force1.flange_b, body1.flange_a)
connect(force2.flange_b, body2.flange_a)
connect(body1.flange_b, relative_speed_sensor.flange_a, relative_position_sensor.flange_a, relative_acceleration_sensor.flange_a)
connect(body2.flange_b, relative_speed_sensor.flange_b, relative_position_sensor.flange_b, relative_acceleration_sensor.flange_b)
metadata {
"Dyad": {
"tests": {
"case1": {
"stop": 5,
"initial": {"body1.s": 0, "body2.s": 0},
"expect": {
"final": {
"relative_position_sensor.s_rel": 112.5,
"relative_speed_sensor.v_rel": 44.99999999,
"relative_acceleration_sensor.a_rel": 9
}
}
}
}
}
}
end
Test Cases
Test Case case1
Related
- Examples
- Experiments
- Analyses
- Tests