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

RSDK-3344 - getPosition refactor #110

Closed

Conversation

kim-mishra
Copy link
Collaborator

No description provided.

@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label May 31, 2023
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels May 31, 2023
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels May 31, 2023
Comment on lines +185 to +188
{
std::lock_guard<std::mutex> lk(viam_response_mutex);
global_pose = latest_global_pose;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Question: Is there any behavior surrounding lock availability we want to implement here? Or do we always want GetPosition to wait until the lock is available

Copy link
Collaborator

Choose a reason for hiding this comment

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

B/c the viam_response_mutex is only held for the duration of copying a variable (not an expensive operation) it is ok to block until the lock is acquired.

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels May 31, 2023

auto pos_vector = global_pose.translation();
auto pos_quat = global_pose.rotation();
viam_carto_get_position_response* vcgpr;
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 want to actually instantiate the struct & then pass a reference to it to the function, otherwise I think the pointer could point to uninitialized memory:

viam_carto_get_position_response vcgpr;
GetPosition(&vcgpr);

Comment on lines +185 to +188
{
std::lock_guard<std::mutex> lk(viam_response_mutex);
global_pose = latest_global_pose;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

B/c the viam_response_mutex is only held for the duration of copying a variable (not an expensive operation) it is ok to block until the lock is acquired.

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels May 31, 2023
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels May 31, 2023
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels May 31, 2023
@kkufieta kkufieta removed their request for review May 31, 2023 19:03
@kim-mishra kim-mishra changed the title RSDK-3344 - refactor get position RSDK-3344 - getPosition refactor May 31, 2023
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Jun 6, 2023
@nicksanford nicksanford closed this Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test This pull request is marked safe to test from a trusted zone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants