Remove more np calls
This commit is contained in:
parent
889d4a6d62
commit
d6432bb320
|
@ -110,7 +110,8 @@ Now that we have the USD file for the robot, let's write our own robot class. Fo
|
|||
??? code "stretch.py"
|
||||
``` python linenums="1"
|
||||
import os
|
||||
import numpy as np
|
||||
import math
|
||||
import torch as th
|
||||
from omnigibson.macros import gm
|
||||
from omnigibson.robots.active_camera_robot import ActiveCameraRobot
|
||||
from omnigibson.robots.manipulation_robot import GraspingPoint, ManipulationRobot
|
||||
|
@ -157,7 +158,7 @@ Now that we have the USD file for the robot, let's write our own robot class. Fo
|
|||
def _default_joint_pos(self):
|
||||
# Define the default joint positions for your robot
|
||||
|
||||
return np.array([0, 0, 0.5, 0, 0, 0, 0, 0, 0, 0.0, 0, 0, np.pi / 8, np.pi / 8])
|
||||
return th.tensor([0, 0, 0.5, 0, 0, 0, 0, 0, 0, 0.0, 0, 0, math.pi / 8, math.pi / 8]. dtype=th.float32)
|
||||
|
||||
@property
|
||||
def wheel_radius(self):
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
from functools import cached_property
|
||||
|
||||
import numpy as np
|
||||
import torch as th
|
||||
import trimesh
|
||||
|
||||
import omnigibson as og
|
||||
import omnigibson.lazy as lazy
|
||||
|
@ -92,7 +90,7 @@ class GeomPrim(XFormPrim):
|
|||
if self.has_material():
|
||||
self.material.diffuse_color_constant = rgb
|
||||
else:
|
||||
self.set_attribute("primvars:displayColor", np.array(rgb))
|
||||
self.set_attribute("primvars:displayColor", rgb.cpu().numpy())
|
||||
|
||||
@property
|
||||
def opacity(self):
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
import datetime
|
||||
import math
|
||||
import os
|
||||
import tempfile
|
||||
import uuid
|
||||
from collections import defaultdict
|
||||
from pathlib import Path
|
||||
|
||||
import numpy as np
|
||||
|
@ -18,11 +16,9 @@ from omnigibson.prims.geom_prim import VisualGeomPrim
|
|||
from omnigibson.prims.material_prim import MaterialPrim
|
||||
from omnigibson.prims.prim_base import BasePrim
|
||||
from omnigibson.systems.system_base import BaseSystem, PhysicalParticleSystem
|
||||
from omnigibson.utils.geometry_utils import generate_points_in_volume_checker_function
|
||||
from omnigibson.utils.physx_utils import create_physx_particle_system, create_physx_particleset_pointinstancer
|
||||
from omnigibson.utils.python_utils import assert_valid_key, torch_delete
|
||||
from omnigibson.utils.sampling_utils import sample_cuboid_on_object_full_grid_topdown
|
||||
from omnigibson.utils.ui_utils import create_module_logger, disclaimer
|
||||
from omnigibson.utils.ui_utils import create_module_logger
|
||||
from omnigibson.utils.usd_utils import (
|
||||
PoseAPI,
|
||||
absolute_prim_path_to_scene_relative,
|
||||
|
@ -243,7 +239,7 @@ class PhysxParticleInstancer(BasePrim):
|
|||
th.tensor: (N, 4) numpy array, where each of the N particles' orientations are expressed in (x,y,z,w)
|
||||
quaternion coordinates relative to this instancer's parent prim
|
||||
"""
|
||||
return th.from_numpy(np.array(self.get_attribute(attr="orientations")))
|
||||
return th.from_numpy(np.array(self.get_attribute(attr="orientations"), dtype=np.float32))
|
||||
|
||||
@particle_orientations.setter
|
||||
def particle_orientations(self, quat):
|
||||
|
|
|
@ -11,7 +11,6 @@ from functools import cache, wraps
|
|||
from hashlib import md5
|
||||
from importlib import import_module
|
||||
|
||||
import numpy as np
|
||||
import torch as th
|
||||
|
||||
# Global dictionary storing all unique names
|
||||
|
@ -293,7 +292,7 @@ def get_uuid(name, n_digits=8, deterministic=True):
|
|||
"""
|
||||
# Make sure the number is float32 compatible
|
||||
val = int(md5(name.encode()).hexdigest(), 16) if deterministic else abs(hash(name))
|
||||
return int(np.float32(val % (10**n_digits)))
|
||||
return int(th.tensor(val % (10**n_digits), dtype=th.float32).item())
|
||||
|
||||
|
||||
def meets_minimum_version(test_version, minimum_version):
|
||||
|
|
|
@ -1,18 +1,14 @@
|
|||
import itertools
|
||||
import math
|
||||
import random
|
||||
import time
|
||||
from collections import Counter, defaultdict
|
||||
|
||||
import numpy as np
|
||||
import torch as th
|
||||
import trimesh
|
||||
from scipy.stats import truncnorm
|
||||
|
||||
import omnigibson as og
|
||||
import omnigibson.lazy as lazy
|
||||
import omnigibson.utils.transform_utils as T
|
||||
from omnigibson.macros import create_module_macros, gm
|
||||
from omnigibson.macros import create_module_macros
|
||||
from omnigibson.utils.ui_utils import create_module_logger, draw_line
|
||||
|
||||
# Create module logger
|
||||
|
|
Loading…
Reference in New Issue