-
Notifications
You must be signed in to change notification settings - Fork 18
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-2881: Update viam-cartographer to check if camera provides timestamps #92
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[q] The extracting of the timestamp here is being performing by accessing the TimeReceivedMetadataKey and parsing the timestamp out of it. That leaves me with two questions:
- If the camera's context metadata does not contain that key, won't ok return
false
? Ideally, that should be the check to determine if a camera is in replay or not. - The current implementation uses the result of the Parsing of the timeReceived to determine if a given camera is a replay camera or not. This mean if a replay camera ever had malformed metadata, it would register as a real/live camera.
Please correct me if those questions are overlooking something, However, I dont believe we should be using the parsing to determine replay status, only the presence of that camera.TimeReceivedMetadataKey
internal/dim-2d/dim-2d.go
Outdated
@@ -105,6 +107,7 @@ func GetAndSaveData(ctx context.Context, dataDirectory string, lidar lidar.Lidar | |||
ctx, span := trace.StartSpan(ctx, "viamcartographer::internal::dim2d::GetAndSaveData") | |||
defer span.End() | |||
|
|||
ctx, md := utils.ContextWithMetadata(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the results of the discussion regarding my open question, update the comment here to more correctly represent that the deciding factor is the parsing/extraction and not the presence of the timestamp.
Example:
ctx, md := utils.ContextWithMetadata(ctx) | |
// If the timestamps correlated with the point cloud and provided by the server can be extracted use them when writing the data to disk, otherwise use the current time. |
@jeremyrhyde We should never get metadata for that field in the wrong format, but anything can happen :) My thought was it would be better to just use current timestamps ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, lgtm!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with the change to error out for malformed input
Summary
This PR modifies the viam-cartographer to provide metadata in the context it provides when calling its sensor. If the sensor is a replay camera, the camera will attach metadata to the gRPC response which will then get injected into the context in a client-side gRPC interceptor. When viam-cartographer finds timestamps in the context metadata, it extracts the time received value and uses this and the timestamp for the PCD file name.
Manual Testing
I tested by configuring a robot (my Mac) with a replay camera and providing that as a sensor for SLAM. Along with the changes in the corresponding rdk PR, I confirmed that the files get written to disk with the correct timestamps correlated with the time they were captured (last week):