Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
410 commits
Select commit Hold shift + click to select a range
4eb9e41
--increase array key limit to 1000 elements from 100
jturner65 Apr 26, 2024
edd872e
--add rekeying to markersets after they are loaded.
jturner65 Apr 26, 2024
b6f60d9
--add MarkerSets accessors for all possible permutations
jturner65 Apr 26, 2024
b1d0cc6
--cleanup
jturner65 Apr 26, 2024
cf99b77
-- clang-tidy
jturner65 Apr 26, 2024
702ec10
--make sure we clear out existing markers before we write new ones.
jturner65 Apr 26, 2024
92fe289
--bindings for subsets, link sets
jturner65 Apr 26, 2024
74c5c8c
--Finish bindings, cleanup LinkMarkerSet
jturner65 Apr 26, 2024
761da98
--clarify rekeying
jturner65 Apr 27, 2024
75df840
--rename hierarchy components for clarity and brevity
jturner65 Apr 27, 2024
c376d90
--need to hide ArticulatedLink getScale (inherited from RigidBase)
jturner65 Apr 27, 2024
9089ebb
--transform points between object local and world points
jturner65 Apr 29, 2024
e48e2bd
Merge branch 'MarkerSubsetsHandling2' into hssd_ao_utilities
jturner65 Apr 29, 2024
4a23736
--merge wip marker handling from 'alex-04_22-marker_set_util'
jturner65 Apr 29, 2024
6e9eeb7
--missing ref
jturner65 Apr 29, 2024
85d2009
Merge branch 'MarkerSubsetsHandling2' into hssd_ao_utilities_JT
jturner65 Apr 29, 2024
7e0dc85
--return the results properly.
jturner65 Apr 29, 2024
10db06c
Merge branch 'MarkerSubsetsHandling2' into hssd_ao_utilities_JT
jturner65 Apr 29, 2024
c96b063
--move marker handling to separate function WIP
jturner65 Apr 29, 2024
a3700b3
--provide accessors to MarkerSets
jturner65 Apr 29, 2024
fabc61c
Merge branch 'MarkerSubsetsHandling2' into hssd_ao_utilities_JT
jturner65 Apr 29, 2024
705f420
-- add/remove points to markersets for selected object
jturner65 Apr 29, 2024
2e25c76
--change bindings name
jturner65 Apr 29, 2024
8483837
Merge branch 'MarkerSubsetsHandling2' into hssd_ao_utilities_JT
jturner65 Apr 29, 2024
ed188b6
--finish remove point code; simplify mouse cast
jturner65 Apr 30, 2024
59b410d
--add more existence checks
jturner65 Apr 30, 2024
1ac0a9e
Merge branch 'MarkerSubsetsHandling2' into hssd_ao_utilities_JT
jturner65 Apr 30, 2024
4a991ec
--more support and bugfixes - debug viewer for markers
jturner65 Apr 30, 2024
8241b27
--marker adding, removal, display works!
jturner65 Apr 30, 2024
9103241
--add ability to map back to id from link name
jturner65 Apr 30, 2024
68d0ce1
--expand markerset functionality
jturner65 Apr 30, 2024
62a8281
Merge branch 'MarkerSubsetsHandling2' into hssd_ao_utilities_JT
jturner65 Apr 30, 2024
62c8370
-- implement saving function - press shift-m
jturner65 Apr 30, 2024
ca947a1
--expand bindings for markersets
jturner65 Apr 30, 2024
b25a3dc
--enable casting/templated subconfig create
jturner65 Apr 30, 2024
699bb78
--create subconfigs with appropriate type; init attrs w.empty markerset
jturner65 Apr 30, 2024
9b76720
Merge branch 'MarkerSubsetsHandling2' into hssd_ao_utilities_JT
jturner65 Apr 30, 2024
c065fe0
--handle colors better
jturner65 Apr 30, 2024
10f6526
--address occasional bugs with empty strings written to paths for sav…
jturner65 Apr 30, 2024
3a84d9a
Merge branch 'MarkerSubsetsHandling2' into hssd_ao_utilities_JT
jturner65 Apr 30, 2024
08edc82
--save config for every marker annotation add or delete
jturner65 Apr 30, 2024
472aaca
--address fix bug in marker record code.
jturner65 May 1, 2024
5697d93
--save obj init attributes unmodified by object creation process
jturner65 May 1, 2024
a1bcfc7
--explicitly state limitations of using object initialization attributes
jturner65 May 1, 2024
ed6c705
Merge branch 'MarkerSubsetsHandling2' into hssd_ao_utilities_JT
jturner65 May 1, 2024
da4d795
--Reviewer suggestions
jturner65 May 1, 2024
8c1f224
Merge branch 'MarkerSubsetsHandling2' into hssd_ao_utilities_JT
jturner65 May 1, 2024
f679ff4
--Reviewer suggestions - missed
jturner65 May 1, 2024
c4f0701
Merge branch 'MarkerSubsetsHandling2' into hssd_ao_utilities_JT
jturner65 May 1, 2024
534cf2d
--reviewer suggestion
jturner65 May 1, 2024
49123f4
Merge branch 'MarkerSubsetsHandling2' into hssd_ao_utilities_JT
jturner65 May 1, 2024
9439b3e
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 May 1, 2024
6a7e00d
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 May 3, 2024
26d1254
--cleanup functions; add task_set name selector;
jturner65 May 3, 2024
b26e0ed
--provide mechanism for correcting improper marker load locations due…
jturner65 May 6, 2024
c612c31
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 May 6, 2024
67bbd0b
refactor check_siro_scenes.py
aclegg3 May 7, 2024
be322dc
--remove early exit
jturner65 May 7, 2024
a743440
--example of getting all marker points in global coords.
jturner65 May 7, 2024
5ea91a9
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 May 8, 2024
86504d6
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 May 9, 2024
9e59f4f
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 May 13, 2024
2800637
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 May 13, 2024
9e2d629
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 May 21, 2024
e43e998
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 May 21, 2024
20f6a4d
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 May 28, 2024
da82548
--python header
jturner65 May 28, 2024
10d4297
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Jun 4, 2024
6ccd142
--move markerset handling to external utility
jturner65 Jun 4, 2024
c9aeb4e
--add object editor to utils; remove specific editing code from spot_…
jturner65 Jun 4, 2024
05eb3a0
--update viewer to use obj_editor and to be compatible with cook-surf…
jturner65 Jun 4, 2024
8195fbe
--organize draw receptacles
jturner65 Jun 4, 2024
71a10a1
--cleanup and expand object editor functions
jturner65 Jun 4, 2024
8d7ba23
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Jun 4, 2024
a49f2e8
--SpotAgent convenience class
jturner65 Jun 5, 2024
730bfc3
--strip out spot-specific code from spot-viewer
jturner65 Jun 5, 2024
cca7ab3
--uniformity
jturner65 Jun 6, 2024
c148380
--have spot_agent manage the camera modifications
jturner65 Jun 6, 2024
44fb4ea
--enable spot to disengage and re-engage the navmesh (i.e. like no_clip)
jturner65 Jun 7, 2024
bbdaed0
--stub vertical move for spot
jturner65 Jun 7, 2024
f30882e
--fix snapping to height.
jturner65 Jun 7, 2024
a352dac
--cleanup
jturner65 Jun 10, 2024
c1e598a
--add ability to add either a dupe of the sel object or a rigid/ao by…
jturner65 Jun 10, 2024
cacf75d
--fixes
jturner65 Jun 10, 2024
ce9eca0
--properly set instance user config from base passed base config.
jturner65 Jun 11, 2024
ac741a3
Merge branch 'Bugfix_InstanceFromObjConfig' into hssd_ao_utilities_JT
jturner65 Jun 11, 2024
4d1eea6
--slight improvements to adding objects
jturner65 Jun 11, 2024
18a2ba6
--properly set instance user config from base passed base config.
jturner65 Jun 11, 2024
503a2a5
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Jun 12, 2024
bed1ba6
--fix handle (template name) not being saved to scene obj/ao instance…
jturner65 Jun 13, 2024
303b441
Merge branch 'Bugfix_InstanceFromObjConfig' into hssd_ao_utilities_JT
jturner65 Jun 13, 2024
6139210
--fix handle (template name) not being saved to scene obj/ao instance…
jturner65 Jun 13, 2024
c91e5d2
Merge branch 'Bugfix_InstanceFromObjConfig' into hssd_ao_utilities_JT
jturner65 Jun 13, 2024
ae1c612
--minor fix for to-string-like capabilities
jturner65 Jun 13, 2024
c3feee9
--use simplified handle to avoid embedding paths in template names
jturner65 Jun 13, 2024
581b645
Merge branch 'Bugfix_InstanceFromObjConfig' into hssd_ao_utilities_JT
jturner65 Jun 13, 2024
6121e22
--undoing a merged-in error
jturner65 Jun 13, 2024
6218f17
--minor
jturner65 Jun 13, 2024
cb9d573
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Jun 13, 2024
be7a8d1
--add contact and region display to spot viewer
jturner65 Jun 17, 2024
885c829
--minor
jturner65 Jun 17, 2024
6ec3554
minor fixes/adustments to viewer. Minor changes to check-siro-scenes …
aclegg3 Jun 18, 2024
31da239
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Jun 20, 2024
8db031c
--fix adding new objects
jturner65 Jun 25, 2024
d0f0a5d
--don't save clutter if there is none
jturner65 Jun 25, 2024
33a18be
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Jun 26, 2024
734d004
--support multi-select/multi-edit; migrate more lab funcs to sim_util…
jturner65 Jun 26, 2024
c1526fb
--get rid of sutils in viewer.py and spot_viewer.py (migrate all the …
jturner65 Jun 26, 2024
955e81b
--moving the wrong object
jturner65 Jun 26, 2024
db00942
--remove superfluous message
jturner65 Jun 26, 2024
8c670e4
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Jun 27, 2024
f05c707
--use appropriate object duplication process
jturner65 Jul 1, 2024
9844956
--compute AO cumulative bbox on creation unconditionally.
jturner65 Jul 1, 2024
a7edb24
Merge branch 'Bugfix_AlwaysCreateAOBBox' into hssd_ao_utilities_JT
jturner65 Jul 1, 2024
2e5761c
--remove unnecessary bbox computation function
jturner65 Jul 1, 2024
ca463f8
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Jul 2, 2024
0b3cee5
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Jul 3, 2024
9fab5ed
--added 'target' selection, 'select all like tar', and 'match tar x/y…
jturner65 Jul 8, 2024
eb1ded0
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Jul 15, 2024
fb96783
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Jul 21, 2024
0cb4bf1
--update viewer to handle sim_utils updates
jturner65 Jul 21, 2024
b856314
--add marker_viewer
jturner65 Jul 21, 2024
2d3b6d1
--improve casting process
jturner65 Jul 21, 2024
2e518ea
--expand taskname support for markerset editing
jturner65 Jul 21, 2024
860b181
--minor reorg
jturner65 Jul 21, 2024
50369fd
--remove mouse grabber/grab mode
jturner65 Jul 21, 2024
7b06608
--update marker_viewer.py
jturner65 Jul 21, 2024
e4011ff
--add listing file of all urdfs
jturner65 Jul 22, 2024
bfff836
--add final remove all objects function
jturner65 Jul 22, 2024
1cadc01
--properly place agent and AO to edit
jturner65 Jul 22, 2024
3015be3
--update marker_viewer
jturner65 Jul 22, 2024
4407a4a
--handle articulated objects and rigid objects with the same name
jturner65 Jul 22, 2024
ccec0b7
--expand same-name handling; cleanup
jturner65 Jul 22, 2024
6163b6b
--improved handling of finished/unfinished urdfs
jturner65 Jul 23, 2024
033d59b
--temporary fix for configs saving filepath subdirs incorrectly.
jturner65 Jul 23, 2024
6337031
--clear markerset if it has no subconfigs.
jturner65 Jul 24, 2024
b4e9f0e
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Jul 24, 2024
048fdc8
--add ability to rotate object around y axis
jturner65 Jul 24, 2024
bb2667d
--add display of target object info - type, handle and # of links (if…
jturner65 Jul 24, 2024
c8d9548
--record urdfs with no links as they get saved
jturner65 Jul 24, 2024
8abea60
--fix urdf notes file formatting issue
jturner65 Jul 24, 2024
7e90488
--force save object toggle.
jturner65 Jul 24, 2024
9780f1e
--display status of force save boolean
jturner65 Jul 24, 2024
a51da46
--revert markerset subconfig removals; Don't write empty configs to file
jturner65 Jul 25, 2024
e7e79cd
Merge branch 'BUGFIX_markersetSegfault' into hssd_ao_utilities_JT
jturner65 Jul 25, 2024
fd7c880
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Jul 25, 2024
4ca6855
--make sure object exists before accessing
jturner65 Jul 25, 2024
59f3d68
--need bigger char size for text
jturner65 Jul 25, 2024
9c40da4
--change joint state toggle to "G" from "J"
jturner65 Aug 2, 2024
58e83e7
--cleanup; prep for back-tab
jturner65 Aug 2, 2024
d279723
--Shift-Tab goes back to previous URDF file
jturner65 Aug 2, 2024
a70d641
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Aug 12, 2024
871a1fe
--enable redo/undelete
jturner65 Aug 12, 2024
7766349
--clang-tidy complaints
jturner65 Aug 13, 2024
1ad03de
--better undo/redo capabilities (add 'dirty' flag)
jturner65 Aug 14, 2024
5114caf
--match rotation
jturner65 Aug 14, 2024
7c05de6
--separate axis and box drawing; enable drawing ao and rigid boxes
jturner65 Aug 15, 2024
03c55f2
--Support displaying color-coded boxes around all objects of desired …
jturner65 Aug 15, 2024
7dc2050
--make a copy of keys() view so dict can be modified in loop
jturner65 Aug 15, 2024
ec903e2
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Aug 15, 2024
f05d4dd
--reorganize in preparation for BE sim_utils rework
jturner65 Aug 16, 2024
a9af604
--re-add ortho function import
jturner65 Aug 16, 2024
eabaa6d
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Aug 20, 2024
886fa51
--verify objects are selected before attempting to match their dims
jturner65 Aug 20, 2024
27c9e2a
--properly set matching orientation
jturner65 Aug 20, 2024
1e380d9
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Aug 25, 2024
fa4eb6d
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Aug 29, 2024
68586f0
accpet "body" as "root" for interaction_surface_points
aclegg3 Aug 29, 2024
e77cbff
--update documentation configuration script
jturner65 Aug 30, 2024
299bd7a
modifications for checking split, faucets, and rec filters in siro_sc…
aclegg3 Sep 3, 2024
d837734
--fix adding object duplicates (should place them right above original)
jturner65 Sep 4, 2024
9202052
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Sep 5, 2024
1a8e920
add a check, error meesage, and correction for 0 scale in box shapes
aclegg3 Sep 6, 2024
bfb46bd
update the default_link code to align with new lab util
aclegg3 Sep 6, 2024
763cc06
add faucet checks, scene splits, non-default active link flagging, ho…
aclegg3 Sep 6, 2024
3ee7d1b
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Sep 10, 2024
0620632
--[Bugfix] - Scene Reset Redundancy (#2470)
jturner65 Sep 13, 2024
9f2a3d7
--[BE] - Add ability to filter Configuration subconfigs (#2471)
jturner65 Sep 13, 2024
76f74a7
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Sep 18, 2024
3cdf192
Merge branch 'dev' into hssd_ao_utilities_JT
jturner65 Sep 18, 2024
3bb430f
--[Bugfix] - Address ObjectInstanceAttributes save issues (#2472)
jturner65 Sep 18, 2024
edad0fb
Merge branch 'dev' into hssd_ao_utilities_JT
jturner65 Sep 18, 2024
c0b2110
--[BE] - Baselink ID init via constant (#2465)
jturner65 Sep 24, 2024
e46ca38
Merge branch 'dev' into hssd_ao_utilities_JT
jturner65 Sep 24, 2024
ec8d264
roll back default link change and remove CPO from viewer
aclegg3 Sep 17, 2024
51b9eaa
add new script to clean up scene instance files
aclegg3 Sep 27, 2024
efb5620
minor changes
aclegg3 Sep 27, 2024
08e072c
use new rec distance checking util to improve rec selection in the vi…
aclegg3 Sep 30, 2024
d924c81
--[BE] - ManagedContainer updates and cleanups (#2475)
jturner65 Sep 30, 2024
ee2d7b4
--[Bugfix] - Compare Configuration scalar doubles properly (#2478)
jturner65 Sep 30, 2024
9ac03ff
Merge branch 'dev' into hssd_ao_utilities_JT
jturner65 Sep 30, 2024
d55b1ee
--[Bugfix] - Scene Reset Redundancy (#2470)
jturner65 Sep 13, 2024
7275866
--[BE] - Add ability to filter Configuration subconfigs (#2471)
jturner65 Sep 13, 2024
a535d57
--[Bugfix] - Address ObjectInstanceAttributes save issues (#2472)
jturner65 Sep 18, 2024
e1d9880
--[BE] - Baselink ID init via constant (#2465)
jturner65 Sep 24, 2024
a24e13f
--[BE] - ManagedContainer updates and cleanups (#2475)
jturner65 Sep 30, 2024
2d09449
--[Bugfix] - Compare Configuration scalar doubles properly (#2478)
jturner65 Sep 30, 2024
d65d2f9
Merge branch 'dev' into hssd_ao_utilities_JT
jturner65 Oct 29, 2024
a6e0917
add a check, error meesage, and correction for 0 scale in box shapes …
jturner65 Oct 30, 2024
94c9576
--enable toggle of window text; some cleanup
jturner65 Oct 31, 2024
97af8b3
--verify object exists before selecting/deselecting.
jturner65 Oct 31, 2024
bb1b6e7
Merge remote-tracking branch 'origin/dev' into hssd_ao_utilities_JT
jturner65 Oct 31, 2024
0ccdd8d
--add help text
jturner65 Oct 31, 2024
f6fc34f
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Nov 4, 2024
4f3d098
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Nov 11, 2024
3b2db98
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Nov 12, 2024
456e81b
minor refactor to check_siro_scenes tool
aclegg3 Nov 12, 2024
98e96d9
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Nov 13, 2024
fd297d3
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Nov 13, 2024
a238e95
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Nov 18, 2024
5ee8e4b
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Nov 22, 2024
c7d00ee
-- use last raycast stage hit as new object placement location
jturner65 Nov 22, 2024
8155783
--clean up imports
jturner65 Oct 29, 2024
9a93ee5
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Nov 22, 2024
02a8d1c
--use new debugLineRenderer function for axes
jturner65 Nov 22, 2024
db02a75
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Nov 25, 2024
8f1c324
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Dec 4, 2024
48af169
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Dec 8, 2024
432971e
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Dec 11, 2024
cf90800
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Dec 16, 2024
798616f
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Dec 19, 2024
05ace92
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Dec 27, 2024
5a9b99b
remove deprecated bb draw
aclegg3 Jan 9, 2025
0dca35b
show region id in window text
aclegg3 Jan 14, 2025
54e8736
--copy of modified viewer.py
jturner65 Jan 15, 2025
b78d5e4
--restore viewer.py to main version
jturner65 Jan 15, 2025
f7305c0
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Jan 15, 2025
fe625a4
--update viewers
jturner65 Jan 15, 2025
dd687d0
--some editor improvements
jturner65 Jan 17, 2025
3f7b9a4
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Jan 22, 2025
bdab8b3
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Jan 23, 2025
68db0ac
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Jan 27, 2025
6fd39e8
added duplicate detection with shift+E and removal with alt+E
aclegg3 Jan 27, 2025
b61802d
improved duplicate detection with handle string similarity metric and…
aclegg3 Jan 28, 2025
6aea387
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Jan 28, 2025
1142667
--move dupe detection to object_editor
jturner65 Jan 29, 2025
58779cb
--make spot more picky for dupes
jturner65 Jan 29, 2025
4eb4f48
--expand dupe selection/editing
jturner65 Jan 30, 2025
cde1830
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Feb 3, 2025
088f7a2
--object semantics script
jturner65 Feb 4, 2025
c896daa
--no longer add 1 for end of file directory in handle name.
jturner65 Feb 4, 2025
f7bc655
--minor tweaks
jturner65 Feb 4, 2025
8e23e4b
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Feb 10, 2025
799710d
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Feb 10, 2025
5bed6df
--minor
jturner65 Feb 12, 2025
b843690
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Feb 12, 2025
950494d
minor bugfix
aclegg3 Feb 13, 2025
b7ae057
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Feb 14, 2025
f4a4ae5
Merge branch 'main' into hssd_ao_utilities_JT
jturner65 Mar 10, 2025
fc152e6
add in-engine load test to the URDF conversion verification process
aclegg3 May 28, 2025
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
187 changes: 187 additions & 0 deletions examples/obj_semantics_writer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
#!/usr/bin/env python3

# Copyright (c) Meta Platforms, Inc. and affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

import csv
import json
from typing import Callable, Dict, List, Union

from habitat_sim.attributes import ArticulatedObjectAttributes, ObjectAttributes
from habitat_sim.metadata import MetadataMediator

# Object Semantics Writer Script
# This program reads a metadata .csv file containing a mapping of object handles (i.e., hashes or names)
# to semantic classes (e.g. "lamp" or "bed"), enumerates the classes and then writes the class index for
# each object in its respective object config file to support semantic rendering.

# this is the common index of un-identified objects
UNKNOWN_INDEX = 0

HSSD_DATASET_DIR = "data/scene_datasets/floorplanner_ss/"


def load_object_metadata(obj_metadata_csv: str) -> Dict[str, List[str]]:
"""
Reads a csv file mapping object handles (i.e. hashes) to semantic classes.
Returns a Dict mapping all semantic classes to their complete set of member object handles.
"""
# load object affordances metadata
obj_classes_to_handles: Dict[str, List[str]] = {}
with open(obj_metadata_csv, "r", newline="") as csvfile:
csvreader = csv.reader(csvfile, delimiter=",")
is_first = True
for row in csvreader:
if is_first:
is_first = False
continue
obj_handle = row[0]
obj_class = row[3].replace("/", "_").replace("#", "") # the condensed class
if obj_class not in obj_classes_to_handles:
obj_classes_to_handles[obj_class] = []
obj_classes_to_handles[obj_class].append(obj_handle)
return obj_classes_to_handles


def assign_indices_to_classes(
obj_classes_to_handles: Dict[str, List[str]]
) -> Dict[str, int]:
"""
Processes the provided object classes and assigns indices to each.
NOTE: 'unknown' is a special case. All classes with 'unknown' in the string are condensed to index 0.
NOTE: 'N_A' is condensed to 'unknown' at index 0.
"""
next_index = UNKNOWN_INDEX + 1
classes_to_indices = {}
classes_sorted = sorted(obj_classes_to_handles.keys())
for obj_class in classes_sorted:
if "unknown" in obj_class or obj_class == "N_A":
classes_to_indices[obj_class] = UNKNOWN_INDEX
else:
classes_to_indices[obj_class] = next_index
next_index += 1
return classes_to_indices


def write_lexicon(
semantic_classes_to_indices: Dict[str, int],
out_path: str = f"{HSSD_DATASET_DIR}semantics/hssd-hab_semantic_lexicon.json",
) -> None:
"""
Writes a semantic lexicon JSON file compatible with Habitat SceneDataset format.
This file maps semantics classes to indices which are then embedded in object configs.

Format:
{
"classes": [
{
"name": "alarm_clock",
"id": 1
},
...
]}
"""

lexicon = {"classes": [{"name": "unknown", "id": UNKNOWN_INDEX}]}

for sem_class, index in semantic_classes_to_indices.items():
if index != UNKNOWN_INDEX:
lexicon["classes"].append({"name": sem_class, "id": index})

# write the lexicon to a file
with open(out_path, "w") as f:
f.write(json.dumps(lexicon, sort_keys=True, indent=4))


def set_attr_semantic_ids(
attributes: List[Union[ObjectAttributes, ArticulatedObjectAttributes]],
semantic_classes_to_indices: Dict[str, int],
semantic_classes_to_handle: Dict[str, List[str]],
register_callback: Callable = None,
) -> None:
"""
Set the semantic_id property within the Attributes object.
"""
handles_to_indices = {
handle: semantic_classes_to_indices[sem_class]
for sem_class, handles in semantic_classes_to_handle.items()
for handle in handles
}
print("Setting semantics: ")
for attr in attributes:
handle = attr.handle.split("/")[-1].split(".")[0]
if handle in handles_to_indices:
attr.semantic_id = handles_to_indices[handle]
print(f" {handle} : {attr.semantic_id}")
if register_callback is not None:
register_callback(attr)
else:
print(
f" - Attributes '{handle}' not in the semantic registry, skipping. Full name {attr.handle}"
)


def main(dataset: str, obj_metadata_csv: str):
# aggregate semantics from csv file
obj_semantics = load_object_metadata(obj_metadata_csv)
class_indices = assign_indices_to_classes(obj_semantics)
# write the lexicon file
write_lexicon(class_indices)

mm = MetadataMediator()
mm.active_dataset = dataset
otm = mm.object_template_manager
aotm = mm.ao_template_manager
print(f" rigid object templates: {len(otm.get_file_template_handles())}")
print(f" articulated object templates: {len(aotm.get_template_handles())}")
print(f" urdf paths: {len(mm.urdf_paths)}")

# Handle the rigids
set_attr_semantic_ids(
otm.get_templates_by_handle_substring().values(),
class_indices,
obj_semantics,
register_callback=otm.register_template,
)
# resave the templates back to file
for handle in otm.get_file_template_handles():
otm.save_template_by_handle(handle, True)

# Handle the AOs
set_attr_semantic_ids(
aotm.get_templates_by_handle_substring().values(),
class_indices,
obj_semantics,
register_callback=aotm.register_template,
)
# resave the templates back to file
for handle in aotm.get_template_handles():
aotm.save_template_by_handle(handle, True)


if __name__ == "__main__":
import argparse

parser = argparse.ArgumentParser()

# optional arguments
parser.add_argument(
"--dataset",
default=f"{HSSD_DATASET_DIR}hssd-hab-siro-wip.scene_dataset_config.json",
type=str,
help=f'scene dataset file to load (default: "{HSSD_DATASET_DIR}hssd-hab-siro-wip.scene_dataset_config.json"',
)

# required arguments
parser.add_argument(
"--semantic-csv",
default=f"{HSSD_DATASET_DIR}hssd_obj_semantics_condensed.csv",
type=str,
help=f'csv file containing the mapping from object handles to semantic classes (default : "{HSSD_DATASET_DIR}hssd_obj_semantics_condensed.csv")',
)

args = parser.parse_args()

# run the program
main(dataset=args.dataset, obj_metadata_csv=args.semantic_csv)
Loading