Skip to content

Commit a9c8df5

Browse files
aclegg3aihabitat
andauthored
Migrate habitat-lab to habitat-sim agent-sensor-decoupling API (#2220)
* Migrate habitat-lab to habitat-sim agent-sensor-decoupling API Adapt habitat-lab to the new public sensor API from habitat-sim PR #2621 (agent-sensor-decoupling branch). Key changes: - Replace all private _sensors dict access with public sim.sensors property - Replace _sim._sensors[name]._sensor_object with sim.get_sensor(name).sensor_object - Replace agent._sensors with agent.sensors (live C++ subtree view) - Simplify instance_image_nav_task sensor lifecycle to use sim.remove_sensor() instead of manual multi-dict cleanup - Remove Python name-mangling (_Simulator__sensors) from debug_visualizer and its tests; use sim.sensors registry directly - Update CI workflow to build habitat-sim from the PR branch Companion to: facebookresearch/habitat-sim#2621 --------- Co-authored-by: Alexander William Clegg <alexclegg@meta.com>
1 parent 8c403d6 commit a9c8df5

File tree

19 files changed

+62
-70
lines changed

19 files changed

+62
-70
lines changed

.github/actions/install_ubuntu_deps/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ runs:
4848
uses: conda-incubator/setup-miniconda@v3.0.1
4949
with:
5050
miniconda-version: "latest"
51-
python-version: "3.12"
51+
python-version: "3.11"
5252
activate-environment: "habitat"
5353
- name: Install conda and dependencies
5454
run: |-

.github/workflows/install_and_test.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,13 @@ jobs:
7676
#activate conda env
7777
export PATH=$HOME/miniconda/bin:/usr/local/cuda/bin:$PATH
7878
conda activate habitat
79-
#install habitat-sim
79+
#install habitat-sim from nightly conda
80+
conda install -y -c conda-forge -c aihabitat-nightly habitat-sim headless withbullet
81+
#clone habitat-sim repo for test data and benchmark scripts
8082
if [ ! -d ./habitat-sim ]
8183
then
8284
git clone https://github.com/facebookresearch/habitat-sim.git --recursive
8385
fi
84-
cd habitat-sim
85-
pip install -r requirements.txt --progress-bar off
86-
git submodule update --init --recursive --jobs 8
87-
python -u setup.py install --headless --with-cuda --bullet
8886
- name: Download test data
8987
run: |
9088
# Disable clone protection for git lfs
@@ -182,7 +180,7 @@ jobs:
182180
uses: conda-incubator/setup-miniconda@v3.0.1
183181
with:
184182
miniconda-version: "latest"
185-
python-version: "3.12"
183+
python-version: "3.11"
186184
activate-environment: "non-editable-install"
187185
- name: Ensure non-editable mode works
188186
run: |-
@@ -214,7 +212,7 @@ jobs:
214212
uses: conda-incubator/setup-miniconda@v3.0.1
215213
with:
216214
miniconda-version: "latest"
217-
python-version: "3.12"
215+
python-version: "3.11"
218216
activate-environment: "bdist-install"
219217
- name: Ensure bdist install works and build sdist
220218
run: |-

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ repos:
2222
args: ['--fix=lf']
2323

2424
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
25-
rev: v2.3.0
25+
rev: v2.14.0
2626
hooks:
2727
- id: pretty-format-ini
2828
args: [--autofix]
2929
- id: pretty-format-toml
3030
args: [--autofix]
3131
additional_dependencies:
32-
- toml-sort==0.21.0
32+
- toml-sort==0.23.1
3333

3434
- repo: https://github.com/pre-commit/pygrep-hooks
3535
rev: v1.9.0 # Use the ref you want to point at

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ RUN ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake
3838
RUN cmake --version
3939

4040
# Conda environment
41-
RUN conda create -n habitat python=3.9 cmake=3.14.0
41+
RUN conda create -n habitat python=3.12 cmake=3.28
4242

4343
# Setup habitat-sim
44-
RUN git clone --branch stable https://github.com/facebookresearch/habitat-sim.git
45-
RUN /bin/bash -c ". activate habitat; cd habitat-sim; pip install -r requirements.txt; python setup.py install --headless"
44+
RUN git clone --branch stable https://github.com/facebookresearch/habitat-sim.git --recursive
45+
RUN /bin/bash -c ". activate habitat; cd habitat-sim; pip install -r requirements.txt; HABITAT_BUILD_GUI_VIEWERS=OFF pip install . --no-build-isolation"
4646

4747
# Install challenge specific habitat-lab
4848
RUN git clone --branch stable https://github.com/facebookresearch/habitat-lab.git

examples/hitl/rearrange_v2/rearrange_v2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ def __init__(
622622
agent_cfg = rearrange_v2_config.agents[agent_index]
623623
head_sensor_substring = agent_cfg.head_sensor_substring
624624
agent_name = sim.agents_mgr.get_agent_name_from_index(agent_index)
625-
for sensor_name, sensor in sim_agent._sensors.items():
625+
for sensor_name, sensor in sim_agent.sensors.items():
626626
if (
627627
isinstance(sensor, VisualSensor)
628628
and agent_name in sensor_name

examples/interactive_play.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,9 @@ def update(self, env, step_result, update_idx):
450450
trans = mn.Matrix4.from_(
451451
quat.to_matrix(), mn.Vector3(*self._free_xyz)
452452
)
453-
env._sim._sensors[
453+
env._sim.get_sensor(
454454
"third_rgb"
455-
]._sensor_object.node.transformation = trans
455+
).sensor_object.node.transformation = trans
456456
step_result = env._sim.get_sensor_observations()
457457
return step_result
458458
return step_result

habitat-hitl/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Example HITL apps are configured to run at 30 steps per second (SPS). If your sy
3333
* The HITL framework depends on the `habitat-lab` and `habitat-baselines` packages. While these packages are in the same repository as the HITL framework, it's not strictly necessary for the HITL framework to import the packages that live in th- [Human-in-the-loop (HITL) Framework](#human-in-the-loop-hitl-framework)
3434
3. Install Habitat-sim [main branch](https://github.com/facebookresearch/habitat-sim).
3535
* [Build from source](https://github.com/facebookresearch/habitat-sim/blob/main/BUILD_FROM_SOURCE.md), or install the [conda packages](https://github.com/facebookresearch/habitat-sim#recommended-conda-packages).
36-
* Be sure to include Bullet physics, e.g. `python setup.py install --bullet`.
36+
* Be sure to include Bullet physics, e.g. `HABITAT_WITH_BULLET=ON pip install . --no-build-isolation` or `./build.sh --with-bullet`.
3737
4. Install the `habitat-hitl` package.
3838
* From the `habitat-lab` root directory, run `pip install -e habitat-hitl`.
3939
5. Download required assets for our example HITL applications (Note that the dataset downloader should be run from habitat-lab/.):

habitat-lab/habitat/articulated_agents/articulated_agent_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def __init__(
7777
if hasattr(self.params, "cameras"):
7878
self._cameras = defaultdict(list)
7979
for camera_prefix in self.params.cameras:
80-
for sensor_name in self._sim._sensors:
80+
for sensor_name in self._sim.sensors:
8181
if sensor_name.startswith(camera_prefix):
8282
self._cameras[camera_prefix].append(sensor_name)
8383

habitat-lab/habitat/articulated_agents/humanoids/kinematic_humanoid.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def update(self) -> None:
201201
# update the cameras
202202
for cam_prefix, sensor_names in self._cameras.items():
203203
for sensor_name in sensor_names:
204-
sens_obj = self._sim._sensors[sensor_name]._sensor_object
204+
sens_obj = self._sim.get_sensor(sensor_name).sensor_object
205205
cam_info = self.params.cameras[cam_prefix]
206206

207207
if cam_info.attached_link_id == -1:

habitat-lab/habitat/articulated_agents/manipulator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def __init__(
7171
if hasattr(self.params, "cameras"):
7272
self._cameras = defaultdict(list)
7373
for camera_prefix in self.params.cameras:
74-
for sensor_name in self._sim._sensors:
74+
for sensor_name in self._sim.sensors:
7575
if sensor_name.startswith(camera_prefix):
7676
self._cameras[camera_prefix].append(sensor_name)
7777

@@ -149,7 +149,7 @@ def update(self) -> None:
149149
# update the cameras
150150
for cam_prefix, sensor_names in self._cameras.items():
151151
for sensor_name in sensor_names:
152-
sens_obj = self._sim._sensors[sensor_name]._sensor_object
152+
sens_obj = self._sim.get_sensor(sensor_name).sensor_object
153153
cam_info = self.params.cameras[cam_prefix]
154154

155155
if cam_info.attached_link_id == -1:

0 commit comments

Comments
 (0)