Skip to content

Commit

Permalink
remove seaborn
Browse files Browse the repository at this point in the history
  • Loading branch information
maxime-desroches committed Aug 29, 2024
1 parent 9b3fde1 commit de20edc
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
7 changes: 3 additions & 4 deletions metadrive/base_class/base_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
from typing import Dict

import numpy as np
import seaborn as sns
from panda3d.bullet import BulletWorld, BulletBodyNode, BulletVehicle
from panda3d.core import LVector3, NodePath, PandaNode
from metadrive.constants import Semantics, CameraTagStateKey
from metadrive.constants import Semantics, CameraTagStateKey, COLOR_PALETTE
from metadrive.base_class.base_runnable import BaseRunnable
from metadrive.constants import ObjectState
from metadrive.engine.asset_loader import AssetLoader
Expand Down Expand Up @@ -151,8 +150,8 @@ def __init__(self, name=None, random_seed=None, config=None, escape_random_seed_
self.loader.__init__()

# add color setting for visualization
color = sns.color_palette("colorblind")
color.remove(color[2]) # Remove the green and leave it for special vehicle
color = COLOR_PALETTE.copy()
color.pop(2) # Remove the green and leave it for special vehicle
idx = get_np_random().randint(len(color))
rand_c = color[idx]
self._panda_color = rand_c
Expand Down
5 changes: 2 additions & 3 deletions metadrive/component/vehicle/base_vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from typing import Union, Optional

import numpy as np
import seaborn as sns
from panda3d._rplight import RPSpotLight
from panda3d.bullet import BulletVehicle, BulletBoxShape, ZUp
from panda3d.core import Material, Vec3, TransformState
Expand All @@ -17,7 +16,7 @@
from metadrive.component.lane.straight_lane import StraightLane
from metadrive.component.navigation_module.node_network_navigation import NodeNetworkNavigation
from metadrive.component.pg_space import VehicleParameterSpace, ParameterSpace
from metadrive.constants import CamMask
from metadrive.constants import CamMask, COLOR_PALETTE
from metadrive.constants import MetaDriveType, CollisionGroup
from metadrive.constants import Semantics
from metadrive.engine.asset_loader import AssetLoader
Expand Down Expand Up @@ -995,7 +994,7 @@ def lane_index(self):
def panda_color(self):
c = super(BaseVehicle, self).panda_color
if self._use_special_color:
color = sns.color_palette("colorblind")
color = COLOR_PALETTE
rand_c = color[2] # A pretty green
c = rand_c
return c
Expand Down
12 changes: 12 additions & 0 deletions metadrive/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,3 +546,15 @@ class CameraTagStateKey:

DEFAULT_SENSOR_OFFSET = (0., 0.8, 1.5)
DEFAULT_SENSOR_HPR = (0., 0.0, 0.0)

COLOR_PALETTE = [(0.00392156862745098, 0.45098039215686275, 0.6980392156862745),
(0.8705882352941177, 0.5607843137254902, 0.0196078431372549),
(0.00784313725490196, 0.6196078431372549, 0.45098039215686275),
(0.8352941176470589, 0.3686274509803922, 0.0),
(0.8, 0.47058823529411764, 0.7372549019607844),
(0.792156862745098, 0.5686274509803921, 0.3803921568627451),
(0.984313725490196, 0.6862745098039216, 0.8941176470588236),
(0.5803921568627451, 0.5803921568627451, 0.5803921568627451),
(0.9254901960784314, 0.8823529411764706, 0.2),
(0.33725490196078434, 0.7058823529411765, 0.9137254901960784)]

5 changes: 2 additions & 3 deletions metadrive/tests/test_env/test_metadrive_env.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import copy
import seaborn as sns
import os

import numpy as np
import pytest

from metadrive import MetaDriveEnv
from metadrive.constants import TerminationState
from metadrive.constants import TerminationState, COLOR_PALETTE

# Key: scenario name, value: environmental config
blackbox_test_configs = dict(
Expand Down Expand Up @@ -60,7 +59,7 @@ def test_pgdrive_env_blackbox(config):
env = MetaDriveEnv(config=cfg)
try:
obs, _ = env.reset()
assert env.agent.panda_color == sns.color_palette("colorblind")[2]
assert env.agent.panda_color == COLOR_PALETTE[2]
assert env.observation_space.contains(obs)
_act(env, env.action_space.sample())
for x in [-1, 0, 1]:
Expand Down
4 changes: 2 additions & 2 deletions metadrive/tests/test_env/test_waymo_env.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
import seaborn as sns
import numpy as np

from metadrive.constants import COLOR_PALETTE
from metadrive.engine.asset_loader import AssetLoader
from metadrive.envs.scenario_env import ScenarioEnv
from metadrive.policy.idm_policy import TrajectoryIDMPolicy
Expand Down Expand Up @@ -38,7 +38,7 @@ def test_waymo_env(policy, render=False, num_scenarios=3):

if i == 999:
raise ValueError("Can not arrive dest")
assert env.agent.panda_color == sns.color_palette("colorblind")[2]
assert env.agent.panda_color == COLOR_PALETTE[2]
finally:
env.close()

Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def is_win():
"pygame",
"tqdm",
"yapf",
"seaborn",
"tqdm",
"progressbar",
# "panda3d==1.10.8",
Expand Down

0 comments on commit de20edc

Please sign in to comment.