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

Robot Serialization #316

Merged
merged 11 commits into from
Dec 20, 2021
Merged

Robot Serialization #316

merged 11 commits into from
Dec 20, 2021

Conversation

varunagrawal
Copy link
Collaborator

This class provides serialization capabilities for the Robot class and all the currently defined links and joints.

@varunagrawal varunagrawal added the feature New feature or request label Nov 30, 2021
@varunagrawal varunagrawal self-assigned this Nov 30, 2021
@varunagrawal varunagrawal force-pushed the feature/robot-serialization branch from df304fc to 3dab7bb Compare November 30, 2021 21:21
Copy link
Member

@dellaert dellaert left a comment

Choose a reason for hiding this comment

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

I trust @ProfFan to review

@@ -17,17 +17,17 @@ jobs:
matrix:
# Github Actions requires a single row to be added to the build matrix.
# See https://help.github.com/en/articles/workflow-syntax-for-github-actions.
name: [ubuntu-18.04-gcc-9, ubuntu-18.04-clang-10]
name: [ubuntu-20.04-gcc-9, ubuntu-20.04-clang-10]
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a 18.04 target here so we don't lose 18.04

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

18.04 has Boost 1.65 and not the minimum 1.67 that GTSAM supports. As such, that serialization bug that we had about deepcopies rears its head again with 18.04.

We'll have to do a custom install of Boost if you want 18.04 which will significantly increase CI time. Thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

Help, we lost 18.04 for GTSAM???

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nope. We do a custom Boost install for 1.67 in GTSAM. That adds a good 5 minutes to the CI.

Copy link
Member

Choose a reason for hiding this comment

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

Tell me again why we do not support the default boost version on 1804?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@ProfFan any updates on this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay, I have a resolution for this: I am just setting Ubuntu 20.04 for the clang CI. That way we are still supporting Boost 1.65 (at least for GCC).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ping @ProfFan

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is good, but

@varunagrawal varunagrawal requested a review from ProfFan December 2, 2021 01:04
Copy link
Member

@gchenfc gchenfc left a comment

Choose a reason for hiding this comment

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

I guess I'll let you and Fan duke it out about Boost, but the rest LGTM

ar &BOOST_SERIALIZATION_NVP(bMlink_);
ar &BOOST_SERIALIZATION_NVP(is_fixed_);
ar &BOOST_SERIALIZATION_NVP(fixed_pose_);
ar &BOOST_SERIALIZATION_NVP(joints_);
Copy link
Member

@gchenfc gchenfc Dec 2, 2021

Choose a reason for hiding this comment

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

just checking, will everything work ok if Joint is serializing Link and Link is serializing Joint?

Like they're serializing eachother?

Actually this brings up another question (not for this PR but just puzzling): how does Joint/Link even work? Won't our code have circular pointer counts so Joints/Links will never get cleaned up? e.g. if a link and joint hold shared_ptr's to eachother, then even if their "owning" robot drops its pointer then both their pointer counts will still be 1 and they won't get freed right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah I should get rid of joint serialization in Link.h

// Define comparators for easy std::map equality checking
auto link_comparator = [](decltype(*this->name_to_link_.begin()) a,
decltype(a) b) {
// compare the key name and the underlying shared_ptr object
Copy link
Member

Choose a reason for hiding this comment

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

nit: can you _emph_ or make a note in the comment "Define comparators ..." or something that clarifies that the only reason this is needed is for the shared_ptr ? Spent a couple minutes trying to figure out why you didn't just use the default map comparator 😂

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am still not a fan of this shared pointer implementation of Links and Joints. Other than efficiency (which can also be achieved with references), was there any other reason for choosing to use them?

Copy link
Member

Choose a reason for hiding this comment

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

references won't work for polymorphic types, e.g. RevoluteJoint vs ScrewJoint vs PrismaticJoint

specifically, to hold a container of polymorphic types you need pointers (unless use fancy std::variant stuff but I don't think that suits our use case - inherently we need runtime polymorphism to hold all the joints in one data structure)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Huh, I figured we could just pass references to the Joint class since the public API for each joint type is the same. I am not going to tackle this anytime soon so we can actually drop it. 😅

@varunagrawal varunagrawal requested a review from gchenfc December 6, 2021 15:47
Copy link
Member

@gchenfc gchenfc left a comment

Choose a reason for hiding this comment

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

Looks good!

@dellaert
Copy link
Member

Serialization should deal fine with pointers, BTW. Not sure what the exact issue is.

@varunagrawal varunagrawal requested a review from gchenfc December 18, 2021 16:29
Copy link
Contributor

@ProfFan ProfFan left a comment

Choose a reason for hiding this comment

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

Please change gcc back to 18.04 and then LGTM

@@ -17,17 +17,17 @@ jobs:
matrix:
# Github Actions requires a single row to be added to the build matrix.
# See https://help.github.com/en/articles/workflow-syntax-for-github-actions.
name: [ubuntu-18.04-gcc-9, ubuntu-18.04-clang-10]
name: [ubuntu-20.04-gcc-9, ubuntu-20.04-clang-10]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is good, but

- name: ubuntu-18.04-gcc-9
os: ubuntu-18.04
- name: ubuntu-20.04-gcc-9
os: ubuntu-20.04
Copy link
Contributor

Choose a reason for hiding this comment

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

They need to be updated^

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is so strange. As per commit 1b8707e, that change should have already been made.

@varunagrawal varunagrawal merged commit b449a24 into master Dec 20, 2021
@varunagrawal varunagrawal deleted the feature/robot-serialization branch December 20, 2021 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants