-
Notifications
You must be signed in to change notification settings - Fork 110
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-8840 - Add set speed and acceleration function to xArm doCommand #4382
Conversation
components/arm/xarm/xarm.go
Outdated
if val, ok := cmd["set"]; ok { | ||
// The command expects a float64 slice of length 2, describing the desired speed and acceleration. | ||
// We specify our values in degrees and here they are converted into radians. | ||
interfaceList, err := utils.AssertType[[]interface{}](val) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than forcing setting of speed and acceleration together as a list, let's add "set_speed" and "set_acceleration" as separate commands.
if !ok { | ||
return nil, errors.New("could not get float64 from interfaceList[1]") | ||
} | ||
x.speed = utils.DegToRad(speed) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both of these need to be checked that they are greater than zero.
components/arm/xarm/xarm.go
Outdated
@@ -255,5 +255,25 @@ func (x *xArm) DoCommand(ctx context.Context, cmd map[string]interface{}) (map[s | |||
if _, ok := cmd["load"]; ok { | |||
return x.getLoad(ctx) | |||
} | |||
if val, ok := cmd["set"]; ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When this is modularized we should add some good documentation to DoCommand describing to a user how it should be interacted with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My preference is that this simply goes away, and speed/acceleration are specified as part of a time-anchored trajectory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the time being since we are just using this for a single demo I would prefer to keep this functionality in the DoCommand.
I could make a ticket to track this improvement though, i.e. removing set_speed & set_acceleration in favor of specifying them "as part of a time-anchored trajectory."
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This definitely should stay in a DoCommand for this PR. The discussed change above is in the far-off future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Its not a super actionable ticket until a bunch of other stuff happens first but I suppose no harm in making it. Keeping it in DoCommand is definitely the correct scope here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
components/arm/xarm/xarm.go
Outdated
} | ||
speed, ok := interfaceList[0].(float64) | ||
if !ok { | ||
return nil, errors.New("could not get float64 from interfaceList[0]") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can use utils.AssertType here to cut down on the number of unique errors we have
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only changes I want to see are the ones already covered by Peter's reveiw
…es are greater than zero
components/arm/xarm/xarm.go
Outdated
@@ -251,9 +251,33 @@ func (x *xArm) DoCommand(ctx context.Context, cmd map[string]interface{}) (map[s | |||
if err != nil { | |||
return nil, err | |||
} | |||
return map[string]interface{}{}, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added this since we were returning an error on move_gripper
when there was none in actuality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be solved differently. Instead, a flag should be set if at least one command is run. We do not want to return per-command, or else you cannot set speed and acceleration simultaneously.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lmk what you think of the current solution.
components/arm/xarm/xarm.go
Outdated
@@ -242,6 +242,10 @@ func (x *xArm) DoCommand(ctx context.Context, cmd map[string]interface{}) (map[s | |||
if err = x.setGripperMode(ctx, false); err != nil { | |||
return nil, err | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we wrap the above few lines in a command as well? Setting speed with a DoCommand should not fail if no gripper is attached.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Add to the xArm's DoCommand.
This DoCommand is used within the wine pouring demo.
This allows us to set a higher acceleration and speed for when we want to de-pour.
A higher speed and acceleration prevents the wine from dribbling out of the bottle on the de-pour.
This is being added so that people other than me can run the demo here in nyc.