How to freeze Bullet simulation between two env.step ? #425
-
Hello, The following example illustrates my point. In the time interval (1s) between two env.step the robot falls (simulation side). So that when the second env.step is called, the episode is terminated. But I don't want the robot's state to change between two env.step, as if only 1/frequency seconds had elapsed. import gymnasium as gym
import numpy as np
import upkie.envs
import time
upkie.envs.register()
with gym.make("UpkieGroundVelocity-v3", frequency=200.0) as env:
observation, _ = env.reset()
gain = np.array([10.0, 1.0, 0.0, 0.1])
for step in range(1_000_000):
action = gain.dot(observation).reshape((1,))
observation, reward, terminated, truncated, _ = env.step(action)
time.sleep(1.0)
if terminated or truncated:
break Thank you in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
For this purpose you can run the simulation with the Using the simulation script./start_simulation.sh --show --nb-substeps 5 I've just pushed this update in 11f4f93 so make sure you Under the hood: using Bazel$ ./tools/bazelisk run //spines:bullet_spine -- --show --nb-substeps 5 You can also check out all available options by: $ ./tools/bazelisk run //spines:bullet_spine -- --help
INFO: ...
Optional arguments:
-h, --help
Print this help and exit.
--log-dir <path>
Path to a directory for output logs.
--nb-substeps <k>
Number of simulation steps per action. Makes spine pausing.
--shm-name <name>
Name for IPC shared memory file.
--show
Show the Bullet GUI.
--space
No ground, no gravity, fly like an eagle!
--extra-urdf-path
Load extra URDFs into the environment.
--spine-frequency <frequency>
Spine frequency in Hertz (default: 1000 Hz).
--robot-variant <variant>
Robot variant (default: '').
-v, --version
Print out the spine version number. |
Beta Was this translation helpful? Give feedback.
For this purpose you can run the simulation with the
--nb-substeps
parameters. For instance, if the simulation spine runs at 1,000 Hz (default) and the agent runs at 200 Hz as in your example, you should set--nb-substeps 5
:Using the simulation script
./start_simulation.sh --show --nb-substeps 5
I've just pushed this update in 11f4f93 so make sure you
git pull
before trying this 👆Under the hood: using Bazel
$ ./tools/bazelisk run //spines:bullet_spine -- --show --nb-substeps 5
You can also check out all available options by: