@@ -730,7 +730,7 @@ class ParamsLength(Enum):
730
730
BOX = 3 # (x, y, z) Axis-aligned box with given side lengths
731
731
CYLINDER = 2 # (rad, lz) Cylinder with given radius and height along z-axis
732
732
SPHERE = 1 # (rad) Sphere with given radius
733
- ELLIPSOID = 3 # (x, y, z) Axis-aligned ellipsoid with given radis
733
+ ELLIPSOID = 3 # (x, y, z) Axis-aligned ellipsoid with given radius
734
734
CAPSULE = 2 # (rad, lz) Capsule with given radius and height along z-axis
735
735
CONE = 2 # (rad, lz) Cone with given radius and height along z-axis
736
736
@@ -805,6 +805,36 @@ def get_radius(cls, geometry_type: Type, parameters: np.ndarray) -> float:
805
805
else :
806
806
return np .sqrt (parameters [1 ] + parameters [0 ]) / 2
807
807
808
+ @classmethod
809
+ def get_height (cls , geometry_type : Type , parameters : np .ndarray ) -> float :
810
+ """
811
+ Gets the robot height from the geometry
812
+
813
+ :param geometry_type: Robot Geometry Type
814
+ :type geometry_type: Type
815
+ :param parameters: Robot Geometry Parameters
816
+ :type parameters: np.ndarray
817
+
818
+ :return: Robot height if the parameters are valid, else None
819
+ :rtype: Optional[float]
820
+ """
821
+ if not cls .is_valid_parameters (geometry_type , parameters ):
822
+ raise ValueError ("Invalid parameters for the robot geometry" )
823
+ if geometry_type in [
824
+ cls .Type .CONE ,
825
+ cls .Type .CYLINDER ,
826
+ cls .Type .CAPSULE ,
827
+ cls .Type .ELLIPSOID ,
828
+ ]:
829
+ # Last parameter is the height
830
+ return parameters [- 1 ]
831
+ elif geometry_type == cls .Type .SPHERE :
832
+ # Return sphere height
833
+ return parameters [0 ] * 2.0
834
+ else :
835
+ # return BOX height
836
+ return parameters [0 ]
837
+
808
838
@classmethod
809
839
def get_length (cls , geometry_type : Type , parameters : np .ndarray ) -> Optional [float ]:
810
840
"""
@@ -1290,6 +1320,16 @@ def radius(self) -> float:
1290
1320
"""
1291
1321
return RobotGeometry .get_radius (self .geometry_type , self .geometry_params )
1292
1322
1323
+ @property
1324
+ def height (self ) -> float :
1325
+ """
1326
+ Gets the robot height
1327
+
1328
+ :return: Height (meters)
1329
+ :rtype: float
1330
+ """
1331
+ return RobotGeometry .get_height (self .geometry_type , self .geometry_params )
1332
+
1293
1333
@property
1294
1334
def wheelbase (self ) -> float :
1295
1335
"""
0 commit comments