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-1059 Add ParallelProjectionOntoXZwithRobotMarker for SLAM visualizations #1762

Merged
57 commits merged into from Jan 23, 2023
Merged

RSDK-1059 Add ParallelProjectionOntoXZwithRobotMarker for SLAM visualizations #1762

57 commits merged into from Jan 23, 2023

Conversation

ghost
Copy link

@ghost ghost commented Jan 11, 2023

This PR creates an image from a pcd by projecting it onto the XZ plane. A red mark is added to the image to denote the current robot position.

Currently, this PR implements the basic logic for converting probability into a color, however, it is waiting on RSDK-1073 to be complete before it can be tested. Note: only cartographer will provide probability data, orbslam will rely on the default (white) color to represent its points.

JIRA Ticket: RSDK-1059

Image:
image

@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Jan 11, 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 Jan 11, 2023
jeremyhyde-viam added 2 commits January 12, 2023 00:18
@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 12, 2023
Copy link
Author

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Some addition notes

sigmaLevel = 7
imageHeight = 1080
imageWidth = 1080
missThreshold = 0.44
Copy link
Author

@ghost ghost Jan 12, 2023

Choose a reason for hiding this comment

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

Currently these thresholds and the getProbabilityColorFromValue are placeholders with basic logic that mirror to some degree the way the painting is being performed in cartographer. See PR description for more details.

These miss and hit thresholds values are also from cartographer.

Copy link
Member

Choose a reason for hiding this comment

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

Where are these values in the carto slam lib?

rimage/transform/parallel_projection.go Show resolved Hide resolved
rimage/transform/parallel_projection.go Outdated Show resolved Hide resolved
@ghost ghost requested review from JohnN193, nicksanford and kkufieta January 12, 2023 05:23
@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 12, 2023
@ghost ghost requested a review from tessavitabile January 12, 2023 05:24
@ghost ghost marked this pull request as ready for review January 12, 2023 05:24
@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Jan 20, 2023
jeremyhyde-viam and others added 3 commits January 20, 2023 17:23
Co-authored-by: Katharina Xenia Kufieta <katharina.kufieta@gmail.com>
Co-authored-by: Katharina Xenia Kufieta <katharina.kufieta@gmail.com>
Co-authored-by: Katharina Xenia Kufieta <katharina.kufieta@gmail.com>
@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 20, 2023
Co-authored-by: Katharina Xenia Kufieta <katharina.kufieta@gmail.com>
@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 20, 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 Jan 20, 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 Jan 23, 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 Jan 23, 2023
@github-actions
Copy link
Contributor

Code Coverage

Package Line Rate Delta Health
go.viam.com/rdk/components/arm 56% 0.00%
go.viam.com/rdk/components/arm/universalrobots 41% 0.00%
go.viam.com/rdk/components/arm/xarm 2% 0.00%
go.viam.com/rdk/components/arm/yahboom 7% 0.00%
go.viam.com/rdk/components/audioinput 55% 0.00%
go.viam.com/rdk/components/base 63% 0.00%
go.viam.com/rdk/components/base/agilex 62% 0.00%
go.viam.com/rdk/components/base/boat 41% 0.00%
go.viam.com/rdk/components/base/wheeled 65% 0.00%
go.viam.com/rdk/components/board 66% 0.00%
go.viam.com/rdk/components/board/arduino 10% 0.00%
go.viam.com/rdk/components/board/commonsysfs 48% 0.00%
go.viam.com/rdk/components/board/fake 38% 0.00%
go.viam.com/rdk/components/board/numato 19% 0.00%
go.viam.com/rdk/components/board/pi 50% 0.00%
go.viam.com/rdk/components/camera 64% +0.25%
go.viam.com/rdk/components/camera/align 64% -0.95%
go.viam.com/rdk/components/camera/fake 67% 0.00%
go.viam.com/rdk/components/camera/ffmpeg 76% 0.00%
go.viam.com/rdk/components/camera/transformpipeline 78% +0.62%
go.viam.com/rdk/components/camera/videosource 45% +0.57%
go.viam.com/rdk/components/encoder 4% 0.00%
go.viam.com/rdk/components/encoder/fake 76% 0.00%
go.viam.com/rdk/components/gantry 60% 0.00%
go.viam.com/rdk/components/gantry/multiaxis 84% 0.00%
go.viam.com/rdk/components/gantry/oneaxis 86% 0.00%
go.viam.com/rdk/components/generic 83% 0.00%
go.viam.com/rdk/components/gripper 68% 0.00%
go.viam.com/rdk/components/input 87% 0.00%
go.viam.com/rdk/components/input/gpio 84% 0.00%
go.viam.com/rdk/components/motor 77% 0.00%
go.viam.com/rdk/components/motor/dimensionengineering 63% 0.00%
go.viam.com/rdk/components/motor/dmc4000 69% 0.00%
go.viam.com/rdk/components/motor/fake 57% 0.00%
go.viam.com/rdk/components/motor/gpio 64% +0.43%
go.viam.com/rdk/components/motor/gpiostepper 56% -0.59%
go.viam.com/rdk/components/motor/tmcstepper 62% 0.00%
go.viam.com/rdk/components/movementsensor 75% 0.00%
go.viam.com/rdk/components/movementsensor/cameramono 46% 0.00%
go.viam.com/rdk/components/movementsensor/gpsnmea 36% 0.00%
go.viam.com/rdk/components/movementsensor/gpsrtk 28% 0.00%
go.viam.com/rdk/components/posetracker 86% 0.00%
go.viam.com/rdk/components/sensor 86% 0.00%
go.viam.com/rdk/components/sensor/ultrasonic 25% 0.00%
go.viam.com/rdk/components/servo 68% 0.00%
go.viam.com/rdk/components/servo/gpio 71% 0.00%
go.viam.com/rdk/config 76% 0.00%
go.viam.com/rdk/control 57% 0.00%
go.viam.com/rdk/data 79% 0.00%
go.viam.com/rdk/examples/customresources/demos/complexmodule 0% 0.00%
go.viam.com/rdk/examples/customresources/demos/remoteserver 0% 0.00%
go.viam.com/rdk/grpc 25% 0.00%
go.viam.com/rdk/ml 67% 0.00%
go.viam.com/rdk/ml/inference 70% 0.00%
go.viam.com/rdk/module 63% 0.00%
go.viam.com/rdk/module/modmanager 79% 0.00%
go.viam.com/rdk/motionplan 70% +2.80%
go.viam.com/rdk/octree 98% 0.00%
go.viam.com/rdk/operation 82% 0.00%
go.viam.com/rdk/pointcloud 72% +0.09%
go.viam.com/rdk/protoutils 59% 0.00%
go.viam.com/rdk/referenceframe 71% 0.00%
go.viam.com/rdk/registry 89% 0.00%
go.viam.com/rdk/resource 84% 0.00%
go.viam.com/rdk/rimage 78% 0.00%
go.viam.com/rdk/rimage/depthadapter 94% 0.00%
go.viam.com/rdk/rimage/transform 74% +0.78%
go.viam.com/rdk/rimage/transform/cmd/extrinsic_calibration 67% 0.00%
go.viam.com/rdk/robot 85% 0.00%
go.viam.com/rdk/robot/client 81% 0.00%
go.viam.com/rdk/robot/framesystem 65% 0.00%
go.viam.com/rdk/robot/impl 80% 0.00%
go.viam.com/rdk/robot/server 55% +0.59%
go.viam.com/rdk/robot/web 62% 0.00%
go.viam.com/rdk/robot/web/stream 87% 0.00%
go.viam.com/rdk/services/armremotecontrol 71% 0.00%
go.viam.com/rdk/services/armremotecontrol/builtin 52% 0.00%
go.viam.com/rdk/services/baseremotecontrol 71% 0.00%
go.viam.com/rdk/services/baseremotecontrol/builtin 79% 0.00%
go.viam.com/rdk/services/datamanager 79% 0.00%
go.viam.com/rdk/services/datamanager/builtin 78% 0.00%
go.viam.com/rdk/services/datamanager/datacapture 70% 0.00%
go.viam.com/rdk/services/datamanager/datasync 0% 0.00%
go.viam.com/rdk/services/motion 63% 0.00%
go.viam.com/rdk/services/motion/builtin 88% 0.00%
go.viam.com/rdk/services/navigation 53% 0.00%
go.viam.com/rdk/services/sensors 77% 0.00%
go.viam.com/rdk/services/sensors/builtin 97% 0.00%
go.viam.com/rdk/services/shell 14% 0.00%
go.viam.com/rdk/services/slam 84% 0.00%
go.viam.com/rdk/services/slam/builtin 70% 0.00%
go.viam.com/rdk/services/vision 80% 0.00%
go.viam.com/rdk/services/vision/builtin 74% 0.00%
go.viam.com/rdk/session 97% 0.00%
go.viam.com/rdk/spatialmath 82% 0.00%
go.viam.com/rdk/subtype 92% 0.00%
go.viam.com/rdk/utils 72% +0.18%
go.viam.com/rdk/vision 26% 0.00%
go.viam.com/rdk/vision/chess 80% 0.00%
go.viam.com/rdk/vision/delaunay 87% 0.00%
go.viam.com/rdk/vision/keypoints 92% 0.00%
go.viam.com/rdk/vision/objectdetection 82% 0.00%
go.viam.com/rdk/vision/odometry 60% 0.00%
go.viam.com/rdk/vision/odometry/cmd 0% 0.00%
go.viam.com/rdk/vision/segmentation 49% 0.00%
go.viam.com/rdk/web/server 25% 0.00%
Summary 65% (21479 / 32860) +0.24%

@ghost ghost merged commit 3db1629 into viamrobotics:main Jan 23, 2023
// if needed based on the mean and standard deviation of the X and Z coordinates.
func calculateScaleFactor(xRange, zRange float64) float64 {
var scaleFactor float64
if xRange != 0 || zRange != 0 {
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't this allow for divide by zero errors, which will cause a panic?
e.g. xRange == 10 zRange == 0


switch {
case prob < missThreshold:
b = uint8(255 * ((missThreshold - prob) / (hitThreshold - 0)))
Copy link
Member

Choose a reason for hiding this comment

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

  1. Why are we subtracting 0 from hitThreshold? Isn't this a no op?

  2. Also, are these shades intended to mean anything? I.e. does more green mean something than less green, or are we just trying to make different probabilities in the 3 different buckets distinct from each other? If more green / less green or more glue / less blue is intended to mean something in the current form, can you please add that intent to the comment?

case prob > hitThreshold:
g = uint8(255 * ((prob - hitThreshold) / (1 - missThreshold)))
default:
b = uint8(255 * ((missThreshold - prob) / (hitThreshold - 0)))
Copy link
Member

Choose a reason for hiding this comment

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

Why are we subtracting 0 from hitThreshold? Isn't this a no op?

g = uint8(255 * ((prob - hitThreshold) / (1 - missThreshold)))
default:
b = uint8(255 * ((missThreshold - prob) / (hitThreshold - 0)))
g = uint8(255 * ((prob - hitThreshold) / (1 - missThreshold)))
Copy link
Member

Choose a reason for hiding this comment

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

Won't prob - hitThreshold result in a negative number here? Won't that result in a panic?


// Adds a point to an image using the value to define the color. If no value is available,
// the default color of white is used.
if x >= 0 && x < imageWidth && y >= 0 && y < imageHeight {
Copy link
Member

Choose a reason for hiding this comment

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

[nit] could we please call x >= 0 && x < imageWidth && y >= 0 && y < imageHeight a variable like: pointWithinImageStandardDeviation so it is clear that this is where we are filtering out points which fall outside of the image borders as they are not within the standard deviation?


// Add a red robot marker to the image
if ppRM.robotPose != nil {
x := int(math.Round((robotMarker.Point().X - minX) * scaleFactor))
Copy link
Member

Choose a reason for hiding this comment

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

If the robot marker is outside of the standard deviation does this still do the right thing?

}

// Calculate the scale factors
scaleFactor := calculateScaleFactor(maxX-minX, maxZ-minZ)
Copy link
Member

Choose a reason for hiding this comment

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

If the scale factor is 0 this will return an image which is black right? Is that ever useful to an end user or would it be better to return an error in this case?

test.That(t, unusedDepthMap, test.ShouldBeNil)
})

t.Run("Test that projecting two offset pointclouds will produce same image", func(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

Can we please add the following tests:

  1. Behavior when robot marker falls outside of standard deviation.
  2. Behavior when either maxX==minX, maxZ==minZ, or both.
  3. Behavior when any of the point cloud points have nil data

@ghost ghost deleted the RSDK-1059_ParallelProjectionOntoXZWithRobotMarker branch February 1, 2023 19:50
randhid pushed a commit to randhid/rdk that referenced this pull request Feb 25, 2023
This pull request was closed.
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.

6 participants