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-8840 - Add set speed and acceleration function to xArm doCommand #4382

Merged
merged 8 commits into from
Sep 23, 2024

Conversation

nfranczak
Copy link
Member

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.

@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Sep 23, 2024
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)
Copy link
Member

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)
Copy link
Member

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.

@@ -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 {
Copy link
Member

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.

Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

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

}
speed, ok := interfaceList[0].(float64)
if !ok {
return nil, errors.New("could not get float64 from interfaceList[0]")
Copy link
Member

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

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.

The only changes I want to see are the ones already covered by Peter's reveiw

@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 Sep 23, 2024
@@ -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
Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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.

@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 Sep 23, 2024
@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 Sep 23, 2024
@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 Sep 23, 2024
@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 Sep 23, 2024
@@ -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
}

Copy link
Member

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.

@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 Sep 23, 2024
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

@nfranczak nfranczak merged commit 15f62ba into viamrobotics:main Sep 23, 2024
19 checks passed
@nfranczak nfranczak deleted the RSDK-8840 branch October 11, 2024 20:04
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.

4 participants