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

Add new KinBody::ExtraGeometryInfo struture for KinBody::Link::_mapExtraGeometries #1441

Open
wants to merge 22 commits into
base: production
Choose a base branch
from

Conversation

zax147
Copy link

@zax147 zax147 commented Sep 30, 2024

Add support for serialization and deserialization of the extraGeometries field.

The extraGeometries in OpenRAVE is saved as std::map< std::string, std::vector<GeometryInfoPtr> > while the schema supposes to be:

         "extraGeometries": [
              {
                  "id": "extraGeometry_id",
                  "name": "extraGeometry_name",
                  "geometries": [
                      {
                          "id": "geom_id",
                          "name": "geom_name",
                      }
                  ]
              }
          ]

@cielavenir
Copy link
Collaborator

just to comment, he is zirui.xie@mujin

src/libopenrave/kinbodylink.cpp Outdated Show resolved Hide resolved
src/libopenrave/kinbodylink.cpp Outdated Show resolved Hide resolved
FOREACHC(im, _mapExtraGeometries) {
rapidjson::Value extraGeometryValue;
extraGeometryValue.SetObject();
orjson::SetJsonValueByKey(extraGeometryValue, "name", im->first, allocator);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you missed handling the id field here and in deserialization

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for offline conversation, I think you can put id instead of name here.
the key of the std::map is now represented by id.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

talked in person.
It looks we still need both id and name.

The user of id can handle limited characters.

Meanwhile, we want to use the more characters for the key of the mapExtraGeometries.
In the upcoming safety-related geometry handling (c.f. #1402), we want to define the key based on the KinBody::GetName, ...etc. Thus, the supported characters should be the same level as KinBody::GetName and others.
Therefore, we also need name field.

That means, we need to introduce the new data structure for mapExtraGeometries...

@zax147 zax147 marked this pull request as draft October 10, 2024 06:43
@zax147 zax147 changed the title Add serialization and deserialization functions for extraGeometries Add new KinBody::ExtraGeometryInfo struture for KinBody::Link::_mapExtraGeometries Oct 18, 2024
@zax147 zax147 marked this pull request as ready for review October 24, 2024 00:47
@@ -1331,19 +1359,19 @@ class OPENRAVE_API KinBody : public InterfaceBase
///
/// \param name The name of the geometry group. If name is empty, will initialize the default geometries.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you update the param comments

geometriesValue.PushBack(geometryValue, allocator);
}
}
extraGeometryValue.AddMember("geometries", geometriesValue, allocator);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can just reuse ExtraGeometryInfo::SerializeJSON

std::map<std::string, std::vector<KinBody::GeometryInfoPtr>>::iterator it = _info._mapExtraGeometries.insert(make_pair(groupname, std::vector<KinBody::GeometryInfoPtr>())).first;
it->second.resize(geometries.size());
std::copy(geometries.begin(), geometries.end(), it->second.begin());
KinBody::ExtraGeometryInfoPtr new_extrageom( new KinBody::ExtraGeometryInfo() );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use camel case

@rdiankov
Copy link
Owner

rdiankov commented Nov 2, 2024

The problem with serializing extra geometry infos is that "self" geometry group gets serialization, which is just a copy of the regular geometry. Furthermore, a lot of other geometries are auto-generated (like padding), so there's really no reason to serialize them as part of the JSON, which then gets into the saved files, and significantly increases the save/load times of the files along with increasing the size on disk.

Perhaps you can begin with talking about the problem you are trying to solve here, and we can think about the right solution.

@zax147
Copy link
Author

zax147 commented Nov 4, 2024

The problem with serializing extra geometry infos is that "self" geometry group gets serialization, which is just a copy of the regular geometry. Furthermore, a lot of other geometries are auto-generated (like padding), so there's really no reason to serialize them as part of the JSON, which then gets into the saved files, and significantly increases the save/load times of the files along with increasing the size on disk.

Perhaps you can begin with talking about the problem you are trying to solve here, and we can think about the right solution.

The problem we're solving is that in the latest MCD, we would like to use the extraGeometries (or geometry groups) field in Webstack, for example, to store extraGeometries in webstack and to selectively show extraGeometries on the UI.

We've added the extraGeometries field and its related function in webstack, and now trying to match with the changes in Webstack.

@rdiankov
Copy link
Owner

rdiankov commented Nov 5, 2024

Why does webstack need to handle extra geometries at the moment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants