Skip to content

Commit

Permalink
Closes #2: adding PRE test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ross Allen committed Dec 11, 2023
1 parent 4403f0d commit 19d009d
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 2 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [v0.4.4] - 2023-12-11

### Added

- [iss2](https://github.com/mit-ll/spacegym-kspdg/issues/2) Unit test to check for PhysicsRangeExtender (PRE) proper installation

### Fixed

- PRE installed instructions in README

### Changed

### Removed

## [v0.4.3] - 2023-11-29

### Added
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ git clone [email protected]:jrodrigv/PhysicsRangeExtender.git

# copy the necessary game data for the mod into your KSP install
mkdir ~/Desktop/KSP_osx/GameData/PhysicsRangeExtender
cp -r ~/Desktop/PhysicsRangeExtender/PhysicsRangeExtender/Distribution/GameData/PhysicsRangeExtender/ ~/Desktop/KSP_osx/GameData/PhysicsRangeExtender/
cp -r ~/Desktop/PhysicsRangeExtender/PhysicsRangeExtender/Distribution/GameData/PhysicsRangeExtender/* ~/Desktop/KSP_osx/GameData/PhysicsRangeExtender/
```

### Install `kspdg`
Expand Down
2 changes: 1 addition & 1 deletion src/kspdg/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
# Single-sourcing package version
# https://packaging.python.org/guides/single-sourcing-package-version/

VERSION = "0.4.3"
VERSION = "0.4.4"
46 changes: 46 additions & 0 deletions tests/ksp_ingame_tests/test_pe1_e1_i3.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,52 @@ def test_step_action_ref_frame_2(pe1_e1_i3_env):
assert np.isclose(r0, r1)
assert np.isclose(v0, v1)

def test_physics_range_extender_1(pe1_e1_i3_env):
'''Check that PRE is installed properly
'''
# ~~ ARRANGE ~~

if pe1_e1_i3_env is None:
env = PE1_E1_I3_Env()
env.reset()
else:
env = pe1_e1_i3_env


# ~~ ACT ~~

rf = env.vesPursue.orbital_reference_frame

# get initial speed of evader wrt pursuer
ve0 = np.linalg.norm(env.vesEvade.velocity(rf))

# Set and engage evader auto-pilot reference frame so
# that it points in it's own prograde direction
env.vesEvade.auto_pilot.reference_frame = env.vesEvade.orbital_reference_frame
env.vesEvade.auto_pilot.target_pitch = 0.0
env.vesEvade.auto_pilot.target_heading = 0.0
env.vesEvade.auto_pilot.target_roll = 0.0
env.vesEvade.auto_pilot.engage()

# turn on low-thrust maneuver for evader for fixed amount of time
env.vesEvade.control.rcs = True
env.vesEvade.control.forward = 1.0
time.sleep(5.0)

# terminate throttle
env.vesEvade.control.forward = 0.0
env.vesEvade.control.right = 0.0
env.vesEvade.control.up = 0.0
env.vesEvade.auto_pilot.disengage()

# get final speed of evader wrt pursuer
ve1 = np.linalg.norm(env.vesEvade.velocity(rf))

# ~~ ASSERT ~~
assert not np.isclose(ve0, ve1)
dv = ve1 - ve0
assert dv > 1.0

if __name__ == "__main__":
# test_get_info_0(None)
test_observation_dict_list_convert_0(None)

0 comments on commit 19d009d

Please sign in to comment.