Skip to content

Commit

Permalink
make gym-copter optional as used only for rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
acxz committed Dec 4, 2020
1 parent d6129b5 commit 11bf6c4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
19 changes: 16 additions & 3 deletions gym_ccc/envs/multirotor.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
"""Continuous Multirotor Environment."""
import sys

import gym
from gym import spaces

import gym_copter.rendering.twod as twod
try:
import gym_copter.rendering.twod
except ImportError:
pass

import numpy as np

Expand Down Expand Up @@ -341,7 +346,10 @@ def __init__(self, gravity=9.8, mass=1.0, dt=0.02, custom_reset=None):
obs_high, dtype=np.float32)

# Support for rendering
self.renderer = None
if 'gym_copter.rendering.twod' in sys.modules:
self.renderer = None
else:
self.renderer = False
self.pose = None

def step(self, action):
Expand Down Expand Up @@ -389,9 +397,14 @@ def reset(self):

def render(self, mode='human'):
"""Show the current state."""
# Print out state instead of cool gui if renderer not available
if self.renderer is False:
print(self.state)
return self.state

# Creater renderer
if self.renderer is None:
self.renderer = twod.TwoDRenderer()
self.renderer = gym_copter.rendering.twod.TwoDRenderer()

# Just a flag to show the props spinning
flight_status = True
Expand Down
16 changes: 11 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
"""Setup file."""

from setuptools import setup
import setuptools

setup(
with open('README.md', 'r') as fh:
long_description = fh.read()

setuptools.setup(
name='gym-ccc',
version='0.0.1',
author='acxz',
long_description='',
long_description=long_description,
description='Environments for continuous classical control problems with' +
'dynamical state information',
packages=['gym_ccc'],
packages=setuptools.find_packages(),
install_requires=[
'gym',
'gym-copter',
'numpy',
'pyquaternion',
],
extra_requires={
'copter-render': ['gym-copter'],
}
)

0 comments on commit 11bf6c4

Please sign in to comment.