Skip to content

Commit

Permalink
[gym/common] Add 'DeformationEstimator' block.
Browse files Browse the repository at this point in the history
  • Loading branch information
duburcqa committed Mar 3, 2024
1 parent f39e6c7 commit a0f99dc
Show file tree
Hide file tree
Showing 16 changed files with 1,244 additions and 67 deletions.
2 changes: 1 addition & 1 deletion core/src/control/abstract_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ namespace jiminy
{ return element.first == *fieldIt; });
if (variableIt != registeredVariables.end())
{
THROW_ERROR(lookup_error, "Variable already registered.");
THROW_ERROR(lookup_error, "Variable '", *fieldIt, "' already registered.");
}
registeredVariables.emplace_back(*fieldIt, &values[i]);
}
Expand Down
28 changes: 14 additions & 14 deletions data/toys_models/ant/ant_hardware.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,6 @@ contactFrameNames = [] #['tip_1', 'tip_2', 'tip_3', 'tip_4']

# ============== Motors ===============

[Motor.SimpleMotor.hip_4]
joint_name = "hip_4"
mechanicalReduction = 150.0
armature = 1.0
frictionViscousPositive = -1.0
frictionViscousNegative = -1.0

[Motor.SimpleMotor.ankle_4]
joint_name = "ankle_4"
mechanicalReduction = 150.0
armature = 1.0
frictionViscousPositive = -1.0
frictionViscousNegative = -1.0

[Motor.SimpleMotor.hip_1]
joint_name = "hip_1"
mechanicalReduction = 150.0
Expand Down Expand Up @@ -63,6 +49,20 @@ armature = 1.0
frictionViscousPositive = -1.0
frictionViscousNegative = -1.0

[Motor.SimpleMotor.hip_4]
joint_name = "hip_4"
mechanicalReduction = 150.0
armature = 1.0
frictionViscousPositive = -1.0
frictionViscousNegative = -1.0

[Motor.SimpleMotor.ankle_4]
joint_name = "ankle_4"
mechanicalReduction = 150.0
armature = 1.0
frictionViscousPositive = -1.0
frictionViscousNegative = -1.0

# ============= Encoder sensors ===============

[Sensor.EncoderSensor.hip_1]
Expand Down
5 changes: 1 addition & 4 deletions python/gym_jiminy/common/gym_jiminy/common/bases/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import gymnasium as gym

from ..utils import FieldNested, DataNested, get_fieldnames, fill, zeros
from ..utils import FieldNested, DataNested, get_fieldnames, zeros

from .generic import (ObsT,
ActT,
Expand Down Expand Up @@ -159,9 +159,6 @@ def _setup(self) -> None:
# Compute the update period
self.observe_dt = self.env.observe_dt * self.update_ratio

# Set default observation
fill(self.observation, 0)

# Make sure the controller period is lower than environment timestep
assert self.observe_dt <= self.env.step_dt, (
"The observer update period must be lower than or equal to the "
Expand Down
14 changes: 7 additions & 7 deletions python/gym_jiminy/common/gym_jiminy/common/bases/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from jiminy_py.simulator import Simulator
from jiminy_py.viewer.viewer import is_display_available

from ..utils import DataNested, fill
from ..utils import DataNested


# Temporal resolution of simulator steps
Expand Down Expand Up @@ -155,7 +155,7 @@ def compute_reward(self,
:returns: Aggregated reward for the current step.
"""
raise NotImplementedError
return 0.0


# Note that `InterfaceJiminyEnv` must inherit from `InterfaceObserver`
Expand Down Expand Up @@ -220,10 +220,6 @@ def _setup(self) -> None:
# The observation must always be refreshed after setup
self.__is_observation_refreshed = False

# Reset observation and action buffers
fill(self.observation, 0)
fill(self.action, 0)

@no_type_check
def _observer_handle(self,
t: float,
Expand Down Expand Up @@ -259,7 +255,11 @@ def _observer_handle(self,
sensor_measurements_it = iter(sensor_measurements.values())
for sensor_type in self._sensors_types:
measurement_sensors[sensor_type] = next(sensor_measurements_it)
self.refresh_observation(measurement)
try:
self.refresh_observation(measurement)
except RuntimeError as e:
raise RuntimeError(
"The observation space must be constant.") from e
self.__is_observation_refreshed = True

def _controller_handle(self,
Expand Down
2 changes: 2 additions & 0 deletions python/gym_jiminy/common/gym_jiminy/common/blocks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
from .mahony_filter import MahonyFilter
from .motor_safety_limit import MotorSafetyLimit
from .proportional_derivative_controller import PDController
from .deformation_estimator import DeformationEstimator


__all__ = [
'MahonyFilter',
'MotorSafetyLimit',
'PDController',
'DeformationEstimator'
]

0 comments on commit a0f99dc

Please sign in to comment.