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

[prototype] marker annotation util #2366

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
1,234 changes: 1,100 additions & 134 deletions examples/viewer.py

Large diffs are not rendered by default.

186 changes: 178 additions & 8 deletions src/esp/bindings/AttributesBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "esp/metadata/attributes/ArticulatedObjectAttributes.h"
#include "esp/metadata/attributes/AttributesBase.h"
#include "esp/metadata/attributes/LightLayoutAttributes.h"
#include "esp/metadata/attributes/MarkerSets.h"
#include "esp/metadata/attributes/ObjectAttributes.h"
#include "esp/metadata/attributes/PbrShaderAttributes.h"
#include "esp/metadata/attributes/PhysicsManagerAttributes.h"
Expand All @@ -33,10 +34,14 @@ using Attrs::CylinderPrimitiveAttributes;
using Attrs::IcospherePrimitiveAttributes;
using Attrs::LightInstanceAttributes;
using Attrs::LightLayoutAttributes;
using Attrs::LinkSet;
using Attrs::MarkerSet;
using Attrs::MarkerSets;
using Attrs::ObjectAttributes;
using Attrs::PbrShaderAttributes;
using Attrs::PhysicsManagerAttributes;
using Attrs::StageAttributes;
using Attrs::TaskSet;
using Attrs::UVSpherePrimitiveAttributes;
using esp::core::managedContainers::AbstractFileBasedManagedObject;
using esp::core::managedContainers::AbstractManagedObject;
Expand Down Expand Up @@ -229,11 +234,168 @@ void initAttributesBindings(py::module& m) {
.value("TREE_TRAVERSAL",
metadata::attributes::ArticulatedObjectLinkOrder::TreeTraversal);

// ==== Markersets and subordinate classes ===

py::class_<MarkerSet, MarkerSet::ptr>(m, "MarkerSet")
.def(py::init(&MarkerSet::create<>))
.def_property_readonly(
"num_points", &MarkerSet::getNumPoints,
R"(The current number of marker points present in this MarkerSet.)")
.def(
"get_points", &MarkerSet::getAllPoints,
R"(Get an ordered list of all the 3D marker points in this MarkerSet)")
.def(
"set_points", &MarkerSet::setAllPoints,
R"(Set the marker points for this MarkerSet to be the passed list of 3D points)",
"markers"_a);

py::class_<LinkSet, LinkSet::ptr>(m, "LinkSet")
.def(py::init(&LinkSet::create<>))
.def_property_readonly(
"num_markersets", &LinkSet::getNumMarkerSets,
R"(The current number of MarkerSets present in this LinkSet.)")
.def("has_markerset", &LinkSet::hasMarkerSet,
R"(Whether or not this LinkSet has a MarkerSet with the given name)",
"markerset_name"_a)
.def("get_all_pointset_names", &LinkSet::getAllMarkerSetNames,
R"(Get a list of all the MarkerSet names within this LinkSet)")
.def("get_markerset", &LinkSet::editMarkerSet,
R"(Get an editable reference to the specified MarkerSet, possibly
empty if it does not exist)",
"markerset_name"_a)
.def("set_markerset_points", &LinkSet::setMarkerSetPoints,
R"(Sets the marker points for the specified MarkerSet)",
"markerset_name"_a, "marker_list"_a)
.def("get_markerset_points", &LinkSet::getMarkerSetPoints,
R"(Gets the marker points for the named MarkerSet of this LinkSet)",
"markerset_name"_a)
.def(
"set_all_points", &LinkSet::setAllMarkerPoints,
R"(Sets the marker points for all the MarkerSets of this LinkSet to the
passed dictionary of values, keyed by MarkerSet name, referencing a list
of 3d points)",
"markerset_dict"_a)
.def("get_all_points", &LinkSet::getAllMarkerPoints,
R"(Get a dictionary holding all the points in this LinkSet, keyed by
MarkerSet name, referencing lists of the MarkerSet's 3d points)");

py::class_<TaskSet, TaskSet::ptr>(m, "TaskSet")
.def(py::init(&TaskSet::create<>))
.def_property_readonly(
"num_linksets", &TaskSet::getNumLinkSets,
R"(The current number of LinkSets present in this TaskSet.)")
.def("has_linkset", &TaskSet::hasLinkSet,
R"(Whether or not this TaskSet has a LinkSet with the given name)",
"linkset_name"_a)
.def("get_all_linkset_names", &TaskSet::getAllLinkSetNames,
R"(Get a list of all the LinkSet names within this TaskSet)")
.def("get_linkset", &TaskSet::editLinkSet,
R"(Get an editable reference to the specified LinkSet, possibly
empty if it does not exist)",
"linkset_name"_a)
.def(
"set_link_markerset_points", &TaskSet::setLinkMarkerSetPoints,
R"(Set the marker points for the specified LinkSet's specified MarkerSet
to the given list of 3d points)",
"linkset_name"_a, "markerset_name"_a, "marker_list"_a)
.def(
"set_linkset_points", &TaskSet::setLinkSetPoints,
R"(Set the marker points in each of the MarkerSets for the specified LinkSet
to the given dictionary of 3d points, keyed by the MarkerSet name)",
"linkset_name"_a, "markerset_dict"_a)
.def(
"set_all_points", &TaskSet::setAllMarkerPoints,
R"(Set the marker points for every MarkerSet of every link in this TaskSet to the values in
the passed dict of dicts. The format should be dictionary keyed by link name of dictionaries,
each keyed by MarkerSet name for the particular link with the value being a list of 3d points)",
"link_markerset_dict"_a)

.def(
"get_link_markerset_points", &TaskSet::getLinkMarkerSetPoints,
R"(Get the marker points for the specified LinkSet's specified MarkerSet as a list of 3d points)",
"linkset_name"_a, "markerset_name"_a)
.def(
"get_linkset_points", &TaskSet::getLinkSetPoints,
R"(Get the marker points in each of the MarkerSets for the specified LinkSet
as a dictionary of lists of 3d points, keyed by the LinkSet's MarkerSet name)",
"linkset_name"_a)
.def(
"get_all_points", &TaskSet::getAllMarkerPoints,
R"(Get the marker points for every MarkerSet of every link in this TaskSet as a dict
of dicts. The format is a dictionary keyed by link name of dictionaries,
each keyed by MarkerSet name for the particular link with the value being a list
of the marker points)");
py::class_<MarkerSets, MarkerSets::ptr>(m, "MarkerSets")
.def(py::init(&MarkerSets::create<>))
.def_property_readonly(
"num_tasksets", &MarkerSets::getNumTaskSets,
R"(The current number of TaskSets present in the MarkerSets collection.)")
.def("has_taskset", &MarkerSets::hasTaskSet,
R"(Whether or not a TaskSet with the given name exists)",
"taskset_name"_a)
.def("get_all_taskset_names", &MarkerSets::getAllTaskSetNames,
R"(Get a list of all the existing TaskSet names)")
.def("get_taskset", &MarkerSets::editTaskSet,
R"(Get an editable reference to the specified TaskSet, possibly
empty if it does not exist)",
"taskset_name"_a)
.def(
"set_task_link_markerset_points",
&MarkerSets::setTaskLinkMarkerSetPoints,
R"(Set the marker points for the specified TaskSet's specified LinkSet's
specified MarkerSet to the given list of 3d points)",
"taskset_name"_a, "linkset_name"_a, "markerset_name"_a,
"marker_list"_a)
.def(
"set_task_linkset_points", &MarkerSets::setTaskLinkSetPoints,
R"(Set the points in all the MarkerSets of the specified LinkSet, in the
specified TaskSet, to the given dictionary, keyed by each MarkerSet's name
and referencing a list of 3d points.)",
"taskset_name"_a, "linkset_name"_a, "markerset_dict"_a)
.def(
"set_taskset_points", &MarkerSets::setTaskSetPoints,
R"(Set all the marker points in the specified TaskSet to the 3d point values in the
passed dict of dicts. The format should be a dictionary keyed by LinkSet name, of
dictionaries, each keyed by MarkerSet name and referencing a list of 3d points)",
"taskset_name"_a, "link_markerset_dict"_a)
.def(
"set_all_points", &MarkerSets::setAllMarkerPoints,
R"(Set the marker points for every MarkerSet of every LinkSet of every TaskSet present to the values in
the passed dict of dicts of dicts. The format should be dictionary, keyed by TaskSet name, of dictionaries,
keyed by link name, of dictionary, each keyed by MarkerSet name and value being a list
of that MarkerSet's marker points)",
"task_link_markerset_dict"_a)
.def(
"get_task_link_markerset_points",
&MarkerSets::getTaskLinkMarkerSetPoints,
R"(Get the marker points for the specified TaskSet's specified LinkSet's specified MarkerSet
as a list of 3d points)",
"taskset_name"_a, "linkset_name"_a, "markerset_name"_a)
.def(
"get_task_linkset_points", &MarkerSets::getTaskLinkSetPoints,
R"(Get the points in all the MarkerSets of the specified LinkSet, in the
specified TaskSet, as a dictionary, keyed by each MarkerSet's name
and referencing a list of 3d points.)",
"taskset_name"_a, "linkset_name"_a)

.def(
"get_taskset_points", &MarkerSets::getTaskSetPoints,
R"(Get all the marker points in the specified TaskSet as a dict of dicts.
The format is a dictionary keyed by LinkSet name, of dictionaries,
each keyed by MarkerSet name and referencing a list of 3d points)",
"taskset_name"_a)
.def(
"get_all_marker_points", &MarkerSets::getAllMarkerPoints,
R"(Get the marker points for every MarkerSet of every link of every TaskSet present as a dict
of dicts of dicts. The format is a dictionary keyed by TaskSet name, of dictionaries,
keyed by LinkSet name, of dictionaries, each keyed by MarkerSet name referencing a list
of that MarkerSet's marker points)");

// ==== ArticulatedObjectAttributes ====
py::class_<ArticulatedObjectAttributes, AbstractAttributes,
ArticulatedObjectAttributes::ptr>(
m, "ArticulatedObjectAttributes",
R"(A metadata template for articulated object configurations. Can be imported from
R"(A metadata template for articulated object configurations. Is imported from
.ao_config.json files.)")
.def(py::init(&ArticulatedObjectAttributes::create<>))
.def(py::init(&ArticulatedObjectAttributes::create<const std::string&>))
Expand Down Expand Up @@ -333,12 +495,15 @@ void initAttributesBindings(py::module& m) {
"rolling_friction_coefficient",
&AbstractObjectAttributes::getRollingFrictionCoefficient,
&AbstractObjectAttributes::setRollingFrictionCoefficient,
R"(Rolling friction coefficient for constructions built from this template. Damps angular velocity about axis orthogonal to the contact normal to prevent rounded shapes from rolling forever.)")
R"(Rolling friction coefficient for constructions built from this template.
Damps angular velocity about axis orthogonal to the contact normal to
prevent rounded shapes from rolling forever.)")
.def_property(
"spinning_friction_coefficient",
&AbstractObjectAttributes::getSpinningFrictionCoefficient,
&AbstractObjectAttributes::setSpinningFrictionCoefficient,
R"(Spinning friction coefficient for constructions built from this template. Damps angular velocity about the contact normal.)")
R"(Spinning friction coefficient for constructions built from this template.
Damps angular velocity about the contact normal.)")
.def_property(
"restitution_coefficient",
&AbstractObjectAttributes::getRestitutionCoefficient,
Expand Down Expand Up @@ -406,7 +571,7 @@ void initAttributesBindings(py::module& m) {
m, "ObjectAttributes",
R"(A metadata template for rigid objects pre-instantiation. Defines asset paths, physical
properties, scale, semantic ids, shader type overrides, and user defined metadata.
ManagedRigidObjects are instantiated from these blueprints. Can be imported from
ManagedRigidObjects are instantiated from these blueprints. Is imported from
.object_config.json files.)")
.def(py::init(&ObjectAttributes::create<>))
.def(py::init(&ObjectAttributes::create<const std::string&>))
Expand Down Expand Up @@ -458,7 +623,11 @@ void initAttributesBindings(py::module& m) {
// ==== StageAttributes ====
py::class_<StageAttributes, AbstractObjectAttributes, StageAttributes::ptr>(
m, "StageAttributes",
R"(A metadata template for stages pre-instantiation. Defines asset paths, collision properties, gravity direction, shader type overrides, semantic asset information, and user defined metadata. Consumed to instantiate the static background of a scene (e.g. the building architecture). Can be imported from .stage_config.json files.)")
R"(A metadata template for stages pre-instantiation. Defines asset paths,
collision properties, gravity direction, shader type overrides, semantic
asset information, and user defined metadata. Consumed to instantiate the
static background of a scene (e.g. the building architecture).
Is imported from .stage_config.json files.)")
.def(py::init(&StageAttributes::create<>))
.def(py::init(&StageAttributes::create<const std::string&>))
.def_property(
Expand Down Expand Up @@ -506,7 +675,8 @@ void initAttributesBindings(py::module& m) {
py::class_<LightInstanceAttributes, AbstractAttributes,
LightInstanceAttributes::ptr>(
m, "LightInstanceAttributes",
R"(A metadata template for light configurations. Supports point and directional lights. Can be imported from .lighting_config.json files.)")
R"(A metadata template for light configurations. Supports point and directional lights.
Is imported from .lighting_config.json files.)")
.def(py::init(&LightInstanceAttributes::create<>))
.def(py::init(&LightInstanceAttributes::create<const std::string&>))
.def_property(
Expand Down Expand Up @@ -545,7 +715,7 @@ void initAttributesBindings(py::module& m) {
m, "PbrShaderAttributes",
R"(A metadata template for PBR shader creation and control values and multipliers,
such as enabling Image Based Lighting and controlling the mix of direct and indirect
lighting contributions. Can be imported from .pbr_config.json files.)")
lighting contributions. Is imported from .pbr_config.json files.)")
.def(py::init(&PbrShaderAttributes::create<>))
.def(py::init(&PbrShaderAttributes::create<const std::string&>))
.def_property(
Expand Down Expand Up @@ -701,7 +871,7 @@ void initAttributesBindings(py::module& m) {
m, "PhysicsManagerAttributes",
R"(A metadata template for Simulation parameters (e.g. timestep, simulation backend,
default gravity direction) and defaults. Consumed to instace a Simulator object.
Can be imported from .physics_config.json files.)")
Is imported from .physics_config.json files.)")
.def(py::init(&PhysicsManagerAttributes::create<>))
.def(py::init(&PhysicsManagerAttributes::create<const std::string&>))
.def_property_readonly(
Expand Down
10 changes: 6 additions & 4 deletions src/esp/bindings/ConfigBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ void initConfigBindings(py::module& m) {
R"(Retrieves a string representation of the value referred to by the passed key.)")

.def(
"get_keys_by_type", &Configuration::getStoredKeys,
"get_keys_by_type", &Configuration::getKeysByType,
R"(Retrieves a list of all the keys of values of the specified types. Takes ConfigValType
enum value as argument.)",
"value_type"_a)
enum value as argument, and whether the keys should be sorted or not.)",
"value_type"_a, "sorted"_a = false)

.def("get_keys_and_types", &Configuration::getValueTypes,
R"(Returns a dictionary where the keys are the names of the values
Expand Down Expand Up @@ -202,7 +202,9 @@ void initConfigBindings(py::module& m) {
// subconfigs
.def(
"get_subconfig_keys", &Configuration::getSubconfigKeys,
R"(Retrieves a list of the keys of this configuration's subconfigurations)")
R"(Retrieves a list of the keys of this configuration's subconfigurations,
specifying whether the keys should be sorted or not)",
"sorted"_a = false)

.def("get_subconfig", &Configuration::editSubconfig<Configuration>,
py::return_value_policy::reference_internal,
Expand Down
16 changes: 15 additions & 1 deletion src/esp/bindings/PhysicsObjectBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ void declareBasePhysicsObjectWrapper(py::module& m,
("Get or set the translation vector of this " + objType +
"'s root SceneNode. If modified, sim state will be updated.")
.c_str())
.def(
"transform_world_pts_to_local",
&PhysObjWrapper::transformWorldPointsToLocal,
R"(Given the list of passed points in world space, return those points
transformed to this object's local space. The link_id is for articulated
objects and is ignored for rigid objects and stages )",
"ws_points"_a, "link_id"_a)
.def(
"transform_local_pts_to_world",
&PhysObjWrapper::transformLocalPointsToWorld,
R"(Given the list of passed points in this object's local space, return
those points transformed to world space. The link_id is for articulated
objects and is ignored for rigid objects and stages )",
"ws_points"_a, "link_id"_a)
.def_property(
"rotation", &PhysObjWrapper::getRotation,
&PhysObjWrapper::setRotation,
Expand Down Expand Up @@ -484,7 +498,7 @@ void declareArticulatedObjectWrapper(py::module& m,
.c_str(),
"link_id"_a)
.def("get_link_name", &ManagedArticulatedObject::getLinkName,
("Get the name of the this " + objType +
("Get the name of this " + objType +
"'s link specified by the given link_id.")
.c_str(),
"link_id"_a)
Expand Down
Loading