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-6179 - use docommand to postprocess #311

Merged

Conversation

kim-mishra
Copy link
Collaborator

@kim-mishra kim-mishra commented Dec 29, 2023

This PR adds postprocessing functionality via the DoCommand. This is achieved by storing 2 additional parameters on the cartoSvc struct.

  1. postprocessed: which keeps track of if post processing is on or off
  2. postprocessingTasks: a list of all of the postprocessing steps that have occurred.

In PointCloudMap if postprocessing has been "turned on" (cartoSvc.postprocessed == true) all of the postprocessing tasks are iterated through & a new pointcloud map is returned with the added/removed points.

The following functionality was added to the DoCommand:

  • postprocess_toggle: turns on and off postprocessing
  • postprocess_add: adds points to pointcloud map. Value must be specified as [{X: x, Y: y}, ...]
  • postprocess_add: adds points to pointcloud map. Value must be specified as [{X: x, Y: y}, ...]
  • postprocess_undo: undoes last postprocessing steps.

@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 Dec 29, 2023
cartofacade/capi.go Outdated Show resolved Hide resolved
@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 Dec 29, 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 Dec 29, 2023
return nil
}

func updatePointCloudWithRemovedPoints(updatedData *[]byte, points []r3.Vector) error {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure what the best way to do this is - the way it is currently implemented the user would have to input the exact point they want to be removed. Maybe we should instead take in a point and radius and remove any points within that circle?

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 having a default sized radius would be fine for now.

If we wanted to cover more options then I’m wondering if there’s a good way to let users define a radius or a rectangle as options, depending on what gets sent in the do command

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated to have a default radius of 1 cm for now

@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 Dec 29, 2023
return Task{}, ErrXNotFloat64
}

task.Points = append(task.Points, r3.Vector{X: xFloat, Y: yFloat})
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should we handle Z/make sure a user did not provide it or is this sufficient?

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 not handling z is sufficient

)

const (
fullConfidence = 100
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right now i set all the added points to have 100% confidence. I did this because I figured if a user added it that number made sense. I could see an argument for having this be configurable but opted for this to simplify the DoCommand. What to others think?

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 using full confidence makes sense. Cannot think of a use case where we would want it to be different

@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 Dec 31, 2023
@kim-mishra kim-mishra force-pushed the RSDK-6179-use-docommand-to-postprocess branch from 8943a02 to 5401553 Compare January 2, 2024 16:04
@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 Jan 2, 2024
confidence score to be encoded in the blue parameter of the RGB value, on a
scale from 1-100.
*/
err := pc.Set(point, pointcloud.NewColoredData(color.NRGBA{B: fullConfidence}))
Copy link
Collaborator

Choose a reason for hiding this comment

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

[q]Would we be interested in adding another color here to mark the pointcloud as an added obstacle?

the prime component currently overwrites all colors to be grayscale based on the blue channel, so actually visualizing the obstacles would require a change in the prime component to handle the new channel but I think it would be a cool visual

Copy link
Collaborator

Choose a reason for hiding this comment

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

@randhid do you think this would be worth doing for the delivery bot?

Copy link

Choose a reason for hiding this comment

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

Will it be more than a day's work? If so yep. If it's complicated, we'll do in a future date when we more formally do this. Save this idea, it's good.

Copy link
Collaborator

@JohnN193 JohnN193 left a comment

Choose a reason for hiding this comment

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

LGTM, theres a few questions floating around but I think everything here looks good!

@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 Jan 2, 2024
postprocess/postprocess.go Outdated Show resolved Hide resolved
viam_cartographer.go Show resolved Hide resolved
}

// Overwrite updatedData with new points
*updatedData = make([]byte, buf.Len())
Copy link

Choose a reason for hiding this comment

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

should we check if nil? What happens if it is?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

if what is nil?

Copy link

Choose a reason for hiding this comment

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

*updatedData, which we pass into Read. Come to think fo it can buf.Len() ever be zero?

Copy link
Collaborator Author

@kim-mishra kim-mishra Jan 2, 2024

Choose a reason for hiding this comment

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

I tested this fmt.Print(make([]byte, 0) == nil) and it it is false, I will add a nil check!

Copy link

Choose a reason for hiding this comment

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

I think there's another one of these higher up, don't forget that one too!

@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 Jan 2, 2024
@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 Jan 2, 2024
Copy link

@randhid randhid left a comment

Choose a reason for hiding this comment

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

One last cleanup nit, but LGTM! Love the processed map!


func updatePointCloudWithRemovedPoints(updatedData *[]byte, points []r3.Vector) error {
if updatedData == nil {
return errors.New("cannot provide nil udpated data")
Copy link

Choose a reason for hiding this comment

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

This can also be a common error in this package for now.

@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 Jan 3, 2024
@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 Jan 3, 2024
@kim-mishra kim-mishra merged commit 173c8b6 into viam-modules:main Jan 3, 2024
7 checks passed
@kim-mishra kim-mishra deleted the RSDK-6179-use-docommand-to-postprocess branch January 3, 2024 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
appimage Build AppImage of PR 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.

4 participants