irl-gym Utility Modules

These are intended to fulfill various utility roles for the gym environment.

Collisions

This module contains collision checks for an environment

class irl_gym.utils.collisions.BoundBox3D(p1, p2, p3, buffer=0.1)

Bases: BoundPoly

contains(point)

Check if a point is contained within the box

Parameters:

point – (np.array) point to check

Returns:

(bool) whether the point is contained

plot(fig, ax, plot)

Plot the box

Parameters:
  • fig – (fig) figure to plot on

  • ax – (axis) axis to plot on

  • plot – (plt) whether to show the plot

class irl_gym.utils.collisions.BoundCamera(center, spread, radius, orientation)

Bases: BoundPoly

contains(point)

Check if a point is contained within the polygon

plot(fig, ax, plot)

Plot the polygon

class irl_gym.utils.collisions.BoundCone(center, spread, distance, orientation)

Bases: BoundPoly

contains(point)

Check if a point is contained within the polygon

plot(fig, ax, plot, color='r')

Plot the polygon

class irl_gym.utils.collisions.BoundCylinder(center, radius, height, y_rot=0, z_rot=0, end_sphere=False)

Bases: BoundPoly

Create a cylinder with a center, radius, height, and rotations

Parameters:
  • center – (np.array) center of the cylinder

  • radius – (float) radius of the cylinder

  • height – (float) height of the cylinder

  • y_rot – (float) rotation about the y-axis (rad)

  • z_rot – (float) rotation about the z-axis (rad)

  • end_sphere – (bool) whether to add a sphere to the end of the cylinder

contains(point)

Check if a point is contained within the cylinder (and end sphere)

Parameters:

point – (np.array) point to check

Returns:

(bool) whether the point is contained

plot(fig, ax, plot, color='r')

Plot the cylinder

Parameters:
  • fig – (fig) figure to plot on

  • ax – (axis) axis to plot on

  • plot – (plt) whether to show the plot

  • color – (str) color of the cylinder

class irl_gym.utils.collisions.BoundEverything(*args, **kwargs)

Bases: BoundPoly

contains(point)

Returns true for everything

plot(fig, ax, plot)

Nothing to plot

class irl_gym.utils.collisions.BoundHexPrism(center, radius, height, heading)

Bases: BoundPoly

contains(point)

Check if a point is contained within the hexagonal prism

Parameters:

point – (np.array) point to check

Returns:

(bool) whether the point is contained

get_points()

Get the 2D and 3D corners of the hexagonal prism

plot(fig, ax, plot)

Plot the hexagonal prism

Parameters:
  • fig – (fig) figure to plot on

  • ax – (axis) axis to plot on

  • plot – (plt) whether to show the plot

update(*, center=None, radius=None, height=None, heading=None)

Update the hexagonal prism parameters

Parameters:
  • center – (np.array) center of the hexagonal prism

  • radius – (float) radius of the hexagonal prism

  • height – (float) height of the hexagonal prism

  • heading – (float) heading of the hexagonal prism

class irl_gym.utils.collisions.BoundPoly(*args, **kwargs)

Bases: ABC

abstract contains(point)

Check if a point is contained within the polygon

abstract plot(fig, ax, plot)

Plot the polygon

class irl_gym.utils.collisions.BoundPyramid(center, spread, distance, orientation)

Bases: BoundPoly

contains(point)

Check if a point is contained within the pyramid

Parameters:

point – (np.array) point to check

Returns:

(bool) whether the point is contained

plot(fig, ax, plot)

Plot the pyramid

Parameters:
  • fig – (fig) figure to plot on

  • ax – (axis) axis to plot on

  • plot – (plt) whether to show the plot

class irl_gym.utils.collisions.BoundRectPrism(corner, dimensions)

Bases: BoundPoly

contains(point)

check if a point is contained within the prism (not Implemented)

Parameters:

point – (np.array) point to check

Returns:

(bool) whether the point is contained

plot(fig, ax, plot, color='b')

Plot the rectangular prism

Parameters:
  • fig – (fig) figure to plot on

  • ax – (axis) axis to plot on

  • plot – (plt) whether to show the plot

  • color – (str) color of the prism

class irl_gym.utils.collisions.BoundSphere(center, radius)

Bases: BoundPoly

contains(point)

Check if a point is contained within the sphere

Parameters:

point – (np.array) point to check

Returns:

(bool) whether the point is contained

plot(fig, ax, plot)

Plot the sphere

Parameters:
  • fig – (fig) figure to plot on

  • ax – (axis) axis to plot on

  • plot – (plt) whether to show the plot

Transforms

This module contains transforms

irl_gym.utils.tf.x_rotation(point, center, angle)

Rotate a point about the x axis

Parameters:
  • point – (list) [x,y,z] in global

  • center – (list) [x,y,z] position of rotation in global frame

  • angle – (float) angle (rad) of rotation

Returns:

(list) [x,y,z] in global frame

irl_gym.utils.tf.xyz_rotation(point, center, angles)

Rotate a point about the x, y, and z axes in that order

Parameters:
  • point – (list) [x,y,z] in global

  • center – (list) [x,y,z] position of rotation in global frame

  • angles – (list) [x,y,z] angles (rad) of rotation

Returns:

(list) [x,y,z] in global frame

irl_gym.utils.tf.y_rotation(point, center, angle)

Rotate a point about the y axis

Parameters:
  • point – (list) [x,y,z] in global frame

  • center – (list) [x,y,z] position of rotation in global frame

  • angle – (float) angle (rad) of rotation

irl_gym.utils.tf.z_rotation(point, center, angle)

Rotate a point about the z axis

Parameters:
  • point – (list) [x,y,z] in global

  • center – (list) [x,y,z] position of rotation in global frame

  • angle – (float) angle (rad) of rotation

Returns:

(list) [x,y,z] in global frame

irl_gym.utils.tf.z_rotation_origin(point, center, angle)

Rotate a point about the z axis

Parameters:
  • point – (list) [x,y,z] in global

  • center – (list) [x,y,z] position of rotation in global frame

  • angle – (float) angle (rad) of rotation

Returns:

(list) [x,y,z] in global frame

irl_gym.utils.tf.zyx_rotation(point, center, angles)

Rotate a point about the z, y, and x axes in that order

Parameters:
  • point – (list) [x,y,z] in global

  • center – (list) [x,y,z] position of rotation in global frame

  • angles – (list) [x,y,z] angles (rad) of rotation

Returns:

(list) [x,y,z] in global frame