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-8460 - Modularize the xarm driver and remove it from RDK #4578

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions components/arm/fake/fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package fake
import (
"context"
_ "embed"
"fmt"
"strings"
"sync"

Expand All @@ -12,7 +13,6 @@ import (
"go.viam.com/rdk/components/arm"
"go.viam.com/rdk/components/arm/eva"
ur "go.viam.com/rdk/components/arm/universalrobots"
"go.viam.com/rdk/components/arm/xarm"
"go.viam.com/rdk/logging"
"go.viam.com/rdk/motionplan"
"go.viam.com/rdk/referenceframe"
Expand All @@ -35,6 +35,21 @@ var fakejson []byte
//go:embed dofbot.json
var dofbotjson []byte

//go:embed xarm6_kinematics_test.json
var xArm6modeljson []byte

//go:embed xarm7_kinematics_test.json
var xArm7modeljson []byte

//go:embed lite6_kinematics_test.json
var lite6modeljson []byte

const (
xArmModelName6DOF = "xArm6"
xArmModelName7DOF = "xArm7"
xArmModelNameLite = "lite6"
)

// Config is used for converting config attributes.
type Config struct {
ArmModel string `json:"arm-model,omitempty"`
Expand Down Expand Up @@ -256,8 +271,8 @@ func (a *Arm) Geometries(ctx context.Context, extra map[string]interface{}) ([]s

func modelFromName(model, name string) (referenceframe.Model, error) {
switch model {
case xarm.ModelName6DOF, xarm.ModelName7DOF, xarm.ModelNameLite:
return xarm.MakeModelFrame(name, model)
case xArmModelName6DOF, xArmModelName7DOF, xArmModelNameLite:
return xArmMakeModelFrame(name, model)
case ur.Model.Name:
return ur.MakeModelFrame(name)
case eva.Model.Name:
Expand All @@ -281,3 +296,17 @@ func modelFromPath(modelPath, name string) (referenceframe.Model, error) {
return nil, errors.New("only files with .json and .urdf file extensions are supported")
}
}

// xArmMakeModelFrame returns the kinematics model of the xarm arm, which has all Frame information.
func xArmMakeModelFrame(name, modelName string) (referenceframe.Model, error) {
switch modelName {
case xArmModelName6DOF:
return referenceframe.UnmarshalModelJSON(xArm6modeljson, name)
case xArmModelNameLite:
return referenceframe.UnmarshalModelJSON(lite6modeljson, name)
case xArmModelName7DOF:
return referenceframe.UnmarshalModelJSON(xArm7modeljson, name)
default:
return nil, fmt.Errorf("no kinematics information for xarm of model %s", modelName)
}
}
1 change: 0 additions & 1 deletion components/arm/register/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ import (
_ "go.viam.com/rdk/components/arm/fake"
_ "go.viam.com/rdk/components/arm/universalrobots"
_ "go.viam.com/rdk/components/arm/wrapper"
_ "go.viam.com/rdk/components/arm/xarm"
)
4 changes: 2 additions & 2 deletions components/arm/wrapper/wrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ func TestReconfigure(t *testing.T) {
cfg1 := resource.Config{
Name: "testArm",
ConvertedAttributes: &Config{
ModelFilePath: "../xarm/xarm6_kinematics.json",
ModelFilePath: "../fake/xarm6_kinematics_test.json",
ArmName: armName.ShortName(),
},
}

cfg1Err := resource.Config{
Name: "testArm",
ConvertedAttributes: &Config{
ModelFilePath: "../xarm/xarm6_kinematics.json",
ModelFilePath: "../fake/xarm6_kinematics_test.json",
ArmName: "dne1",
},
}
Expand Down
280 changes: 0 additions & 280 deletions components/arm/xarm/xarm.go

This file was deleted.

Loading
Loading