erwincoumans / motion_imitation

Code accompanying the paper "Learning Agile Robotic Locomotion Skills by Imitating Animals"
Apache License 2.0
1.17k stars 292 forks source link

fix sensor.py bug #11

Closed FrankTianTT closed 4 years ago

FrankTianTT commented 4 years ago

Hi, thank you for your brilliant job. I find a small bug in the class BoxSpaceSensor in sensor.py, as follows

if isinstance(lower_bound, float):
      self._lower_bound = np.full(shape, lower_bound, dtype=dtype)
    else:
      self._lower_bound = np.array(lower_bound)

but in the class BasePositionSensor in robot_sensors.py, the default parameters of constructor are

  def __init__(self,
               lower_bound: _FLOAT_OR_ARRAY = -100,
               upper_bound: _FLOAT_OR_ARRAY = 100,
               name: typing.Text = "BasePosition",
               dtype: typing.Type[typing.Any] = np.float64) -> None:
    """Constructs BasePositionSensor.
    Args:
      lower_bound: the lower bound of the base position of the robot.
      upper_bound: the upper bound of the base position of the robot.
      name: the name of the sensor
      dtype: data type of sensor value
    """
    super(BasePositionSensor, self).__init__(
        name=name,
        shape=(3,),  # x, y, z
        lower_bound=lower_bound,
        upper_bound=upper_bound,
        dtype=dtype)

So, you know, the result of isinstance(lower_bound, float) is False for BasePositionSensor, so BasePositionSensor._lower_bound become a float, but it should be a list, for example, [x, y, z].

So when I add sensor_wrappers.HistoricSensorWrapper(wrapped_sensor=robot_sensors.BasePositionSensor(), num_history=5) to the sensors, the observation returned by the step add 15, but env.observation_space.shape[0] only add 5!

I think it should help to correct class BoxSpaceSensor as follows

if isinstance(lower_bound, float) or isinstance(lower_bound, int):
      self._lower_bound = np.full(shape, lower_bound, dtype=dtype)
    else:
      self._lower_bound = np.array(lower_bound)

Thanks again for your outstanding work :)

googlebot commented 4 years ago

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

FrankTianTT commented 4 years ago

@googlebot I signed it!

------------------ 原始邮件 ------------------ 发件人: "googlebot"<notifications@github.com>; 发送时间: 2020年7月25日(星期六) 上午8:54 收件人: "google-research/motion_imitation"<motion_imitation@noreply.github.com>; 抄送: "田鸿龙"<franktian424@qq.com>; "Author"<author@noreply.github.com>; 主题: Re: [google-research/motion_imitation] fix sensor.py bug (#11)

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.

What to do if you already signed the CLA

Individual signers

It's possible we don't have your GitHub username or you're using a different email address on your commit. Check your existing CLA data and verify that your email is set on your git commits.

Corporate signers

Your company has a Point of Contact who decides which employees are authorized to participate. Ask your POC to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the Google project maintainer to go/cla#troubleshoot (Public version).

The email used to register you as an authorized contributor must be the email used for the Git commit. Check your existing CLA data and verify that your email is set on your git commits.

The email used to register you as an authorized contributor must also be attached to your GitHub account.

️ Googlers: Go here for more info.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

googlebot commented 4 years ago

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

erwincoumans commented 4 years ago

Thanks for the PR!