How can I get started using the UpkieGroundVelocity environment? #15
-
Asked by @perrin-isir in #11:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
That's one way to go. I can imagine two ways for now:
The idea of option 2 is that, once the spine is running, the Python gym env runs in a separate process that doesn't depend on much (all the C++ dependencies that lead to vulp are managed by Bazel on the spine side). We could therefore have a workflow like:
cd upkie
./tools/bazelisk run //spines:bullet -c opt -- --nb-substeps 5 --show
pip install upkie
cd my_python_code
python ./train.py # only depends on upkie_envs Which option do you think is preferable? |
Beta Was this translation helpful? Give feedback.
-
Here is a simple example (edit: updated to Upkie 3.4.0): import gymnasium as gym
import upkie.envs
upkie.envs.register()
if __name__ == "__main__":
env = gym.make("UpkieGroundVelocity-v3")
observation = env.reset(seed=42)
action = env.action_space.sample()
for step in range(1_000_000):
observation, reward, done, _, _ = env.step(action)
if done:
observation = env.reset()
pitch = observation[0]
action[0] = 10.0 * pitch
env.close() Start the pi3hat/simulation spine in a separate process before running this script: $ ./tools/bazelisk run //spines:bullet -c opt -- --nb-substeps 5 --show Otherwise the script will let you know that the spine is not running. |
Beta Was this translation helpful? Give feedback.
Here is a simple example (edit: updated to Upkie 3.4.0):
Start the pi3hat/simulation spine in a separate process before running this script:
$ ./tools/bazelisk run //spines:bullet -c opt -- --nb-substeps 5 --show
Otherwise the script will let you know t…