Skip to content

Commit 7eab61d

Browse files
CopilotaZira371
andcommitted
Remove unnecessary try/except blocks - PointMass classes are available in codebase
Co-authored-by: aZira371 <99824864+aZira371@users.noreply.github.com>
1 parent c6cbc90 commit 7eab61d

File tree

2 files changed

+98
-127
lines changed

2 files changed

+98
-127
lines changed

tests/acceptance/test_3dof_flight.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,13 @@
1212
The tests use realistic rocket configurations and scenarios to ensure the
1313
robustness of the 3 DOF implementation.
1414
15-
Note: These tests are designed for the 3 DOF feature implemented in issue #882.
16-
They will be skipped until PointMassMotor and PointMassRocket are available.
1715
All fixtures are defined in tests/fixtures/flight/flight_fixtures.py.
1816
"""
1917

2018
import numpy as np
21-
import pytest
2219

2320
from rocketpy import Flight
2421

25-
# Try to import 3DOF-specific classes, skip tests if not available
26-
try:
27-
from rocketpy.motors.point_mass_motor import PointMassMotor
28-
from rocketpy.rocket.point_mass_rocket import PointMassRocket
29-
30-
THREEDOF_AVAILABLE = True
31-
except ImportError:
32-
THREEDOF_AVAILABLE = False
33-
34-
# Skip all tests in this module if 3DOF is not available
35-
pytestmark = pytest.mark.skipif(
36-
not THREEDOF_AVAILABLE,
37-
reason="3 DOF feature (PointMassMotor, PointMassRocket) not yet available. "
38-
"These tests will be enabled when issue #882 is merged.",
39-
)
40-
4122

4223
def test_3dof_flight_basic_trajectory(flight_3dof_no_weathercock):
4324
"""Test that 3 DOF flight produces reasonable trajectory.

tests/fixtures/flight/flight_fixtures.py

Lines changed: 98 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import pytest
33

44
from rocketpy import Flight, Function, Rocket
5+
from rocketpy.motors.point_mass_motor import PointMassMotor
6+
from rocketpy.rocket.point_mass_rocket import PointMassRocket
57

68

79
@pytest.fixture
@@ -365,111 +367,99 @@ def flight_flat(example_plain_env, cesaroni_m1670):
365367

366368
# 3 DOF Flight Fixtures
367369
# These fixtures are for testing the 3 DOF flight simulation mode
368-
# They will be available when PointMassMotor and PointMassRocket are implemented
369-
370-
try:
371-
from rocketpy.motors.point_mass_motor import PointMassMotor
372-
from rocketpy.rocket.point_mass_rocket import PointMassRocket
373-
374-
THREEDOF_AVAILABLE = True
375-
except ImportError:
376-
THREEDOF_AVAILABLE = False
377-
PointMassMotor = None
378-
PointMassRocket = None
379-
380-
381-
if THREEDOF_AVAILABLE:
382-
383-
@pytest.fixture
384-
def acceptance_point_mass_motor():
385-
"""Create a realistic point mass motor for acceptance testing.
386-
387-
Returns
388-
-------
389-
rocketpy.PointMassMotor
390-
A point mass motor with realistic thrust and mass properties.
391-
"""
392-
return PointMassMotor(
393-
thrust_source=1500, # 1500 N constant thrust
394-
dry_mass=2.5, # 2.5 kg dry mass
395-
propellant_initial_mass=3.0, # 3.0 kg propellant
396-
burn_time=3.5, # 3.5 s burn time
397-
)
398-
399-
@pytest.fixture
400-
def acceptance_point_mass_rocket(acceptance_point_mass_motor):
401-
"""Create a realistic point mass rocket for acceptance testing.
402-
403-
Parameters
404-
----------
405-
acceptance_point_mass_motor : rocketpy.PointMassMotor
406-
The motor to be added to the rocket.
407-
408-
Returns
409-
-------
410-
rocketpy.PointMassRocket
411-
A point mass rocket with realistic dimensions and properties.
412-
"""
413-
rocket = PointMassRocket(
414-
radius=0.0635, # 127 mm diameter (5 inches)
415-
mass=5.0, # 5 kg without motor
416-
center_of_mass_without_motor=0.5,
417-
power_off_drag=0.45,
418-
power_on_drag=0.50,
419-
)
420-
rocket.add_motor(acceptance_point_mass_motor, position=0)
421-
return rocket
422-
423-
@pytest.fixture
424-
def flight_3dof_no_weathercock(example_spaceport_env, acceptance_point_mass_rocket):
425-
"""Create a 3 DOF flight without weathercocking.
426-
427-
Parameters
428-
----------
429-
example_spaceport_env : rocketpy.Environment
430-
Environment fixture for Spaceport America.
431-
acceptance_point_mass_rocket : rocketpy.PointMassRocket
432-
Point mass rocket fixture.
433-
434-
Returns
435-
-------
436-
rocketpy.Flight
437-
A 3 DOF flight simulation with weathercock_coeff=0.0.
438-
"""
439-
return Flight(
440-
rocket=acceptance_point_mass_rocket,
441-
environment=example_spaceport_env,
442-
rail_length=5.0,
443-
inclination=85, # 85 degrees from horizontal (5 degrees from vertical)
444-
heading=0,
445-
simulation_mode="3 DOF",
446-
weathercock_coeff=0.0,
447-
)
448-
449-
@pytest.fixture
450-
def flight_3dof_with_weathercock(
451-
example_spaceport_env, acceptance_point_mass_rocket
452-
):
453-
"""Create a 3 DOF flight with weathercocking enabled.
454-
455-
Parameters
456-
----------
457-
example_spaceport_env : rocketpy.Environment
458-
Environment fixture for Spaceport America.
459-
acceptance_point_mass_rocket : rocketpy.PointMassRocket
460-
Point mass rocket fixture.
461-
462-
Returns
463-
-------
464-
rocketpy.Flight
465-
A 3 DOF flight simulation with weathercock_coeff=1.0.
466-
"""
467-
return Flight(
468-
rocket=acceptance_point_mass_rocket,
469-
environment=example_spaceport_env,
470-
rail_length=5.0,
471-
inclination=85,
472-
heading=0,
473-
simulation_mode="3 DOF",
474-
weathercock_coeff=1.0,
475-
)
370+
371+
372+
@pytest.fixture
373+
def acceptance_point_mass_motor():
374+
"""Create a realistic point mass motor for acceptance testing.
375+
376+
Returns
377+
-------
378+
rocketpy.PointMassMotor
379+
A point mass motor with realistic thrust and mass properties.
380+
"""
381+
return PointMassMotor(
382+
thrust_source=1500, # 1500 N constant thrust
383+
dry_mass=2.5, # 2.5 kg dry mass
384+
propellant_initial_mass=3.0, # 3.0 kg propellant
385+
burn_time=3.5, # 3.5 s burn time
386+
)
387+
388+
389+
@pytest.fixture
390+
def acceptance_point_mass_rocket(acceptance_point_mass_motor):
391+
"""Create a realistic point mass rocket for acceptance testing.
392+
393+
Parameters
394+
----------
395+
acceptance_point_mass_motor : rocketpy.PointMassMotor
396+
The motor to be added to the rocket.
397+
398+
Returns
399+
-------
400+
rocketpy.PointMassRocket
401+
A point mass rocket with realistic dimensions and properties.
402+
"""
403+
rocket = PointMassRocket(
404+
radius=0.0635, # 127 mm diameter (5 inches)
405+
mass=5.0, # 5 kg without motor
406+
center_of_mass_without_motor=0.5,
407+
power_off_drag=0.45,
408+
power_on_drag=0.50,
409+
)
410+
rocket.add_motor(acceptance_point_mass_motor, position=0)
411+
return rocket
412+
413+
414+
@pytest.fixture
415+
def flight_3dof_no_weathercock(example_spaceport_env, acceptance_point_mass_rocket):
416+
"""Create a 3 DOF flight without weathercocking.
417+
418+
Parameters
419+
----------
420+
example_spaceport_env : rocketpy.Environment
421+
Environment fixture for Spaceport America.
422+
acceptance_point_mass_rocket : rocketpy.PointMassRocket
423+
Point mass rocket fixture.
424+
425+
Returns
426+
-------
427+
rocketpy.Flight
428+
A 3 DOF flight simulation with weathercock_coeff=0.0.
429+
"""
430+
return Flight(
431+
rocket=acceptance_point_mass_rocket,
432+
environment=example_spaceport_env,
433+
rail_length=5.0,
434+
inclination=85, # 85 degrees from horizontal (5 degrees from vertical)
435+
heading=0,
436+
simulation_mode="3 DOF",
437+
weathercock_coeff=0.0,
438+
)
439+
440+
441+
@pytest.fixture
442+
def flight_3dof_with_weathercock(example_spaceport_env, acceptance_point_mass_rocket):
443+
"""Create a 3 DOF flight with weathercocking enabled.
444+
445+
Parameters
446+
----------
447+
example_spaceport_env : rocketpy.Environment
448+
Environment fixture for Spaceport America.
449+
acceptance_point_mass_rocket : rocketpy.PointMassRocket
450+
Point mass rocket fixture.
451+
452+
Returns
453+
-------
454+
rocketpy.Flight
455+
A 3 DOF flight simulation with weathercock_coeff=1.0.
456+
"""
457+
return Flight(
458+
rocket=acceptance_point_mass_rocket,
459+
environment=example_spaceport_env,
460+
rail_length=5.0,
461+
inclination=85,
462+
heading=0,
463+
simulation_mode="3 DOF",
464+
weathercock_coeff=1.0,
465+
)

0 commit comments

Comments
 (0)