Skip to content

Commit

Permalink
Fixed circular imports by moving enums to separate file. Removed unec…
Browse files Browse the repository at this point in the history
…essary imports
  • Loading branch information
spencerteetaert committed Jun 8, 2022
1 parent 5634010 commit 28bafb3
Show file tree
Hide file tree
Showing 29 changed files with 66 additions and 84 deletions.
2 changes: 1 addition & 1 deletion assignments/aer1216_fall2020_hw2_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from gym_pybullet_drones.envs.CtrlAviary import CtrlAviary
from gym_pybullet_drones.utils.Logger import Logger
from gym_pybullet_drones.utils.utils import sync
from gym_pybullet_drones.envs.BaseAviary import DroneModel
from gym_pybullet_drones.utils.enums import DroneModel
from aer1216_fall2020_hw2_ctrl import HW2Control

DURATION = 10
Expand Down
2 changes: 1 addition & 1 deletion examples/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import numpy as np

from gym_pybullet_drones.utils.utils import sync, str2bool
from gym_pybullet_drones.envs.BaseAviary import DroneModel, Physics
from gym_pybullet_drones.utils.enums import DroneModel, Physics
from gym_pybullet_drones.envs.CtrlAviary import CtrlAviary
from gym_pybullet_drones.control.DSLPIDControl import DSLPIDControl
from gym_pybullet_drones.utils.Logger import Logger
Expand Down
2 changes: 1 addition & 1 deletion examples/downwash.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import numpy as np

from gym_pybullet_drones.utils.utils import sync, str2bool
from gym_pybullet_drones.envs.BaseAviary import DroneModel, Physics
from gym_pybullet_drones.utils.enums import DroneModel, Physics
from gym_pybullet_drones.envs.CtrlAviary import CtrlAviary
from gym_pybullet_drones.control.DSLPIDControl import DSLPIDControl
from gym_pybullet_drones.utils.Logger import Logger
Expand Down
2 changes: 1 addition & 1 deletion examples/fly.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import pybullet as p
import matplotlib.pyplot as plt

from gym_pybullet_drones.envs.BaseAviary import DroneModel, Physics
from gym_pybullet_drones.utils.enums import DroneModel, Physics
from gym_pybullet_drones.envs.CtrlAviary import CtrlAviary
from gym_pybullet_drones.envs.VisionAviary import VisionAviary
from gym_pybullet_drones.control.DSLPIDControl import DSLPIDControl
Expand Down
2 changes: 1 addition & 1 deletion examples/groundeffect.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import pybullet as p
import matplotlib.pyplot as plt

from gym_pybullet_drones.envs.BaseAviary import DroneModel, Physics
from gym_pybullet_drones.utils.enums import DroneModel, Physics
from gym_pybullet_drones.envs.CtrlAviary import CtrlAviary
from gym_pybullet_drones.envs.VisionAviary import VisionAviary
from gym_pybullet_drones.control.DSLPIDControl import DSLPIDControl
Expand Down
2 changes: 1 addition & 1 deletion examples/velocity.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import pybullet as p
import matplotlib.pyplot as plt

from gym_pybullet_drones.envs.BaseAviary import DroneModel, Physics
from gym_pybullet_drones.utils.enums import DroneModel, Physics
from gym_pybullet_drones.envs.CtrlAviary import CtrlAviary
from gym_pybullet_drones.envs.VisionAviary import VisionAviary
from gym_pybullet_drones.control.DSLPIDControl import DSLPIDControl
Expand Down
2 changes: 1 addition & 1 deletion experiments/learning/multiagent.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
from ray.rllib.policy.sample_batch import SampleBatch
from ray.rllib.env.multi_agent_env import ENV_STATE

from gym_pybullet_drones.envs.BaseAviary import DroneModel, Physics
from gym_pybullet_drones.utils.enums import DroneModel, Physics
from gym_pybullet_drones.envs.multi_agent_rl.FlockAviary import FlockAviary
from gym_pybullet_drones.envs.multi_agent_rl.LeaderFollowerAviary import LeaderFollowerAviary
from gym_pybullet_drones.envs.multi_agent_rl.MeetupAviary import MeetupAviary
Expand Down
2 changes: 1 addition & 1 deletion experiments/learning/test_multiagent.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from ray.rllib.models import ModelCatalog
from ray.rllib.policy.sample_batch import SampleBatch

from gym_pybullet_drones.envs.BaseAviary import DroneModel, Physics
from gym_pybullet_drones.utils.enums import DroneModel, Physics
from gym_pybullet_drones.envs.multi_agent_rl.FlockAviary import FlockAviary
from gym_pybullet_drones.envs.multi_agent_rl.LeaderFollowerAviary import LeaderFollowerAviary
from gym_pybullet_drones.envs.multi_agent_rl.MeetupAviary import MeetupAviary
Expand Down
2 changes: 1 addition & 1 deletion experiments/performance/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import pybullet as p
import matplotlib.pyplot as plt

from gym_pybullet_drones.envs.BaseAviary import DroneModel, Physics
from gym_pybullet_drones.utils.enums import DroneModel, Physics
from gym_pybullet_drones.envs.CtrlAviary import CtrlAviary
from gym_pybullet_drones.envs.VisionAviary import VisionAviary
from gym_pybullet_drones.control.DSLPIDControl import DSLPIDControl
Expand Down
6 changes: 1 addition & 5 deletions gym_pybullet_drones/control/BaseControl.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import os
import math
import numpy as np
import pybullet as p
from enum import Enum
import xml.etree.ElementTree as etxml
from scipy.spatial.transform import Rotation

from gym_pybullet_drones.envs.BaseAviary import DroneModel, BaseAviary
from gym_pybullet_drones.utils.enums import DroneModel

class BaseControl(object):
"""Base class for control.
Expand Down
2 changes: 1 addition & 1 deletion gym_pybullet_drones/control/DSLPIDControl.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from scipy.spatial.transform import Rotation

from gym_pybullet_drones.control.BaseControl import BaseControl
from gym_pybullet_drones.envs.BaseAviary import DroneModel, BaseAviary
from gym_pybullet_drones.utils.enums import DroneModel

class DSLPIDControl(BaseControl):
"""PID control class for Crazyflies.
Expand Down
3 changes: 1 addition & 2 deletions gym_pybullet_drones/control/SimplePIDControl.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import math
import numpy as np
import pybullet as p

from gym_pybullet_drones.control.BaseControl import BaseControl
from gym_pybullet_drones.envs.BaseAviary import DroneModel, BaseAviary
from gym_pybullet_drones.utils.enums import DroneModel
from gym_pybullet_drones.utils.utils import nnlsRPM

class SimplePIDControl(BaseControl):
Expand Down
31 changes: 1 addition & 30 deletions gym_pybullet_drones/envs/BaseAviary.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import time
import collections
from datetime import datetime
from enum import Enum
import xml.etree.ElementTree as etxml
from PIL import Image
# import pkgutil
Expand All @@ -12,37 +11,9 @@
import pybullet as p
import pybullet_data
import gym
from gym_pybullet_drones.utils.enums import DroneModel, Physics, ImageType

class DroneModel(Enum):
"""Drone models enumeration class."""

CF2X = "cf2x" # Bitcraze Craziflie 2.0 in the X configuration
CF2P = "cf2p" # Bitcraze Craziflie 2.0 in the + configuration
HB = "hb" # Generic quadrotor (with AscTec Hummingbird inertial properties)

################################################################################

class Physics(Enum):
"""Physics implementations enumeration class."""

PYB = "pyb" # Base PyBullet physics update
DYN = "dyn" # Update with an explicit model of the dynamics
PYB_GND = "pyb_gnd" # PyBullet physics update with ground effect
PYB_DRAG = "pyb_drag" # PyBullet physics update with drag
PYB_DW = "pyb_dw" # PyBullet physics update with downwash
PYB_GND_DRAG_DW = "pyb_gnd_drag_dw" # PyBullet physics update with ground effect, drag, and downwash

################################################################################

class ImageType(Enum):
"""Camera capture image type enumeration class."""

RGB = 0 # Red, green, blue (and alpha)
DEP = 1 # Depth
SEG = 2 # Segmentation by object id
BW = 3 # Black and white

################################################################################

class BaseAviary(gym.Env):
"""Base class for "drone aviary" Gym environments."""
Expand Down
3 changes: 2 additions & 1 deletion gym_pybullet_drones/envs/CtrlAviary.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import numpy as np
from gym import spaces

from gym_pybullet_drones.envs.BaseAviary import DroneModel, Physics, BaseAviary
from gym_pybullet_drones.envs.BaseAviary import BaseAviary
from gym_pybullet_drones.utils.enums import DroneModel, Physics

class CtrlAviary(BaseAviary):
"""Multi-drone environment class for control applications."""
Expand Down
3 changes: 2 additions & 1 deletion gym_pybullet_drones/envs/DynAviary.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import numpy as np
from gym import spaces

from gym_pybullet_drones.envs.BaseAviary import DroneModel, Physics, BaseAviary
from gym_pybullet_drones.envs.BaseAviary import BaseAviary
from gym_pybullet_drones.utils.enums import DroneModel, Physics
from gym_pybullet_drones.utils.utils import nnlsRPM

class DynAviary(BaseAviary):
Expand Down
3 changes: 2 additions & 1 deletion gym_pybullet_drones/envs/VelocityAviary.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import numpy as np
from gym import spaces

from gym_pybullet_drones.envs.BaseAviary import DroneModel, Physics, BaseAviary
from gym_pybullet_drones.envs.BaseAviary import BaseAviary
from gym_pybullet_drones.utils.enums import DroneModel, Physics
from gym_pybullet_drones.control.DSLPIDControl import DSLPIDControl
from gym_pybullet_drones.control.SimplePIDControl import SimplePIDControl

Expand Down
3 changes: 2 additions & 1 deletion gym_pybullet_drones/envs/VisionAviary.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import numpy as np
from gym import spaces

from gym_pybullet_drones.envs.BaseAviary import DroneModel, Physics, ImageType, BaseAviary
from gym_pybullet_drones.envs.BaseAviary import BaseAviary
from gym_pybullet_drones.utils.enums import DroneModel, Physics, ImageType

class VisionAviary(BaseAviary):
"""Multi-drone environment class for control applications using vision."""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import os
from datetime import datetime
import numpy as np
import pybullet as p
from gym import spaces
from ray.rllib.env.multi_agent_env import MultiAgentEnv, ENV_STATE
from ray.rllib.env.multi_agent_env import MultiAgentEnv

from gym_pybullet_drones.envs.BaseAviary import DroneModel, Physics, BaseAviary
from gym_pybullet_drones.envs.BaseAviary import BaseAviary
from gym_pybullet_drones.utils.enums import DroneModel, Physics
from gym_pybullet_drones.envs.single_agent_rl.BaseSingleAgentAviary import ActionType, ObservationType
from gym_pybullet_drones.utils.utils import nnlsRPM
from gym_pybullet_drones.control.DSLPIDControl import DSLPIDControl
Expand Down
6 changes: 1 addition & 5 deletions gym_pybullet_drones/envs/multi_agent_rl/FlockAviary.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import math
import numpy as np
from gym import spaces
from ray.rllib.env.multi_agent_env import MultiAgentEnv, ENV_STATE

from gym_pybullet_drones.envs.BaseAviary import DroneModel, Physics, BaseAviary

from gym_pybullet_drones.envs.BaseAviary import DroneModel, Physics, BaseAviary
from gym_pybullet_drones.utils.enums import DroneModel, Physics
from gym_pybullet_drones.envs.single_agent_rl.BaseSingleAgentAviary import ActionType, ObservationType
from gym_pybullet_drones.envs.multi_agent_rl.BaseMultiagentAviary import BaseMultiagentAviary

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import math
import numpy as np
from gym import spaces
from ray.rllib.env.multi_agent_env import MultiAgentEnv, ENV_STATE

from gym_pybullet_drones.envs.BaseAviary import DroneModel, Physics, BaseAviary

from gym_pybullet_drones.envs.BaseAviary import DroneModel, Physics, BaseAviary
from gym_pybullet_drones.utils.enums import DroneModel, Physics
from gym_pybullet_drones.envs.single_agent_rl.BaseSingleAgentAviary import ActionType, ObservationType
from gym_pybullet_drones.envs.multi_agent_rl.BaseMultiagentAviary import BaseMultiagentAviary

Expand Down
7 changes: 1 addition & 6 deletions gym_pybullet_drones/envs/multi_agent_rl/MeetupAviary.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import math
import numpy as np
from gym import spaces
from ray.rllib.env.multi_agent_env import MultiAgentEnv, ENV_STATE

from gym_pybullet_drones.envs.BaseAviary import DroneModel, Physics, BaseAviary

from gym_pybullet_drones.envs.BaseAviary import DroneModel, Physics, BaseAviary
from gym_pybullet_drones.utils.enums import DroneModel, Physics
from gym_pybullet_drones.envs.single_agent_rl.BaseSingleAgentAviary import ActionType, ObservationType
from gym_pybullet_drones.envs.multi_agent_rl.BaseMultiagentAviary import BaseMultiagentAviary

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import os
from datetime import datetime
from enum import Enum
import numpy as np
from gym import spaces
import pybullet as p
import pybullet_data

from gym_pybullet_drones.envs.BaseAviary import DroneModel, Physics, ImageType, BaseAviary
from gym_pybullet_drones.envs.BaseAviary import BaseAviary
from gym_pybullet_drones.utils.enums import DroneModel, Physics, ImageType
from gym_pybullet_drones.utils.utils import nnlsRPM
from gym_pybullet_drones.control.DSLPIDControl import DSLPIDControl
from gym_pybullet_drones.control.SimplePIDControl import SimplePIDControl
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import os
import numpy as np
from gym import spaces
import pybullet as p

from gym_pybullet_drones.envs.BaseAviary import DroneModel, Physics, BaseAviary
from gym_pybullet_drones.utils.enums import DroneModel, Physics
from gym_pybullet_drones.envs.single_agent_rl.BaseSingleAgentAviary import ActionType, ObservationType, BaseSingleAgentAviary


Expand Down
3 changes: 1 addition & 2 deletions gym_pybullet_drones/envs/single_agent_rl/HoverAviary.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import numpy as np
from gym import spaces

from gym_pybullet_drones.envs.BaseAviary import DroneModel, Physics, BaseAviary
from gym_pybullet_drones.utils.enums import DroneModel, Physics
from gym_pybullet_drones.envs.single_agent_rl.BaseSingleAgentAviary import ActionType, ObservationType, BaseSingleAgentAviary

class HoverAviary(BaseSingleAgentAviary):
Expand Down
3 changes: 1 addition & 2 deletions gym_pybullet_drones/envs/single_agent_rl/TakeoffAviary.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import numpy as np
from gym import spaces

from gym_pybullet_drones.envs.BaseAviary import DroneModel, Physics, BaseAviary
from gym_pybullet_drones.utils.enums import DroneModel, Physics
from gym_pybullet_drones.envs.single_agent_rl.BaseSingleAgentAviary import ActionType, ObservationType, BaseSingleAgentAviary

class TakeoffAviary(BaseSingleAgentAviary):
Expand Down
3 changes: 1 addition & 2 deletions gym_pybullet_drones/envs/single_agent_rl/TuneAviary.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import numpy as np
from gym import spaces

from gym_pybullet_drones.envs.BaseAviary import DroneModel, Physics, BaseAviary
from gym_pybullet_drones.utils.enums import DroneModel, Physics
from gym_pybullet_drones.envs.single_agent_rl.BaseSingleAgentAviary import ActionType, ObservationType, BaseSingleAgentAviary

class TuneAviary(BaseSingleAgentAviary):
Expand Down
1 change: 0 additions & 1 deletion gym_pybullet_drones/utils/Logger.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import time
from datetime import datetime
from cycler import cycler
import numpy as np
Expand Down
32 changes: 32 additions & 0 deletions gym_pybullet_drones/utils/enums.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from enum import Enum

class DroneModel(Enum):
"""Drone models enumeration class."""

CF2X = "cf2x" # Bitcraze Craziflie 2.0 in the X configuration
CF2P = "cf2p" # Bitcraze Craziflie 2.0 in the + configuration
HB = "hb" # Generic quadrotor (with AscTec Hummingbird inertial properties)

################################################################################

class Physics(Enum):
"""Physics implementations enumeration class."""

PYB = "pyb" # Base PyBullet physics update
DYN = "dyn" # Update with an explicit model of the dynamics
PYB_GND = "pyb_gnd" # PyBullet physics update with ground effect
PYB_DRAG = "pyb_drag" # PyBullet physics update with drag
PYB_DW = "pyb_dw" # PyBullet physics update with downwash
PYB_GND_DRAG_DW = "pyb_gnd_drag_dw" # PyBullet physics update with ground effect, drag, and downwash

################################################################################

class ImageType(Enum):
"""Camera capture image type enumeration class."""

RGB = 0 # Red, green, blue (and alpha)
DEP = 1 # Depth
SEG = 2 # Segmentation by object id
BW = 3 # Black and white

################################################################################
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from rclpy.node import Node
from std_msgs.msg import Float32MultiArray

from gym_pybullet_drones.envs.BaseAviary import DroneModel, Physics
from gym_pybullet_drones.utils.enums import DroneModel, Physics
from gym_pybullet_drones.envs.CtrlAviary import CtrlAviary

class AviaryWrapper(Node):
Expand Down

0 comments on commit 28bafb3

Please sign in to comment.