Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
7f732bb
added metadata
maple5717 Apr 22, 2024
6bc4adf
utils
maple5717 Apr 23, 2024
92d4b78
merged (with change in metadata)
maple5717 Apr 24, 2024
4e4d300
Merge branch 'main' of https://github.com/jiaming-ai/foundation-phy i…
maple5717 Apr 24, 2024
bcea1ab
merged again
maple5717 Apr 24, 2024
fc3732b
merge new
maple5717 Apr 24, 2024
00aa092
Merge branch 'main-new' into main
maple5717 Apr 24, 2024
7bf4d29
collision
maple5717 Apr 24, 2024
2cc1f70
solidity
maple5717 Apr 24, 2024
39efe42
support
maple5717 Apr 24, 2024
e718c2e
continuity scene rendering
maple5717 Apr 24, 2024
75b14be
Merge branch 'main' of https://github.com/jiaming-ai/foundation-phy i…
maple5717 Apr 24, 2024
67eea5c
fixed object rotation in continuity scene
maple5717 Apr 25, 2024
09144c8
fixed object rotation problem in continuty scene
maple5717 Apr 25, 2024
3e1dfe5
recovered pybullet file
maple5717 Apr 25, 2024
c781f7d
Merge branch 'main' of https://github.com/jiaming-ai/foundation-phy i…
maple5717 Apr 25, 2024
e38d10e
added back camera
maple5717 Apr 26, 2024
8ad2bae
readme
maple5717 Apr 26, 2024
62d9860
added watch file
maple5717 Apr 26, 2024
30640af
Merge branch 'main' of https://github.com/jiaming-ai/foundation-phy i…
maple5717 May 2, 2024
af30417
deleted some weird tables
maple5717 May 2, 2024
b9c4d32
check scene with both cameras
maple5717 May 2, 2024
d1b5ccb
supported rendering with two cameras
maple5717 May 2, 2024
3e22ef9
run
maple5717 May 2, 2024
9a50c05
fixed the view problem of the alternative camera
maple5717 May 3, 2024
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
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,21 @@ python fy/run_tiancheng.py --save_states True --debug True
```
python fy/run_tiancheng.py --save_states False --debug False

```

```
python fy/run_tiancheng.py --save_states --debug --render_non_violate_video --test_scene_cls 100

```

```
python fy/run_tiancheng.py --render_non_violate_video --test_scene_cls 100
```

```
python fy/run_tiancheng.py --debug --save_states --test_scene_cls 100
```
run with watch
```
python fy/run_watch_tiancheng.py
```
80 changes: 68 additions & 12 deletions fy/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ def _set_camera_path(self, path_config):
key_frame_val = path_config["key_frame_val"]

camera = bpy.data.objects['camera']


bpy.ops.curve.primitive_bezier_circle_add(enter_editmode=False,
align='WORLD',
location=center,
Expand Down Expand Up @@ -293,6 +295,7 @@ def _set_camera_path(self, path_config):
keyframe.interpolation = 'CUBIC'
keyframe.easing='EASE_IN_OUT'

camera.location = [0,0,0]
return path_con

def _set_camera_focus_point(self, look_at=[0,0,0]):
Expand Down Expand Up @@ -356,27 +359,77 @@ def prepare_scene(self):
self.static_objs = []

self._setup_everything()
if self._check_scene():
if self._check_scene_with_all_cameras():
self.generate_keyframes()
return
logging.warning("Current scene is invalid. Regenerating ")
# self.renderer.save_state(f"temp_scene/invalid_{self.i}.blend")
self.renderer.save_state(f"temp_scene/invalid_{self.i}.blend")
self.i += 1

if self.is_move_camera:
self.camera_path_sample_stats[self.cur_camera_traj_idx] += 1
logging.info(f"Re-sampling... Current stats: {self.camera_path_sample_stats}")

def _check_scene_with_all_cameras(self):
"""Check if the scene is valid for all the cameras. Return Flase if the scene is invalid.
TODO: implement (Override) this function

Returns:
_type_: _description_
"""
# self.scene.camera.position = self.default_camera_pos
# self.scene.camera.look_at(self.camera_look_at)
print("checking camera view 1")
self._switch_to_view1()
if not (self._check_scene()):
logging.warning("Check scene failed with Camera View 1")
return False

if not self.flags.render_multiview:
return True

print("checking camera view 2")
self._switch_to_view2()
if self._check_scene():
# change back to the front camera
self._switch_to_view1()
return True
else:
logging.warning("Check scene failed with Camera View 2")
return False

def _switch_to_view1(self):
cam = bpy.data.objects["camera"]

if self.is_move_camera:
self.scene.camera.position = [0,0,0]
self.scene.camera.rotation_quaternion = [1,0,0,0]
else:
self.scene.camera.position = self.default_camera_pos
self.scene.camera.look_at(self.camera_look_at)


for c in cam.constraints:
c.mute = False


def _switch_to_view2(self):
cam = bpy.data.objects["camera"]
for c in cam.constraints:
c.mute = True

self.scene.camera.position = self.alternative_camera_pos
self.scene.camera.look_at(self.alternative_camera_look_at)

def _check_scene(self):
"""Check if the scene is valid. Return Flase if the scene is invalid.
TODO: implement (Override) this function
"""Check if the scene is valid Return Flase if the scene is invalid.
TODO: implement (Override) this function

Returns:
_type_: _description_
"""
return True
# return self._check_scene_visible()

Returns:
_type_: _description_
"""

return True

def __enter__(self):
return self
Expand Down Expand Up @@ -540,9 +593,11 @@ def _setup_indoor_scene(self,
set_name(self.table_name)
self.ref_h = table_h
self.default_camera_pos[2] += table_h
self.alternative_camera_pos[2] += table_h
self.table_id = table_id
# print(self.table_id)
self.camera_look_at = [0, 0, self.ref_h]
self.alternative_camera_look_at = [0, 0, self.ref_h]

self.rng = rng
self.output_dir = output_dir
Expand Down Expand Up @@ -939,8 +994,9 @@ def render_alternative_view(self, save_to_file=False, **kwargs):
_type_: _description_
"""
self.load_non_violation_scene() # only used for non-violation scene
self.scene.camera.position = self.alternative_camera_pos
self.scene.camera.look_at(self.alternative_camera_look_at)
# self.scene.camera.position = self.alternative_camera_pos
# self.scene.camera.look_at(self.alternative_camera_look_at)
self._switch_to_view2()
data_stack = self.renderer.render(return_layers=self.render_data)
if save_to_file:
kb.write_image_dict(data_stack, self.output_dir, **kwargs)
Expand Down
4 changes: 0 additions & 4 deletions fy/configs/tables.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@
04379243/bbae4abbff206a2a14038d588fd1342f
04379243/c4388c59f863de596edd3f7982f0bf26
04379243/c7358b3aed4160cb21bc3cf138f79e
04379243/6ab7ebf9b94176456f1e07a56c129dfc
04379243/6f019fe6ab60a3e37b11ae648ea92233
04379243/fe0e7198411fc340c057222d6d091c56
04379243/f0cee441d88de6dafebad4f49b26ec52
Expand All @@ -162,9 +161,7 @@
04379243/87ca3e8e37367054dcabaa2ad147fa73
04379243/9d71f9424fc659e17a50afc9c93f8a50
04379243/97bda10740c4a74036b0f2a1430e993a
04379243/b14c4d5783a339609fd4171283f33ca8
04379243/a4dbf0f4fef1c36cf199233c9f2ce2ce
04379243/726164afa497b154b075b4c36d25279a
04379243/a99a74777f6aacf2489e5619471f9f53
04379243/f64617385056e0b1beedb4c8fd29e2d1
04379243/fe99a1127734f7852b70eac6546e93fd
Expand Down Expand Up @@ -851,7 +848,6 @@
04379243/8839cf79a5338a568ce66f12ba927a2b
04379243/be5501adc4564d9edf30786b8faddb78
04379243/f80cce35d167ff9b855931d119219022
04379243/9a71b92445cd3f023a9bc242c86fb7a0
04379243/ae5ac5b2b027fcf9118ddfdb81cc6068
04379243/6f576d151a46bdefd5cb6d178687b980
04379243/8768002c872788b8e513931a191fd77c
Expand Down
Loading