import os
from enum import Enum
from importlib import resources
import pybullet_data
[docs]
class URDF(Enum):
"""
Enum listing all the built-in URDF
"""
A1 = "a1"
AIRPLANE = "airplane"
CUBE = "cube"
DRONE_RACER = "drone_racer"
DRONE_CF2P = "drone_cf2p"
DRONE_CF2X = "drone_cf2x"
PLANE = "plane"
PLANE_100 = "plane_100"
RACECAR = "racecar"
@property
def urdf(self) -> str:
"""Path to the URDF file corresponding to the enum entry"""
if self == URDF.RACECAR:
return os.path.join(pybullet_data.getDataPath(), "racecar", "racecar_differential.urdf")
elif self == URDF.A1:
return os.path.join(pybullet_data.getDataPath(), "a1", "a1.urdf")
elif self == URDF.DRONE_RACER:
with resources.path( # pylint: disable=deprecated-method (3.8)
"symaware.simulators.pybullet", "__init__.py"
) as path:
return str(path.parent.joinpath("assets", "racer.urdf"))
elif self == URDF.DRONE_CF2P:
with resources.path( # pylint: disable=deprecated-method (3.8)
"symaware.simulators.pybullet", "__init__.py"
) as path:
return str(path.parent.joinpath("assets", "cf2p.urdf"))
elif self == URDF.DRONE_CF2X:
with resources.path( # pylint: disable=deprecated-method (3.8)
"symaware.simulators.pybullet", "__init__.py"
) as path:
return str(path.parent.joinpath("assets", "cf2x.urdf"))
elif self == URDF.CUBE:
return os.path.join(pybullet_data.getDataPath(), "cube.urdf")
elif self == URDF.PLANE:
return os.path.join(pybullet_data.getDataPath(), "plane.urdf")
elif self == URDF.PLANE_100:
return os.path.join(pybullet_data.getDataPath(), "plane100.urdf")
elif self == URDF.AIRPLANE:
with resources.path( # pylint: disable=deprecated-method (3.8)
"symaware.simulators.pybullet", "__init__.py"
) as path:
return str(path.parent.joinpath("assets", "airplane.urdf"))
else:
raise ValueError(f"Unknown urdp {self}")