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-1899 rearchitect backend of constraint system in anticipation of new constraints being added #2108

Conversation

biotinker
Copy link
Member

@biotinker biotinker commented Mar 24, 2023

This PR does the following:

  • Changes nothing user-facing in terms of generated motion plans. Tweaks a few public-facing constraint-related functions that were previously useless to an external user so almost certainly unused.
  • Remove scores from being returned by constraints; they now return simply a bool
  • Split Constraints into StateConstraints that check the validity of a specific configuration state, and ArcConstraints, which check the validity of a transition from one state to another
  • Similarly, split Metrics into StateMetrics which measure some score for a state, and ArcMetrics, which measure some score for some transition from some state to another
  • Important: This PR moves away from a spatialmath.Pose as a primary data structure for the internal specification of Goals in motion planning. Goals are now stored/passed internally mostly as StateMetrics, where e.g. a passed in Pose is used to create a distance function which will converge on that pose. This is already what was happening implicitly, but this change opens the door to planning in terms of robot configurations where a single spatialmath.Pose is not necessarily the appropriate way to specify a Goal (e.g. 2d planning)

@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Mar 24, 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 Mar 24, 2023
@spieswl
Copy link

spieswl commented Mar 24, 2023

@tessavitabile Follow-up from 1:1, the Important section at the bottom of Peter's PR description is the preparatory content for 2D Motion Planning (and eventually can lead to GeoPoint goals, other spatial goal encodings, etc.)

@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 Mar 24, 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 Mar 24, 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 Mar 24, 2023
@biotinker biotinker marked this pull request as ready for review March 27, 2023 15:47
@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 Mar 27, 2023
opt.AddConstraint(defaultJointConstraint, NewJointConstraint(math.Inf(1)))
opt.metric = NewSquaredNormMetric()
opt.pathDist = NewZeroMetric() // By default, the distance to the valid manifold is zero, unless constraints say otherwise
opt.GoalArcScore = JointMetric
Copy link

@spieswl spieswl Mar 27, 2023

Choose a reason for hiding this comment

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

[q, nit] Was this meant to stay as GoalArcScore?

Copy link

@spieswl spieswl left a comment

Choose a reason for hiding this comment

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

Some small nits, just some minor cleanup.

Copy link
Member

@raybjork raybjork left a comment

Choose a reason for hiding this comment

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

This is a massive change, nice! I'm only halfway through but will come back later today to review the rest of it but wanted to get some initial comments in now

…nstraint-system-in-anticipation-of-new-constraints-being-added
@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 Mar 28, 2023
Copy link
Member

@raybjork raybjork left a comment

Choose a reason for hiding this comment

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

Ok I think I'm done with my first pass. Overall super excited about this. This is an awesome change!

At a high level the things that I am mainly concerned with surround the new ____Input types. I think we should figure out a good naming scheme for what we call Input StateInput SegmentInput because the word input is getting a little overloaded and now is a good time to establish how we want to talk about these going forward. Also, I don't see the need to add frames to these new structures. The frame can be a member on the constraintHandler, which should simplify things a bit.

}

collisions := cg.collisions()
if len(collisions) > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

We need to add this back now right?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, since we're no longer reporting distances here

Copy link
Member

Choose a reason for hiding this comment

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

what is reportDistances doing as an argument if we are not doing this anymore?

Copy link
Member Author

Choose a reason for hiding this comment

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

Once the PenetrationDepthMetric that I mentioned in my TODO is written, that will use true

@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 Mar 29, 2023
@github-actions
Copy link
Contributor

Code Coverage

Package Line Rate Delta Health
go.viam.com/rdk/components/arm 62% 0.00%
go.viam.com/rdk/components/arm/fake 30% 0.00%
go.viam.com/rdk/components/arm/universalrobots 42% 0.00%
go.viam.com/rdk/components/arm/wrapper 20% 0.00%
go.viam.com/rdk/components/arm/xarm 6% 0.00%
go.viam.com/rdk/components/arm/yahboom 6% 0.00%
go.viam.com/rdk/components/audioinput 54% 0.00%
go.viam.com/rdk/components/base 62% 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 76% 0.00%
go.viam.com/rdk/components/board 65% 0.00%
go.viam.com/rdk/components/board/arduino 10% 0.00%
go.viam.com/rdk/components/board/fake 38% 0.00%
go.viam.com/rdk/components/board/genericlinux 24% 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.00%
go.viam.com/rdk/components/camera/align 64% 0.00%
go.viam.com/rdk/components/camera/fake 64% 0.00%
go.viam.com/rdk/components/camera/ffmpeg 77% 0.00%
go.viam.com/rdk/components/camera/rtsp 44% 0.00%
go.viam.com/rdk/components/camera/transformpipeline 78% 0.00%
go.viam.com/rdk/components/camera/videosource 34% 0.00%
go.viam.com/rdk/components/encoder 15% 0.00%
go.viam.com/rdk/components/encoder/fake 76% 0.00%
go.viam.com/rdk/components/gantry 59% 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 82% 0.00%
go.viam.com/rdk/components/gripper 67% 0.00%
go.viam.com/rdk/components/input 87% 0.00%
go.viam.com/rdk/components/input/fake 86% 0.00%
go.viam.com/rdk/components/input/gpio 84% 0.00%
go.viam.com/rdk/components/motor 76% 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 56% 0.00%
go.viam.com/rdk/components/motor/gpio 66% +0.41%
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/motor/ulnstepper 52% 0.00%
go.viam.com/rdk/components/movementsensor 74% 0.00%
go.viam.com/rdk/components/movementsensor/adxl345 65% 0.00%
go.viam.com/rdk/components/movementsensor/cameramono 45% 0.00%
go.viam.com/rdk/components/movementsensor/gpsnmea 37% 0.00%
go.viam.com/rdk/components/movementsensor/gpsrtk 29% 0.00%
go.viam.com/rdk/components/movementsensor/mpu6050 82% 0.00%
go.viam.com/rdk/components/posetracker 84% 0.00%
go.viam.com/rdk/components/sensor 66% 0.00%
go.viam.com/rdk/components/sensor/ultrasonic 31% 0.00%
go.viam.com/rdk/components/servo 66% 0.00%
go.viam.com/rdk/components/servo/gpio 71% 0.00%
go.viam.com/rdk/config 77% 0.00%
go.viam.com/rdk/control 57% 0.00%
go.viam.com/rdk/data 77% -3.94%
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 67% 0.00%
go.viam.com/rdk/module/modmanager 81% 0.00%
go.viam.com/rdk/motionplan 71% -0.22%
go.viam.com/rdk/operation 82% 0.00%
go.viam.com/rdk/pointcloud 68% -0.08%
go.viam.com/rdk/protoutils 49% 0.00%
go.viam.com/rdk/referenceframe 72% -0.47%
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 75% 0.00%
go.viam.com/rdk/rimage/transform/cmd/extrinsic_calibration 67% 0.00%
go.viam.com/rdk/robot 86% 0.00%
go.viam.com/rdk/robot/client 82% 0.00%
go.viam.com/rdk/robot/framesystem 65% 0.00%
go.viam.com/rdk/robot/impl 79% 0.00%
go.viam.com/rdk/robot/packages 80% 0.00%
go.viam.com/rdk/robot/server 53% -0.57%
go.viam.com/rdk/robot/web 64% 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 55% 0.00%
go.viam.com/rdk/services/baseremotecontrol 71% 0.00%
go.viam.com/rdk/services/baseremotecontrol/builtin 78% 0.00%
go.viam.com/rdk/services/datamanager 75% 0.00%
go.viam.com/rdk/services/datamanager/builtin 84% -0.44%
go.viam.com/rdk/services/datamanager/datacapture 73% 0.00%
go.viam.com/rdk/services/datamanager/datasync 0% 0.00%
go.viam.com/rdk/services/motion 62% 0.00%
go.viam.com/rdk/services/motion/builtin 88% 0.00%
go.viam.com/rdk/services/navigation 54% 0.00%
go.viam.com/rdk/services/sensors 74% 0.00%
go.viam.com/rdk/services/sensors/builtin 97% 0.00%
go.viam.com/rdk/services/shell 25% 0.00%
go.viam.com/rdk/services/slam 84% 0.00%
go.viam.com/rdk/services/slam/builtin 74% 0.00%
go.viam.com/rdk/services/slam/fake 90% 0.00%
go.viam.com/rdk/services/vision 79% 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 84% 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 26% 0.00%
Summary 65% (22759 / 34886) -0.05%

@biotinker biotinker requested review from spieswl and raybjork March 30, 2023 15:21
Copy link

@spieswl spieswl left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@raybjork raybjork left a comment

Choose a reason for hiding this comment

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

Just a few more things but really close!

return referenceframe.InputsL2Distance(segment.StartConfiguration, segment.EndConfiguration)
}

// TODO(pl): Writing a PenetrationDepthMetric will allow cbirrt to path along the sides of obstacles rather than terminating
Copy link
Member

Choose a reason for hiding this comment

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

Remove these

}

collisions := cg.collisions()
if len(collisions) > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

what is reportDistances doing as an argument if we are not doing this anymore?

@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 Apr 3, 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 Apr 3, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Apr 3, 2023

Availability

Scene # viamrobotics:main biotinker:20230315_RSDK-1899-rearchitect-backend-of-constraint-system-in-anticipation-of-new-constraints-being-added Percent Improvement Health
1 100% 100% 0%
2 100% 100% 0%
3 100% 100% 0%
4 100% 100% 0%
5 60% 90% 50%
6 30% 40% 33%
7 30% 10% -67%
8 100% 100% 0%
9 90% 100% 11%
10 100% 100% 0%
11 100% 100% 0%
12 100% 100% 0%

Quality

Scene # viamrobotics:main biotinker:20230315_RSDK-1899-rearchitect-backend-of-constraint-system-in-anticipation-of-new-constraints-being-added Percent Improvement Probability of Improvement Health
1 1.31±0.00 1.31±0.00 -0% 24%
2 0.90±0.00 0.91±0.01 -0% 41%
3 3.87±0.58 4.01±0.85 -4% 44%
4 6.30±0.30 6.22±0.40 1% 57%
5 24.64±7.51 23.74±8.66 4% 53%
6 21.10±4.76 19.73±3.88 6% 59%
7 5.05±2.22 13.41±0.00 -165% 0%
8 5.18±0.85 5.28±0.97 -2% 47%
9 4.49±0.19 5.49±1.98 -22% 31%
10 4.22±0.39 4.28±0.41 -1% 46%
11 5.07±0.65 4.99±0.64 2% 54%
12 4.04±0.87 3.77±0.73 7% 60%

Performance

Scene # viamrobotics:main biotinker:20230315_RSDK-1899-rearchitect-backend-of-constraint-system-in-anticipation-of-new-constraints-being-added Percent Improvement Probability of Improvement Health
1 5.50±2.87 5.50±2.87 -0% 50%
2 5.50±2.87 5.50±2.87 -0% 50%
3 5.50±2.87 5.50±2.87 -0% 50%
4 5.50±2.87 5.50±2.87 -0% 50%
5 6.33±2.49 5.22±2.90 18% 61%
6 5.33±3.09 5.50±2.29 -3% 48%
7 4.33±1.70 2.00±0.00 54% 92%
8 5.50±2.87 5.50±2.87 -0% 50%
9 5.00±2.58 5.50±2.87 -10% 45%
10 5.50±2.87 5.50±2.87 -0% 50%
11 5.50±2.87 5.50±2.87 -0% 50%
12 5.50±2.87 5.50±2.87 -0% 50%

The above data was generated by running scenes defined in the motion-testing repository
The SHA1 for viamrobotics:main is: 582f0769ecb07b78e7a7820bd71da099814e30cc
The SHA1 for biotinker:20230315_RSDK-1899-rearchitect-backend-of-constraint-system-in-anticipation-of-new-constraints-being-added is: 582f0769ecb07b78e7a7820bd71da099814e30cc

  • 10 samples were taken for each scene
  • A timeout of 5.0 seconds was imposed for each trial

@biotinker biotinker merged commit 830eea2 into viamrobotics:main Apr 3, 2023
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.

5 participants