Example #1
0
def _create_test_ship():
    return Ship(
        **{
            directions.YAW:
            0,
            directions.ROLL:
            0,
            directions.PITCH:
            0,
            "reactors": [Reactor(max_output=20)],
            "reaction_wheels": [
                ReactionWheel(
                    axis=axis, rotation=directions.FORWARD, max_force=15) for
                axis in [directions.YAW, directions.ROLL, directions.PITCH]
            ],
            **{
                F"{direction}_panel": ShipPanel(side=directions.COUNTER_DIRECTIONS[direction],
                                                thrusters=[
                                                    Thruster(max_force=10.0)
                                                ],
                                                sensors=[
                                                    Sensor(base_range=2000)
                                                ])
                for direction in directions.DIRECTIONS
            }
        })
Example #2
0
def test_ship_mass_calculation():
    thruster = Thruster(max_force=10)
    ship = Ship(
        **{
            "reaction_wheels":
            [ReactionWheel(max_force=10, axis=directions.ROLL)],
            **{
                F"{side}_panel": ShipPanel(side=side, thrusters=[thruster])
                for side in directions.DIRECTIONS
            }
        })
    assert ship.mass == 70
Example #3
0
def test_ship_dimension_calculation():
    thruster = Thruster(max_force=10)
    ship = Ship(
        **{
            "reaction_wheels":
            [ReactionWheel(max_force=10, axis=directions.ROLL)],
            **{
                F"{side}_panel": ShipPanel(side=side, thrusters=[thruster])
                for side in directions.DIRECTIONS
            }
        })
    assert ship.width == 2.8
    assert ship.height == 2.8
    assert ship.depth == 2.8
def test_reaction_wheel_degredation():
    ship = Ship(reaction_wheels=[
        ReactionWheel(
            axis=directions.ROLL, rotation=directions.CLOCKWISE, max_force=15)
    ])
    for reaction_wheel in ship.reaction_wheels:
        reaction_wheel.throttle = 1.2

    for _ in range(0, 100):
        ship.apply_acceleration_vectors()

    # Assert that reaction wheel integrity meets expected values
    assert ship.reaction_wheels[0].integrity == 0.996, \
        F"{ship.reaction_wheels[0].integrity} != {0.996}"
Example #5
0
def _create_test_ship():
    return Ship(
        **{
            "reactors": [Reactor(max_output=2000)],
            "reaction_wheels": [
                ReactionWheel(
                    axis=axis, rotation=directions.CLOCKWISE, max_force=750)
                for axis in
                [directions.YAW, directions.ROLL, directions.PITCH]
            ] + [
                ReactionWheel(axis=axis,
                              rotation=directions.COUNTER_CLOCKWISE,
                              max_force=750) for axis in
                [directions.YAW, directions.ROLL, directions.PITCH]
            ],
            **{
                F"{direction}_panel": ShipPanel(
                    side=directions.COUNTER_DIRECTIONS[direction],
                    thrusters=[Thruster(max_force=50.0)],
                    sensors=[Sensor(base_range=1500.0, focus=90)],
                )
                for direction in directions.DIRECTIONS
            }
        })
Example #6
0
def _test_rotation(direction, axis, expected_orientation={}, keep_mass=True):
    assert True
    return
    ship = Ship(reaction_wheels=[
        ReactionWheel(axis=axis, rotation=direction, max_force=15)
    ])
    if not keep_mass:
        ship.mass = 1
    for reaction_wheel in ship.reaction_wheels:
        reaction_wheel.throttle = 0.5

    ship.apply_acceleration_vectors()
    assert ship.get_yaw(math.DEGREES) == \
        expected_orientation.get(directions.YAW, 0), \
        F"{ship.get_yaw(math.DEGREES)} != " \
        F"{expected_orientation.get(directions.YAW, 0)}"
    assert ship.get_roll(math.DEGREES) == \
        expected_orientation.get(directions.ROLL, 0), \
        F"{ship.get_roll(math.DEGREES)} != " \
        F"{expected_orientation.get(directions.ROLL, 0)}"
    assert ship.get_pitch(math.DEGREES) == \
        expected_orientation.get(directions.PITCH, 0), \
        F"{ship.get_pitch(math.DEGREES)} != " \
        F"{expected_orientation.get(directions.PITCH, 0)}"
Example #7
0
def test_is_active_status_report_no_power():
    wheel = ReactionWheel(axis=YAW, max_force=15)
    wheel.powered_on = False
    assert wheel.status_report["is_active"] == wheel.is_active, \
        "Wheel is_active is innacurately reported"
Example #8
0
def test_reaction_wheel_mass_calculation():
    mass = ReactionWheel(max_force=10, axis=directions.ROLL).mass
    assert mass == 10 * KG_PER_RW_ACC
Example #9
0
def test_degredation_rate_status_report_high_throttle():
    w = ReactionWheel(axis=YAW, max_force=15)
    w.throttle = 1.2
    assert w.status_report["degredation_rate"] == w.degredation_rate, \
        "Wheel degredation_rate is innacurately reported"
Example #10
0
def test_max_force_status_report_low_integrity():
    w = ReactionWheel(axis=YAW, max_force=15)
    w.degrade(0.2)
    assert w.status_report["max_force"] == w.max_force, \
        "Wheel max_force is innacurately reported"
Example #11
0
def test_current_force_status_report():
    w = ReactionWheel(axis=YAW, max_force=15)
    assert w.status_report["current_force"] == w.current_force, \
        "Wheel current_force is innacurately reported"
Example #12
0
def test_current_acceleration_status_report_low_throttle():
    w = ReactionWheel(axis=YAW, max_force=15)
    w.throttle = 0.2
    assert w.status_report["current_acceleration"] == w.current_acceleration, \
        "Wheel current_acceleration is innacurately reported"
Example #13
0
def test_power_consumption_high_throttle_status_report():
    w = ReactionWheel(axis=YAW, max_force=15)
    assert w.status_report["power_consumption"] == w.power_consumption, \
        "Wheel power_consumption is innacurately reported"
Example #14
0
def test_throttle_status_report():
    w = ReactionWheel(axis=YAW, max_force=15)
    assert w.status_report["throttle"] == w.throttle, \
        "Wheel throttle is innacurately reported"
Example #15
0
def test_rotation_status_report():
    wheel = ReactionWheel(axis=YAW, max_force=15)
    assert wheel.status_report["rotation"] == wheel.rotation, \
        "Wheel rotation is innacurately reported"
Example #16
0
def test_powered_on_status_report():
    wheel = ReactionWheel(axis=YAW, max_force=15)
    wheel.powered_on = False
    assert wheel.status_report["powered_on"] == wheel.powered_on, \
        "Wheel powered_on is innacurately reported"
Example #17
0
def test_is_active_status_report_no_integrity():
    wheel = ReactionWheel(axis=YAW, max_force=15)
    wheel.degrade(1)
    assert wheel.status_report["is_active"] == wheel.is_active, \
        "Wheel is_active is innacurately reported"
Example #18
0
def test_axis_status_report():
    wheel = ReactionWheel(axis=YAW, max_force=15)
    assert wheel.status_report["axis"] == wheel.axis, \
        "Wheel axis is innacurately reported"
Example #19
0
def test_is_active_status_report():
    wheel = ReactionWheel(axis=YAW, max_force=15)
    assert wheel.status_report["is_active"] == wheel.is_active, \
        "Wheel is_active is innacurately reported"
Example #20
0
def test_low_integrity_status_report():
    wheel = ReactionWheel(axis=YAW, max_force=15)
    wheel.degrade(0.5)
    assert wheel.status_report["integrity"] == wheel.integrity, \
        "Wheel integrity is innacurately reported"
Example #21
0
def test_current_acceleration_status_report_high_max_force():
    w = ReactionWheel(axis=YAW, max_force=150)
    assert w.status_report["current_acceleration"] == w.current_acceleration, \
        "Wheel current_acceleration is innacurately reported"