Instructions to use zhijieq/directional-navigation with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use zhijieq/directional-navigation with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("zhijieq/directional-navigation", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Directional Navigation
Directional Navigation is a MuJoCo task for moving a robot to a goal while avoiding walls and other moving robots. This repository provides both the Gymnasium environment and a policy trained for the task.
Install
The package supports Python 3.10 and newer.
python -m pip install "https://huggingface.co/zhijieq/directional-navigation/resolve/main/directional_navigation-1.0-py3-none-any.whl"
Use the environment and policy
import gymnasium as gym
from transformers import AutoModel
env = gym.make(
"directional_navigation:DirectionalNavigation-v0",
render_mode="human",
real_time_factor=1.0,
num_robots=None,
seed=None,
)
policy = AutoModel.from_pretrained(
"zhijieq/directional-navigation",
trust_remote_code=True,
)
try:
observation, _ = env.reset()
while True:
action = policy.act(observation)
observation, _, terminated, _, info = env.step(action)
if info["reason"] == "goal_reached":
print("goal_reached", flush=True)
elif terminated:
print(info["reason"], flush=True)
observation, _ = env.reset()
except KeyboardInterrupt:
pass
finally:
env.close()
Environment
Each scene takes place in a square arena with a randomly placed goal and up to 40 moving robots.
Pass num_robots to gym.make to use a fixed number of moving robots from 0
to 40. If it is omitted or set to None, the environment chooses a new random
number from 0 to 40 for each scene.
Pass seed to gym.make to reproduce a simulation. With seed=None, the
environment starts with a nondeterministic random sequence.
observation.lidar: 256 distance readings covering 360 degrees around the robot, with a maximum range of 10 m.observation.state: a 2D unit vector pointing from the robot to the goal.- Action: a 2D movement vector with each value between -1 and 1.
- Reaching the goal places a new goal without resetting the arena.
- A collision ends the current scene; call
reset()to start a new one. - Press
Enterin the MuJoCo viewer to start a new scene.
The environment also works with gym.make_vec for parallel rollouts.
Policy architecture
The policy combines the 256 LiDAR readings with the direction to the goal. The goal direction is projected to 256 features, joined with the LiDAR input, and passed through layers of 512 and 256 units with GELU activations. A final two-unit layer produces the movement direction.
- Downloads last month
- 412