A library for dynamic obstacle management in Habitat-Sim simulations
Project description
Habitat Obstacle Tools
A Python library for dynamic obstacle management in Habitat-Sim simulations.
Features
- Dynamic object management: Spawn, move, and remove obstacles at runtime
- Multiple coordinate frames: World (Habitat), robot current, robot start frames
- Physics properties: Mass, friction, restitution, motion types (DYNAMIC/KINEMATIC/STATIC)
- Object library: Includes basic test objects (chair, sphere, donut); supports additional object datasets
- Interactive control: Terminal keyboard control with real-time visualization
- Event-driven: Pre-configured object spawn/move events via YAML configuration
Installation
Core Package
pip install habitat-obstacle-tools
Habitat-Sim Installation
This library requires habitat-sim to be installed separately, as it is not available on PyPI and must be built from source or installed via conda:
Option 1: Conda (Recommended)
conda create -n habitat python=3.9
conda activate habitat
conda install habitat-sim -c conda-forge -c aihabitat
Option 2: Build from Source Follow the Habitat-Sim installation instructions
Dependencies
The package installs these dependencies automatically:
numpy
Quick Start
from habitat_obstacle_tools import (
spawn_object, move_object, PhysicsProperties, MotionType, ReferenceFrame
)
# Spawn a chair at world coordinates (1, 0, 2)
obj = spawn_object(sim, "chair", position=(1, 0, 2))
# Spawn a sphere 2 meters in front of the robot
obj2 = spawn_object(
sim,
obj_source="sphere",
position=(0, 0, -2), # Forward is -Z direction
frame="robot"
)
# Move object to new position
move_object(obj, sim, position=(3, 0, 5))
# Use verbose to see coordinate transforms
obj3 = spawn_object(sim, "chair", position=(0, 0, -2), frame="robot", verbose=True)
# prints: [spawn] 'chair' at frame=robot local=(0.000, 0.000, -2.000) -> world=(...)
Coordinate Frames
| Frame | Description | Usage |
|---|---|---|
habitat |
World coordinate system | Absolute positions |
robot |
Robot's current position as origin | Relative to robot, forward is -Z |
robot_start |
Robot's start position as origin | Relative to start position |
Motion Types
| Type | Description | Collision Detection | Use Case |
|---|---|---|---|
DYNAMIC |
Controlled by physics engine, affected by gravity and collisions | Requires manual NavMesh updates | Movable objects |
KINEMATIC |
Can be moved via code, not affected by physics | None | Animated objects |
STATIC |
Completely static, immovable | Automatic (with update_navmesh=True) |
Fixed obstacles |
Configuration
See config.yaml for complete configuration examples:
scene:
glb: "/path/to/scene.glb"
navmesh: "/path/to/scene.navmesh"
object_events:
- step: 5
action: "spawn"
obj_source: "chair"
position: [0.0, 0.0, -2.0]
frame: "robot"
physics:
mass: 5.0
motion_type: "static"
interactive_objects:
- name: "chair"
obj_source: "chair"
physics: { mass: 5.0, motion_type: "static" }
Interactive Test
Run the interactive test application:
python -m habitat_obstacle_tools.test_interactive --config config.yaml
Controls:
W/↑: Move forwardS/↓: Move backwardA/←: Turn leftD/→: Turn right1-9: Spawn preset objects 2m in front of robotM: Move most recently spawned object to robot's right sideQ/ESC: Exit and save video
Additional Object Libraries
The package includes basic objects (chair, sphere, donut). For more objects, download from the official Habitat datasets and register the directory:
| Dataset | Objects | Source |
|---|---|---|
| YCB | 77 everyday objects | YCB Benchmarks |
| OVMM | 2540+ objects | Habitat OVMM |
from habitat_obstacle_tools import add_object_dir
# Point to your downloaded object configs
add_object_dir("/path/to/ycb/configs")
add_object_dir("/path/to/ovmm/ai2thorhab/configs/objects")
Or set the HABITAT_OBJECTS_DIR environment variable:
export HABITAT_OBJECTS_DIR=/path/to/your/objects
API Reference### Core Functions
spawn_object()- Create object in simulatormove_object()- Move existing object to new poserecompute_navmesh()- Recompute navigation mesh for collision detectionparse_physics()- Parse physics properties from dictionary
Types
MotionType- Enum: DYNAMIC, KINEMATIC, STATICPhysicsProperties- Dataclass for physical propertiesReferenceFrame- Enum: HABITAT, ROBOT, ROBOT_START
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file habitat_obstacle_tools-0.1.0.tar.gz.
File metadata
- Download URL: habitat_obstacle_tools-0.1.0.tar.gz
- Upload date:
- Size: 239.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4999c0aebad0e65db02e791f3e074f60da45b5cb274f21e6157b24a48d7fb3ad
|
|
| MD5 |
43d4868b1842a80189f21d96d47cd065
|
|
| BLAKE2b-256 |
f7db4d9b05e6ed65702c895f79d7d6ce6aa646cd2915eb60e236dd9ea23375a1
|
File details
Details for the file habitat_obstacle_tools-0.1.0-py3-none-any.whl.
File metadata
- Download URL: habitat_obstacle_tools-0.1.0-py3-none-any.whl
- Upload date:
- Size: 233.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9430f41d9f153c21f568e9e76cfb28ef6dfc38ec8463f32ef9288b8ad9354f97
|
|
| MD5 |
a567ebdcde3fbef9cdd48888a88999a7
|
|
| BLAKE2b-256 |
84ed3d81b2333bbc1bdb4cc664e29380304151ea9359b31ae49f7fdc29bb3077
|