Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed save video printouts #328

Open
wants to merge 52 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
c7c616b
modifies behavior_mp_env to allow planning with HLA's
NishanthJKumar Oct 10, 2021
3323fee
Merge pull request #1 from NishanthJKumar/master
NishanthJKumar Oct 10, 2021
1122a45
modifies behavior_mp_env to reveal action_exec_status
NishanthJKumar Oct 10, 2021
fb82c73
includes new tamp env for behavior to integrate with sample-based TAM…
NishanthJKumar Oct 11, 2021
f211023
add mac installation instructions
tomsilver Oct 13, 2021
71da6c9
add njk sorting books yaml
tomsilver Oct 16, 2021
b322e81
add reshelving books yaml
tomsilver Oct 18, 2021
a1c65ab
includes new grasp and navigation parameterized HLA's!
NishanthJKumar Oct 19, 2021
f1f6818
Merge pull request #2 from NishanthJKumar/behavior_planning_wrapper
NishanthJKumar Oct 20, 2021
5964228
changes to enable navigateTo option
NishanthJKumar Oct 26, 2021
d9c75b6
Merge pull request #3 from NishanthJKumar/behavior_planning_wrapper
NishanthJKumar Oct 26, 2021
6ad053b
updates to enable navigateTo option to work deterministically
NishanthJKumar Nov 4, 2021
6fb3169
Merge pull request #4 from NishanthJKumar/behavior_planning_wrapper
NishanthJKumar Nov 4, 2021
bee4e96
increases RRT search iters and removes ghost hands
NishanthJKumar Nov 9, 2021
714a624
enables passing random seed to sampling functions
NishanthJKumar Nov 9, 2021
fa9a776
minor changes to enforce seeded, predictable randomness
NishanthJKumar Nov 17, 2021
cdacb11
minor changes to try to get grasp option working
NishanthJKumar Dec 21, 2021
36f86f3
minor deletion of comment
NishanthJKumar Dec 31, 2021
7a388d4
adds minor comment to code that gets grasped objects
NishanthJKumar Dec 31, 2021
7a7d667
small change to get basic pick and place working with predicators!
NishanthJKumar Jan 1, 2022
3e6b995
adds changes that fix state reloading bug
NishanthJKumar Jan 18, 2022
7f8165d
Merge branch 'master' of https://github.com/StanfordVL/iGibson into S…
NishanthJKumar Jan 18, 2022
f182c07
Merge branch 'StanfordVL-master'. Necessary for QoL and to fix state …
NishanthJKumar Jan 18, 2022
9ad900f
Revert "Checking and maybe updating to latest changes on SVL Master"
NishanthJKumar Jan 18, 2022
493e795
Merge pull request #6 from Learning-and-Intelligent-Systems/revert-5-…
NishanthJKumar Jan 18, 2022
404a36f
updates to get load_checkpoint to correctly update visually
NishanthJKumar Jan 19, 2022
1bb2aad
minor changes to get grasping with option models working!
NishanthJKumar Jan 19, 2022
a417ff0
added behavior task and house command line arguments
Jan 22, 2022
7e18fd1
changes necessary for online_sampling to produce randomized scenes
NishanthJKumar Jan 26, 2022
74d97aa
adds random seed for placeOnTop sampler
NishanthJKumar Jan 27, 2022
6cd759f
changes to dynamically edit online_sampling
NishanthJKumar Jan 28, 2022
a6c4fda
removed unnecessary print
NishanthJKumar Jan 28, 2022
31122fa
minor changes to get online sampling working!
NishanthJKumar Jan 29, 2022
08365c0
minor changes for behavior hacking/debugging
wmcclinton May 30, 2022
fa2326c
removes lots of unnecessary prints
NishanthJKumar Jul 15, 2022
e9f3d6f
Modifies onTop classifier to work correctly for 'shelf' category
NishanthJKumar Sep 11, 2022
9fec253
modify opengl variable name in shader
NishanthJKumar Sep 16, 2022
cdc5377
gitignore update
NishanthJKumar Sep 16, 2022
ce75e2d
commented out lines that cause bug
NishanthJKumar Sep 16, 2022
599a566
change the way modify_config_file works
NishanthJKumar Sep 28, 2022
9b8cb60
changes naming to actually be unique
NishanthJKumar Sep 28, 2022
1c9d6e8
uncomments lines necessary for viz
NishanthJKumar Oct 7, 2022
ad30a13
prevents error from setting simulator viewer
NishanthJKumar Oct 7, 2022
7a59eb4
Fix isinstance check for multiobject state data load
jorge-a-mendez Oct 7, 2022
768b4ea
Fix OpenGL shading language version
jorge-a-mendez Oct 7, 2022
dc92386
remove sampling rejection printouts
NishanthJKumar Oct 14, 2022
eb7461c
added save-video functionality
kathrynle20 Mar 30, 2023
77bd079
save video works
kathrynle20 Apr 5, 2023
e602598
feedback
NishanthJKumar Apr 18, 2023
171eafd
feedback
NishanthJKumar Apr 18, 2023
7c39e57
fixes
NishanthJKumar Apr 18, 2023
6b4b54f
deleted filename printing
kathrynle20 Apr 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
adds changes that fix state reloading bug
NishanthJKumar committed Jan 18, 2022
commit 3e6b99539e3d2891c23503c5011abd490792a92b
10 changes: 7 additions & 3 deletions igibson/utils/checkpoint_utils.py
Original file line number Diff line number Diff line change
@@ -4,6 +4,8 @@

import pybullet as p

from igibson.utils.utils import restoreState


def save_task_relevant_state(env, root_directory, filename="behavior_dump"):
json_path = os.path.join(root_directory, f"{filename}.json")
@@ -12,31 +14,33 @@ def save_task_relevant_state(env, root_directory, filename="behavior_dump"):
with open(json_path, "w") as f:
json.dump(save_task_relevant_object_and_robot_states(env), f)


def save_sim_urdf_object_state(sim, root_directory, filename="behavior_dump"):
json_path = os.path.join(root_directory, f"{filename}.json")

# Save the dump in a file.
with open(json_path, "w") as f:
json.dump(save_all_scene_object_and_robot_states(sim), f)


def save_checkpoint(simulator, root_directory):
bullet_path = os.path.join(root_directory, "%d.bullet" % simulator.frame_count)
json_path = os.path.join(root_directory, "%d.json" % simulator.frame_count)

# Save the simulation state.
p.saveBullet(bullet_path)

# Save the dump in a file.
with open(json_path, "w") as f:
json.dump(save_internal_states(simulator), f)
return simulator.frame_count


def load_checkpoint(simulator, root_directory, frame):
bullet_path = os.path.join(root_directory, "%d.bullet" % frame)
json_path = os.path.join(root_directory, "%d.json" % frame)

# Restore the simulation state.
p.restoreState(fileName=bullet_path)
# p.restoreState(fileName=bullet_path)
restoreState(fileName=bullet_path)

with open(json_path, "r") as f:
dump = json.load(f)
35 changes: 33 additions & 2 deletions igibson/utils/utils.py
Original file line number Diff line number Diff line change
@@ -3,8 +3,7 @@

import numpy as np

# The function to retrieve the rotation matrix changed from as_dcm to as_matrix in version 1.4
# We will use the version number for backcompatibility
import pybullet as p
import scipy
import yaml
from packaging import version
@@ -201,3 +200,35 @@ def brighten_texture(input_filename, output_filename, brightness=1):
img = np.clip(img * brightness, 0, 255)
img = img.astype(np.uint8)
Image.fromarray(img).save(output_filename)


def restoreState(*args, **kwargs):
"""Restore to a given pybullet state, with a mitigation for a known sleep state restore bug.
When the pybullet state is restored, the object's wake zone (the volume around the object where
if any other object enters, the object should be waken up) does not get reset correctly,
causing weird bugs around asleep objects. This function mitigates the issue by forcing the
sleep code to update each object's wake zone.
"""
p.restoreState(*args, **kwargs)
for body_id in range(p.getNumBodies()):
p.resetBasePositionAndOrientation(
body_id, *p.getBasePositionAndOrientation(body_id), physicsClientId=kwargs.get("physicsClientId", 0)
)
return p.restoreState(*args, **kwargs)


def let_user_pick(options, print_intro=True, random_selection=False):
if print_intro and not random_selection:
print("Please choose:")
for idx, element in enumerate(options):
print("{}) {}".format(idx + 1, element))
if not random_selection:
i = input("Enter number: ")
else:
i = random.choice(range(len(options))) + 1
try:
if 0 < int(i) <= len(options):
return int(i)
except:
pass
return None