Skip to content

Commit

Permalink
#34 Made landed habitat rotate with the surface of the Earth
Browse files Browse the repository at this point in the history
The habitat maintains its heading away from the surface of the Earth
without having to reset its heading.

Also, fixed a bug where small engine values while landed could cause the
habitat to fall into the Earth.
  • Loading branch information
pmelanson committed Feb 13, 2019
1 parent c317df9 commit 09ef665
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 140 deletions.
20 changes: 7 additions & 13 deletions orbitx/PhysicEntity.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,21 @@ class PhysicsEntity(object):
habitat_hull_strength=50
spacestation_hull_strength=100
cannot_land=0 #reserved for small astroid, to be changed

def __init__(self, entity):
assert isinstance(entity, protos.Entity)
self.name = entity.name
self.pos = np.asarray([entity.x, entity.y])
self.R = entity.r
self.r = entity.r
self.v = np.asarray([entity.vx, entity.vy])
self.m = entity.mass
self.spin = entity.spin
self.heading = entity.heading
self.fuel = entity.fuel
self.throttle = entity.throttle
self.attached_to =""
if hasattr(entity,"attached_to"):
self.attached_to = entity.attached_to
self.broken=False
if hasattr(entity,"broken"):
self.broken = entity.broken
self.artificial=False
if hasattr(entity,"artificial"):
self.artificial = entity.artificial

self.attached_to = entity.attached_to
self.broken = entity.broken
self.artificial = entity.artificial

def as_proto(self):
return protos.Entity(
Expand All @@ -36,7 +30,7 @@ def as_proto(self):
y=self.pos[1],
vx=self.v[0],
vy=self.v[1],
r=self.R,
r=self.r,
mass=self.m,
spin=self.spin,
heading=self.heading,
Expand Down Expand Up @@ -107,7 +101,7 @@ def spin_change(self, *, requested_spin_change=None):

class Habitat():
"""Static class implementing hab engine and reaction wheel constraints."""
engine = Engine(max_fuel_cons=1, max_acc=100)
engine = Engine(max_fuel_cons=1, max_acc=12)
rw = ReactionWheel(max_spin_change=1)

@classmethod
Expand Down
10 changes: 5 additions & 5 deletions orbitx/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@

DEFAULT_TIME_ACC = 1

CHEAT_FUEL = 0
MIN_THROTTLE = -1
MAX_THROTTLE = 1

MIN_THROTTLE = -0.2
MAX_THROTTLE = 1.2
LAUNCH_SEPARATION = 0.5

DEBUG_LOGFILE = 'debug.log'
PERF_FILE = 'flamegraph-data.log'

# Set up a logger.
# Log DEBUG and higher to stderr,
# Log DEBUG and higher to the logfile,
# Log WARNING and higher to stdout.
logging.getLogger().setLevel(logging.DEBUG)
logging.captureWarnings(True)
Expand Down Expand Up @@ -58,7 +58,7 @@


def enable_verbose_logging():
"""Enables logging of all messages, from DEBUG upwards"""
"""Enables logging of all messages to stdout, from DEBUG upwards"""
print_handler.setLevel(logging.DEBUG)


Expand Down
Loading

0 comments on commit 09ef665

Please sign in to comment.