Skip to content

[RSDK-8336] Add GetMappingSessionPointcloud and GetActiveMappingSessionForRobotID#3

Merged
JohnN193 merged 4 commits intomainfrom
getpointcloud
Aug 1, 2024
Merged

[RSDK-8336] Add GetMappingSessionPointcloud and GetActiveMappingSessionForRobotID#3
JohnN193 merged 4 commits intomainfrom
getpointcloud

Conversation

@JohnN193
Copy link
Copy Markdown
Collaborator

https://viam.atlassian.net/browse/RSDK-8336

This pr adds support for viewing in progress cloudslam maps and grabbing the active mapping session on startup, if the robot already has an active cloudslam session.

additionally fixes an issue where http connections were not closing properly when stopping the module.

@JohnN193 JohnN193 requested review from penguinland and susWorld July 29, 2024 21:19
Copy link
Copy Markdown

@penguinland penguinland left a comment

Choose a reason for hiding this comment

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

LGTM! All my comments are minor things.

Comment thread cloudslam/app.go Outdated
SyncClient: pbDataSync.NewDataSyncServiceClient(conn),
PackageClient: pbPackage.NewPackageServiceClient(conn),
HTTPClient: &http.Client{},
// Disable keepalives makes each request only last for a single http GET request
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The comment says what it does, but not why it does that. This option means you need to redo the TCP handshake every time you make a new request, which might even involve redoing the TLS handshake and generating/exchanging an encryption key, if you're using HTTPS. Why go through all that effort every time?

Comment thread cloudslam/app.go
// GetDataFromHTTP makes a request to an http endpoint app serves, which gets redirected to GCS.
// will remove nolint in the next pr when this function gets used to retrieve pcds
//
//nolint:unused
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍 Thanks for maintaining the comments like this!

Comment thread cloudslam/cloudslam.go Outdated
mapRefreshRate = 1 / 5. // Hz
defaultLidarFreq = 5 // Hz
defaultMSFreq = 20 // Hz
mapRefreshRate = 1 / 0.2 // Seconds
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Idle curiosity: why not make it 5 seconds? You seem to be emphasizing that this is 0.2 Hz instead of 5 seconds, which seems odd to me (but maybe makes sense in context).

Thanks for updating the units! That was an important change.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

ya know ur not wrong

Comment thread cloudslam/cloudslam.go Outdated
activeJob atomic.Pointer[string]
lastPose atomic.Pointer[spatialmath.Pose]
// lastPCD atomic.Pointer[string]
lastPCD atomic.Pointer[string]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should it be obvious to someone working on this codebase what PCD stands for? If so, this is fine. but if not, put in a comment somewhere expanding the acronym. Not sure if it should be here or up at initPCDURL, or somewhere else.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I wonder if this should be named lastPCDURL, to match initPCDURL. At first glance, I had expected we'd look up whatever is stored in initPCDURL and put its contents in lastPCD.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I could change it to lastPointCloudURL to make it obvious, and I agree that it should include URL in the name

Comment thread cloudslam/cloudslam.go

func (svc *cloudslamWrapper) activeMappingSessionThread(ctx context.Context) {
for {
if !goutils.SelectContextOrWait(ctx, time.Duration(1000.*mapRefreshRate)*time.Millisecond) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Mild preference to remove the period from 1000: I don't see why we need it to be a float. If it does need to be a float, mild preference to make it 1000.0 to emphasize that it's a float, since the period is easy to overlook.

Comment thread cloudslam/cloudslam.go
svc.lastPose.Store(&currPose)
svc.lastPCD.Store(&resp.MapUrl)
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍 This function is so straightforward! Thanks for making it easy to read.

Copy link
Copy Markdown

@susWorld susWorld left a comment

Choose a reason for hiding this comment

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

my comments are mostly code style related.

Comment thread cloudslam/cloudslam.go Outdated
Comment on lines +34 to +36
defaultLidarFreq = 5 // Hz
defaultMSFreq = 20 // Hz
mapRefreshRate = 1 / 0.2 // Seconds
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Where did you get these values from? Some comments explaining it would be nice

Comment thread cloudslam/cloudslam.go Outdated
wrapper.lastPose.Store(&initPose)
initJob := ""
wrapper.activeJob.Store(&initJob)
wrapper.lastPCD.Store(&initPCDURL)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

newSLAM can definitely be broken down into smaller helper functions. It's too big

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I don't really like the idea of making helper functions that only get used once. At some point I may turn more of the robot/config related fields into their own struct but I do not think this is the pr to do that. If people feel strongly I can make the single-use helpers

Comment thread cloudslam/cloudslam.go
return wrapper, nil
}

func (svc *cloudslamWrapper) activeMappingSessionThread(ctx context.Context) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

missing function description. This applies to all functions without a description

Comment thread cloudslam/cloudslam.go Outdated
wrapper.lastPCD.Store(&initPCDURL)

// using this as a placeholder image. need to determine the right way to have the module use it
path := filepath.Clean("./test2.pcd")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

./test2.pcd can be a global variable, that way you can simplify the next line to bytes, err := os.ReadFile(filepath.Clean(PATH_TO_FILE))

@JohnN193 JohnN193 merged commit d6e1c38 into main Aug 1, 2024
@JohnN193 JohnN193 deleted the getpointcloud branch August 1, 2024 15:03
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.

3 participants