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-628 - allow configurable kinematics for fake arm models #1432

Merged
merged 31 commits into from
Oct 10, 2022

Conversation

raybjork
Copy link
Member

@raybjork raybjork commented Oct 3, 2022

Currently there is no way to specify what kinematic model a fake arm which makes it difficult to test motion planning for arms that we are not connected to. Additionally, the fake and fakeIK models both exist in the codebase which is confusing. This PR addresses both these concerns by wrapping fakeIK model functionality into the fake model, and further makes the kinematic model for the fake model configurable.

@CLAassistant
Copy link

CLAassistant commented Oct 3, 2022

CLA assistant check
All committers have signed the CLA.

@raybjork raybjork marked this pull request as ready for review October 5, 2022 01:19
@raybjork raybjork requested a review from biotinker October 5, 2022 01:19
@raybjork raybjork requested a review from spieswl October 5, 2022 01:19
Copy link
Contributor

@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.

Looks good! I like the simplification down to just fake.

@@ -145,19 +146,19 @@ func TestFrameSystemFromConfig(t *testing.T) {

// There is a point at (1500, 500, 1300) in the world referenceframe. See if it transforms correctly in each referenceframe.
worldPose := referenceframe.NewPoseInFrame(referenceframe.World, spatialmath.NewPoseFromPoint(r3.Vector{1500, 500, 1300}))
armPt := r3.Vector{0, 0, 500}
armPt := r3.Vector{500, 0, 0}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a place we can check where these values are coming from?

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately not really, this was all hand calculated. But you can see the kinematic information in fake_model.json. Does this answer your question?

return fakearm.NewArmIK(ctx, config.Component{Name: "arm"}, logger)
return fakearm.NewArm(ctx, config.Component{
Name: arm.Subtype.String(),
ConvertedAttributes: &fakearm.AttrConfig{ArmModel: xarm.ModelName(6)},
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this change is so that this test can use the kinematic model of the xArm6?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, before it was using another fake kinematic model, which no longer exists

func NewArm(ctx context.Context, cfg config.Component, logger golog.Logger) (arm.LocalArm, error) {
var model referenceframe.Model
var err error
if cfg.ConvertedAttributes != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Probably we should also allow the use of arbitrary files similar to wrapper

Copy link
Member Author

Choose a reason for hiding this comment

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

yes probably, but this is work that I don't think is necessary now, so I would like to push it to another PR

components/arm/fake/fake.go Outdated Show resolved Hide resolved
components/arm/fake/fake_model.json Outdated Show resolved Hide resolved
components/arm/fake/fake.go Outdated Show resolved Hide resolved
components/arm/fake/fake.go Outdated Show resolved Hide resolved
@raybjork raybjork requested a review from biotinker October 10, 2022 15:13
Makefile Outdated Show resolved Hide resolved
@raybjork raybjork requested a review from biotinker October 10, 2022 16:01
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.

Just a couple small changes, and one thing to think about, other than that looks good


// AttrConfig is used for converting config attributes.
type AttrConfig struct {
FailNew bool `json:"fail_new"`
Copy link
Member

Choose a reason for hiding this comment

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

I think this should also be removed, no?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is still being used in some tests, so I wasn't inclined to take it out. Thoughts?

// Validate ensures all parts of the config are valid.
func (config *AttrConfig) Validate(path string) error {
if config.FailNew {
return errors.New("whoops")
Copy link
Member

Choose a reason for hiding this comment

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

This too

components/arm/fake/fake.go Outdated Show resolved Hide resolved
components/arm/fake/fake.go Show resolved Hide resolved
@raybjork raybjork requested a review from biotinker October 10, 2022 16:19
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 74%
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 59%
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 75%
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% (18887 / 28544)

@raybjork raybjork merged commit e245f45 into viamrobotics:main Oct 10, 2022
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