Improbable-AI / walk-these-ways

Sim-to-real RL training and deployment tools for the Unitree Go1 robot.
https://gmargo11.github.io/walk-these-ways/
Other
488 stars 129 forks source link

Gravity Vector Implementation for Deployment #58

Closed TextZip closed 6 months ago

TextZip commented 6 months ago

hi @gmargo11 thanks for the amazing repo, I keep coming back to this repo to learn many new things every time.

In the paper, the gravity vector is mentioned as one of the inputs to the policy and it is also stated that it is measured by accelerometer .. but I couldn't find a lot of details regarding the implementation of the same in the GitHub repo.

The only reference I could find to this was https://github.com/Improbable-AI/walk-these-ways/blob/f72872927db7cd76be9d3a8dba4cba4a7c1d89d1/go1_gym_deploy/utils/cheetah_state_estimator.py#L138

Where it seems the gravity vector is being set to be a constant and is not being updated from the IMU data.

Can you please explain a bit more about what is going on here, in case i am missing something ..

gmargo11 commented 6 months ago

Hi @TextZip ,

Thanks for the question, this is definitely worth clarifying!

In the get_gravity_vector function, the gravity vector is computed as grav = np.dot(self.R.T, np.array([0, 0, -1])). While the [0, 0, -1] term is constant, self.R is updated in the _imu_cb: https://github.com/Improbable-AI/walk-these-ways/blob/f72872927db7cd76be9d3a8dba4cba4a7c1d89d1/go1_gym_deploy/utils/cheetah_state_estimator.py#L279

So, every time an LCM message containing IMU data is received, _imu_cb will be triggered, and the rotation matrix should be updated, leading to a change in the gravity vector.

-Gabe