Skip to content

Commit

Permalink
Moved PlanarTerrain to a dedicated file
Browse files Browse the repository at this point in the history
  • Loading branch information
S-Dafarra committed Dec 29, 2023
1 parent bd0cb20 commit c025e22
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 43 deletions.
3 changes: 2 additions & 1 deletion src/hippopt/robot_planning/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
quaternion_slerp,
transform_interpolator,
)
from .utilities.terrain_descriptor import PlanarTerrain, TerrainDescriptor
from .utilities.planar_terrain import PlanarTerrain
from .utilities.terrain_descriptor import TerrainDescriptor
from .variables.contacts import (
ContactPointDescriptor,
ContactPointState,
Expand Down
1 change: 1 addition & 0 deletions src/hippopt/robot_planning/utilities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
foot_contact_state_plotter,
humanoid_state_visualizer,
interpolators,
planar_terrain,
terrain_descriptor,
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@
import matplotlib.pyplot as plt
import numpy as np

from hippopt.robot_planning.utilities.terrain_descriptor import (
PlanarTerrain,
TerrainDescriptor,
)
from hippopt.robot_planning.utilities.planar_terrain import PlanarTerrain
from hippopt.robot_planning.utilities.terrain_descriptor import TerrainDescriptor
from hippopt.robot_planning.variables.contacts import (
ContactPointState,
FootContactState,
Expand Down
41 changes: 41 additions & 0 deletions src/hippopt/robot_planning/utilities/planar_terrain.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import casadi as cs

from hippopt.robot_planning.utilities.terrain_descriptor import TerrainDescriptor


class PlanarTerrain(TerrainDescriptor):
def create_height_function(self) -> cs.Function:
point_position = cs.MX.sym(self.get_point_position_name(), 3)

return cs.Function(
"planar_terrain_height",
[point_position],
[point_position[2]],
[self.get_point_position_name()],
["point_height"],
self._options,
)

def create_normal_direction_function(self) -> cs.Function:
point_position = cs.MX.sym(self.get_point_position_name(), 3)

return cs.Function(
"planar_terrain_normal",
[point_position],
[cs.MX.eye(3)[:, 2]],
[self.get_point_position_name()],
["normal_direction"],
self._options,
)

def create_orientation_function(self) -> cs.Function:
point_position = cs.MX.sym(self.get_point_position_name(), 3)

return cs.Function(
"planar_terrain_orientation",
[point_position],
[cs.MX.eye(3)],
[self.get_point_position_name()],
["plane_rotation"],
self._options,
)
38 changes: 0 additions & 38 deletions src/hippopt/robot_planning/utilities/terrain_descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,41 +68,3 @@ def get_point_position_name(self) -> str:

def get_name(self) -> str:
return self._name if isinstance(self._name, str) else self.__class__.__name__


class PlanarTerrain(TerrainDescriptor):
def create_height_function(self) -> cs.Function:
point_position = cs.MX.sym(self.get_point_position_name(), 3)

return cs.Function(
"planar_terrain_height",
[point_position],
[point_position[2]],
[self.get_point_position_name()],
["point_height"],
self._options,
)

def create_normal_direction_function(self) -> cs.Function:
point_position = cs.MX.sym(self.get_point_position_name(), 3)

return cs.Function(
"planar_terrain_normal",
[point_position],
[cs.MX.eye(3)[:, 2]],
[self.get_point_position_name()],
["normal_direction"],
self._options,
)

def create_orientation_function(self) -> cs.Function:
point_position = cs.MX.sym(self.get_point_position_name(), 3)

return cs.Function(
"planar_terrain_orientation",
[point_position],
[cs.MX.eye(3)],
[self.get_point_position_name()],
["plane_rotation"],
self._options,
)

0 comments on commit c025e22

Please sign in to comment.