mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-06-27 17:42:04 +08:00
fix metadrive after bump (#30967)
* fix clip * wip * oop * 1.22 * ... ugly * fix tuning old-commit-hash: f2c73039d7799da139ec4e55520f525db4fb95cc
This commit is contained in:
@@ -3,15 +3,13 @@ import numpy as np
|
||||
from metadrive.component.sensors.rgb_camera import RGBCamera
|
||||
from metadrive.component.sensors.base_camera import _cuda_enable
|
||||
from metadrive.component.map.pg_map import MapGenerateMethod
|
||||
from panda3d.core import Vec3, Texture, GraphicsOutput
|
||||
from panda3d.core import Texture, GraphicsOutput
|
||||
|
||||
from openpilot.tools.sim.bridge.common import SimulatorBridge
|
||||
from openpilot.tools.sim.bridge.metadrive.metadrive_world import MetaDriveWorld
|
||||
from openpilot.tools.sim.lib.camerad import W, H
|
||||
|
||||
|
||||
C3_POSITION = Vec3(0.0, 1.0, 1.22)
|
||||
|
||||
|
||||
class CopyRamRGBCamera(RGBCamera):
|
||||
"""Camera which copies its content into RAM during the render process, for faster image grabbing."""
|
||||
@@ -33,8 +31,6 @@ class CopyRamRGBCamera(RGBCamera):
|
||||
class RGBCameraWide(CopyRamRGBCamera):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(RGBCameraWide, self).__init__(*args, **kwargs)
|
||||
cam = self.get_cam()
|
||||
cam.setPos(C3_POSITION)
|
||||
lens = self.get_lens()
|
||||
lens.setFov(120)
|
||||
lens.setNear(0.1)
|
||||
@@ -42,8 +38,6 @@ class RGBCameraWide(CopyRamRGBCamera):
|
||||
class RGBCameraRoad(CopyRamRGBCamera):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(RGBCameraRoad, self).__init__(*args, **kwargs)
|
||||
cam = self.get_cam()
|
||||
cam.setPos(C3_POSITION)
|
||||
lens = self.get_lens()
|
||||
lens.setFov(40)
|
||||
lens.setNear(0.1)
|
||||
|
||||
@@ -2,6 +2,7 @@ import math
|
||||
import numpy as np
|
||||
|
||||
from collections import namedtuple
|
||||
from panda3d.core import Vec3
|
||||
from multiprocessing.connection import Connection
|
||||
|
||||
from metadrive.engine.core.engine_core import EngineCore
|
||||
@@ -10,9 +11,13 @@ from metadrive.envs.metadrive_env import MetaDriveEnv
|
||||
from metadrive.obs.image_obs import ImageObservation
|
||||
|
||||
from openpilot.common.realtime import Ratekeeper
|
||||
|
||||
from openpilot.tools.sim.lib.common import vec3
|
||||
from openpilot.tools.sim.lib.camerad import W, H
|
||||
|
||||
C3_POSITION = Vec3(0.0, 0, 1.22)
|
||||
C3_HPR = Vec3(0, 0,0)
|
||||
|
||||
|
||||
metadrive_state = namedtuple("metadrive_state", ["velocity", "position", "bearing", "steering_angle"])
|
||||
|
||||
@@ -58,14 +63,17 @@ def metadrive_process(dual_camera: bool, config: dict, camera_array, wide_camera
|
||||
|
||||
def get_cam_as_rgb(cam):
|
||||
cam = env.engine.sensors[cam]
|
||||
img = cam.perceive(env.vehicle, clip=False)
|
||||
cam.get_cam().reparentTo(env.vehicle.origin)
|
||||
cam.get_cam().setPos(C3_POSITION)
|
||||
cam.get_cam().setHpr(C3_HPR)
|
||||
img = cam.perceive(clip=False)
|
||||
if type(img) != np.ndarray:
|
||||
img = img.get() # convert cupy array to numpy
|
||||
return img
|
||||
|
||||
rk = Ratekeeper(100, None)
|
||||
|
||||
steer_ratio = 15
|
||||
steer_ratio = 8
|
||||
vc = [0,0]
|
||||
|
||||
while not exit_event.is_set():
|
||||
|
||||
Reference in New Issue
Block a user