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

DATA-516 Fix GetPosition Orientation Response (RDK) #1459

Merged
11 commits merged into from Oct 11, 2022
Merged

DATA-516 Fix GetPosition Orientation Response (RDK) #1459

11 commits merged into from Oct 11, 2022

Conversation

ghost
Copy link

@ghost ghost commented Oct 7, 2022

A quaternion is returned to RDK from orbSLAM via a new response filed "extra". This value is then checked to see if it contains an 'quat' element, that element is then parsed into its respective elements: ox, oy, oz, and otheta. These elements are converted into a orientation vector via the QuatToOV function before being added to the new pose returned by the function.

In no value in 'extra' is found with the name 'quat' then this process is skipped and the pose is returned unaltered. This allows for flexibility between libraries and their return types if needed.

Ticket: DATA-516
Associated PR: #60

Note: This will be removed once spatial math is available in the C++ code via the Rust SDK (see ticket: DATA-531).

slamSvc.logger.Warnf("invalid format for quaternion returned, %v, skipping quaternion transform", q)
return pInFrame, nil
}
slamSvc.logger.Infof("valid format for quaternion returned, %v, performing quaternion transform", q)
Copy link
Author

Choose a reason for hiding this comment

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

Logging of position has been added, however depending on the frequency at which GetPosition is called by the UI this may be removed in the future.

Copy link
Member

Choose a reason for hiding this comment

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

missed that there was logging in both rdk and orbslam, probably only want to log in one of them if you know the grpc call is working

Copy link
Contributor

Choose a reason for hiding this comment

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

If you leave this in, I would make it a debug instead of info.

Copy link
Author

@ghost ghost Oct 11, 2022

Choose a reason for hiding this comment

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

@JohnN193 I'll plan on removing the logging here and keeping it in orbslam

@ghost ghost closed this Oct 7, 2022
@ghost ghost reopened this Oct 7, 2022
@ghost ghost changed the title DATA-516 Fix GetPosition Orientation Response (RDK) DATA-516 Fix GetPosition Orientation Response (ORBSLAM) Oct 7, 2022
@ghost ghost changed the title DATA-516 Fix GetPosition Orientation Response (ORBSLAM) DATA-516 Fix GetPosition Orientation Response (RDK) Oct 7, 2022
@ghost ghost requested review from tessavitabile, JohnN193 and kkufieta October 7, 2022 20:05
@ghost ghost marked this pull request as ready for review October 7, 2022 21:06
Copy link
Member

@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, but I have not really used spacialmath at all so I cannot really comment on that

Copy link
Contributor

@kkufieta kkufieta left a comment

Choose a reason for hiding this comment

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

LGTM besides my nit and that I think someone who is familiar with the spatial math library should be added to the review.

Comment on lines 376 to 377
// TODO DATA-531: Remove extraction and conversion of quaternion from the extra field in the response once the Rust SDK
// is available and the desired math can be implemented on the orbSLAM side
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] Can you add a link to the relevant ticket?

Comment on lines 393 to 397
ori := spatialmath.QuatToOV(quat.Number{Real: valTheta.(float64), Imag: valX.(float64), Jmag: valY.(float64), Kmag: valZ.(float64)})
newPose := spatialmath.NewPoseFromOrientation(pInFrame.Pose().Point(), ori)
pInFrame = referenceframe.NewPoseInFrame(pInFrame.FrameName(), newPose)

}
Copy link
Contributor

Choose a reason for hiding this comment

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

[major] Agreed with John, might make sense to ask e.g. Peter L. for a quick glance at this.

services/slam/builtin/orbslam_int_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@tessavitabile tessavitabile left a comment

Choose a reason for hiding this comment

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

Nice work! A few comments.

services/slam/builtin/builtin.go Outdated Show resolved Hide resolved
services/slam/builtin/builtin.go Show resolved Hide resolved
services/slam/builtin/builtin.go Show resolved Hide resolved
services/slam/builtin/builtin.go Show resolved Hide resolved
slamSvc.logger.Warnf("invalid format for quaternion returned, %v, skipping quaternion transform", q)
return pInFrame, nil
}
slamSvc.logger.Infof("valid format for quaternion returned, %v, performing quaternion transform", q)
Copy link
Contributor

Choose a reason for hiding this comment

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

If you leave this in, I would make it a debug instead of info.

services/slam/builtin/orbslam_int_test.go Outdated Show resolved Hide resolved
@ghost ghost requested a review from biotinker October 11, 2022 20:00
@ghost ghost requested a review from tessavitabile October 11, 2022 20:03
Copy link
Contributor

@tessavitabile tessavitabile left a comment

Choose a reason for hiding this comment

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

Nice!

services/slam/builtin/builtin.go Outdated Show resolved Hide resolved
return pInFrame, nil
}
slamSvc.logger.Infof("valid format for quaternion returned, %v, performing quaternion transform", q)
ori := spatialmath.QuatToOV(quat.Number{Real: valTheta.(float64), Imag: valX.(float64), Jmag: valY.(float64), Kmag: valZ.(float64)})
Copy link
Member

Choose a reason for hiding this comment

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

Since we're parsing these values out of a map[string]interface, it might be worth checking if the (float64) conversion works.

Also, instead of importing gonum.org/v1/gonum/num/quat it can be kept within RDK with

spatialmath.QuatToOV(&spatialmath.Quaternion{Real: valTheta.(float64), Imag: valX.(float64), Jmag: valY.(float64), Kmag: valZ.(float64)})

Though the two are equivalent, Quaternion wraps a quat.Number

Copy link
Author

Choose a reason for hiding this comment

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

Removes need for QuatToOV too! Thanks Peter

Copy link
Member

@biotinker biotinker left a comment

Choose a reason for hiding this comment

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

LGTM

@github-actions
Copy link
Contributor

Code Coverage

Package Line Rate Health
go.viam.com/rdk/components/arm 59%
go.viam.com/rdk/components/arm/universalrobots 12%
go.viam.com/rdk/components/arm/xarm 2%
go.viam.com/rdk/components/arm/yahboom 7%
go.viam.com/rdk/components/audioinput 55%
go.viam.com/rdk/components/base 68%
go.viam.com/rdk/components/base/agilex 62%
go.viam.com/rdk/components/base/boat 41%
go.viam.com/rdk/components/base/wheeled 76%
go.viam.com/rdk/components/board 69%
go.viam.com/rdk/components/board/arduino 10%
go.viam.com/rdk/components/board/commonsysfs 47%
go.viam.com/rdk/components/board/fake 39%
go.viam.com/rdk/components/board/numato 19%
go.viam.com/rdk/components/board/pi 50%
go.viam.com/rdk/components/camera 66%
go.viam.com/rdk/components/camera/fake 67%
go.viam.com/rdk/components/camera/ffmpeg 72%
go.viam.com/rdk/components/camera/transformpipeline 80%
go.viam.com/rdk/components/camera/videosource 57%
go.viam.com/rdk/components/encoder/fake 77%
go.viam.com/rdk/components/gantry 68%
go.viam.com/rdk/components/gantry/multiaxis 84%
go.viam.com/rdk/components/gantry/oneaxis 86%
go.viam.com/rdk/components/generic 85%
go.viam.com/rdk/components/gripper 82%
go.viam.com/rdk/components/input 86%
go.viam.com/rdk/components/input/gpio 87%
go.viam.com/rdk/components/motor 82%
go.viam.com/rdk/components/motor/dmc4000 69%
go.viam.com/rdk/components/motor/fake 59%
go.viam.com/rdk/components/motor/gpio 61%
go.viam.com/rdk/components/motor/gpiostepper 53%
go.viam.com/rdk/components/motor/tmcstepper 65%
go.viam.com/rdk/components/movementsensor 67%
go.viam.com/rdk/components/movementsensor/cameramono 39%
go.viam.com/rdk/components/movementsensor/gpsnmea 37%
go.viam.com/rdk/components/movementsensor/gpsrtk 28%
go.viam.com/rdk/components/posetracker 88%
go.viam.com/rdk/components/sensor 88%
go.viam.com/rdk/components/sensor/ultrasonic 31%
go.viam.com/rdk/components/servo 77%
go.viam.com/rdk/config 77%
go.viam.com/rdk/control 57%
go.viam.com/rdk/data 78%
go.viam.com/rdk/grpc 25%
go.viam.com/rdk/ml 67%
go.viam.com/rdk/ml/inference 70%
go.viam.com/rdk/motionplan 71%
go.viam.com/rdk/operation 93%
go.viam.com/rdk/pointcloud 70%
go.viam.com/rdk/protoutils 62%
go.viam.com/rdk/referenceframe 78%
go.viam.com/rdk/registry 88%
go.viam.com/rdk/resource 85%
go.viam.com/rdk/rimage 78%
go.viam.com/rdk/rimage/depthadapter 94%
go.viam.com/rdk/rimage/transform 73%
go.viam.com/rdk/rimage/transform/cmd/extrinsic_calibration 67%
go.viam.com/rdk/robot 93%
go.viam.com/rdk/robot/client 79%
go.viam.com/rdk/robot/framesystem 68%
go.viam.com/rdk/robot/impl 80%
go.viam.com/rdk/robot/server 58%
go.viam.com/rdk/robot/web 61%
go.viam.com/rdk/robot/web/stream 87%
go.viam.com/rdk/services/armremotecontrol 75%
go.viam.com/rdk/services/armremotecontrol/builtin 25%
go.viam.com/rdk/services/baseremotecontrol 75%
go.viam.com/rdk/services/baseremotecontrol/builtin 71%
go.viam.com/rdk/services/datamanager 62%
go.viam.com/rdk/services/datamanager/builtin 80%
go.viam.com/rdk/services/datamanager/datacapture 34%
go.viam.com/rdk/services/datamanager/datasync 70%
go.viam.com/rdk/services/motion 68%
go.viam.com/rdk/services/motion/builtin 89%
go.viam.com/rdk/services/navigation 54%
go.viam.com/rdk/services/sensors 78%
go.viam.com/rdk/services/sensors/builtin 97%
go.viam.com/rdk/services/shell 15%
go.viam.com/rdk/services/slam 86%
go.viam.com/rdk/services/slam/builtin 74%
go.viam.com/rdk/services/vision 82%
go.viam.com/rdk/services/vision/builtin 74%
go.viam.com/rdk/spatialmath 85%
go.viam.com/rdk/subtype 96%
go.viam.com/rdk/utils 71%
go.viam.com/rdk/vision 25%
go.viam.com/rdk/vision/chess 80%
go.viam.com/rdk/vision/delaunay 87%
go.viam.com/rdk/vision/keypoints 92%
go.viam.com/rdk/vision/objectdetection 83%
go.viam.com/rdk/vision/odometry 60%
go.viam.com/rdk/vision/odometry/cmd 0%
go.viam.com/rdk/vision/segmentation 48%
go.viam.com/rdk/web/server 26%
Summary 66% (18930 / 28594)

@ghost ghost merged commit 4ba55ab into viamrobotics:main Oct 11, 2022
@ghost ghost deleted the 10052022_SLAMGetPositionFixes branch December 29, 2022 20:33
This pull request was closed.
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.

4 participants