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-4120 add MoveThroughJointPositions to Arm interface #4508

Merged
merged 16 commits into from
Nov 5, 2024

Conversation

raybjork
Copy link
Member

The actual work involved here is pretty minor I think. The real work will come in properly implementing the arm modules we are supporting. Opening this up as a draft PR for now to get some initial feedback, while I write tests for the code. Open questions:

  • is there a better way to consolidate GoToInputs and this new function? They are very duplicative
  • is it worth spending more time to do a better implementation on any of the arm drivers we still have builtin to RDK? My feeling is no and that this will be done on a module by module basis later
  • it doesnt feel like there is anything to be done for our upstream services. Motion is still just calling GoToInputs, no?

@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Oct 30, 2024
Copy link
Contributor

Warning your change may break code samples. If your change modifies any of the following functions please contact @viamrobotics/fleet-management. Thanks!

component function
base IsMoving
board GPIOPinByName
camera Properties
encoder Properties
motor IsMoving
sensor Readings
servo Position
arm EndPosition
audio MediaProperties
gantry Lengths
gripper IsMoving
input_controller Controls
movement_sensor LinearAcceleration
power_sensor Power
pose_tracker Poses
motion GetPose
vision GetProperties

@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 Oct 30, 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 Oct 30, 2024
@biotinker
Copy link
Member

it doesnt feel like there is anything to be done for our upstream services. Motion is still just calling GoToInputs, no?

Motion should call GoToInputs, because we move things that are not arms, e.g. gantries.

This PR should update the implementation of GoToInputs on arms so that that calls MoveThroughJointPositions.

Copy link
Contributor

Availability

Scene # viamrobotics:main raybjork:RSDK-4120 Percent Improvement Health
1 100% 100% 0%
2 100% 100% 0%
3 100% 100% 0%
4 100% 100% 0%
5 90% 90% 0%
6 70% 70% 0%
7 30% 30% 0%
8 100% 100% 0%
9 100% 100% 0%
10 100% 100% 0%
11 100% 100% 0%
12 100% 100% 0%
13 100% 100% 0%
14 100% 100% 0%
15 100% 100% 0%
16 100% 100% 0%
17 100% 100% 0%
18 40% 40% 0%

Quality

Scene # viamrobotics:main raybjork:RSDK-4120 Percent Improvement Probability of Improvement Health
1 1.31±0.00 1.31±0.00 -0% 50%
2 0.90±0.00 0.90±0.00 -0% 50%
3 3.49±1.60 3.49±1.60 -0% 50%
4 3.95±1.18 4.14±1.23 -5% 45%
5 16.29±11.44 14.31±6.62 12% 56%
6 15.92±4.30 14.45±5.47 9% 58%
7 4.81±1.78 4.64±1.90 4% 53%
8 4.74±0.49 4.74±0.49 -0% 50%
9 4.45±0.43 4.45±0.43 -0% 50%
10 4.45±0.44 4.45±0.44 -0% 50%
11 5.55±0.72 5.54±0.72 0% 50%
12 3.96±1.11 3.96±1.11 -0% 50%
13 904.77±13.78 904.77±13.78 -0% 50%
14 2129.60±711.35 2129.60±711.35 -0% 50%
15 50549.88±4594.49 50549.88±4594.49 -0% 50%
16 54723.04±11672.98 54723.04±11672.98 -0% 50%
17 15859.97±5452.61 15859.97±5452.61 -0% 50%
18 134215.78±34511.05 135263.70±33918.09 -1% 49%

Performance

Scene # viamrobotics:main raybjork:RSDK-4120 Percent Improvement Probability of Improvement Health
1 0.09±0.01 0.09±0.01 -0% 49%
2 0.16±0.01 0.17±0.02 -2% 44%
3 0.56±0.27 0.55±0.26 2% 51%
4 1.99±0.10 2.02±0.11 -2% 42%
5 2.77±0.93 2.83±0.87 -2% 48%
6 3.11±1.09 3.09±1.10 1% 51%
7 2.08±0.18 2.05±0.18 1% 55%
8 0.27±0.14 0.27±0.14 2% 51%
9 4.97±0.22 4.97±0.19 -0% 50%
10 0.14±0.02 0.13±0.02 3% 57%
11 0.10±0.01 0.10±0.01 2% 59%
12 0.12±0.01 0.12±0.01 0% 51%
13 0.08±0.01 0.08±0.01 -2% 41%
14 0.72±0.24 0.72±0.24 -0% 50%
15 1.47±0.26 1.47±0.26 0% 50%
16 2.44±1.30 2.44±1.29 0% 50%
17 1.52±0.25 1.49±0.26 2% 53%
18 4.68±0.58 4.68±0.58 -0% 50%

The above data was generated by running scenes defined in the motion-testing repository
The SHA1 for viamrobotics:main is: 900738751a11aa6be03dd90a3932f38e1c35f187
The SHA1 for raybjork:RSDK-4120 is: 900738751a11aa6be03dd90a3932f38e1c35f187

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

@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 Oct 30, 2024
Copy link
Member

@nfranczak nfranczak left a comment

Choose a reason for hiding this comment

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

Will do a more thorough review later on. I believe arm/client.go still needs to be updated so that GoToInputs calls MoveThroughJointPositions instead of MoveToJointPositions

components/arm/pb_helpers.go Outdated Show resolved Hide resolved
components/arm/universalrobots/ur.go Show resolved Hide resolved
@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 Oct 31, 2024
@viambot viambot removed the safe to test This pull request is marked safe to test from a trusted zone label Oct 31, 2024
@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Oct 31, 2024
@raybjork raybjork marked this pull request as ready for review October 31, 2024 21:25
@nfranczak
Copy link
Member

https://github.com/viamrobotics/rdk/blob/main/components/arm/client.go#L148
doesn't this need to be updated in this PR?

@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 Nov 1, 2024
@raybjork
Copy link
Member Author

raybjork commented Nov 1, 2024

https://github.com/viamrobotics/rdk/blob/main/components/arm/client.go#L148 doesn't this need to be updated in this PR?

Yes, thank you for catching this. Just updated.

Copy link
Member

@nfranczak nfranczak left a comment

Choose a reason for hiding this comment

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

LGTM, I am very excited about this being merged!

I've left a comment about where the MoveOptions struct should live, the names we give to the field of that particular struct. It's your final call to decide these things.

I've also left a comment asking for clarification to understand why we convert from rad to deg and then back from deg to rad when doing fromProto and then toProto.

🚀

)

// MoveOptions define parameters to be obeyed during arm movement.
type MoveOptions struct {
Copy link
Member

@nfranczak nfranczak Nov 1, 2024

Choose a reason for hiding this comment

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

I think it might make more sense for this struct to live in arm.go? What are your thoughts?
Having it live in pb_helpers.go kind of obscures its presence/makes it harder to find

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 think its pretty easy to find and the struct is simple enough that it kind of feels like a code artifact that is a helper. Going to leave this as is for now and mentally flag this as something to change down the line as we change arms more

)

// MoveOptions define parameters to be obeyed during arm movement.
type MoveOptions struct {
MaxVel, MaxAcc float64
Copy link
Member

Choose a reason for hiding this comment

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

do you think it makes sense to add units here?, e.g. MaxVelRads, MaxAccRads?

Copy link
Member

Choose a reason for hiding this comment

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

+1

Copy link
Member

Choose a reason for hiding this comment

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

Sorry I should've thought of this when I left my original comment, thoughts on the units actually being in degrees since that are easier to mentally reason about? We could then handle the conversion in the backend.
If not, that's also ok :)

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 the units should be in radians because this is the struct we will be operating on. The protobuf struct is in degrees

components/arm/pb_helpers.go Outdated Show resolved Hide resolved
)

// MoveOptions define parameters to be obeyed during arm movement.
type MoveOptions struct {
MaxVel, MaxAcc float64
Copy link
Member

Choose a reason for hiding this comment

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

+1

acc = *protobuf.MaxAccDegsPerSec2
}
return &MoveOptions{
MaxVel: utils.DegToRad(vel),
Copy link
Member

Choose a reason for hiding this comment

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

If not set, these here default to 0.

I could see a naive module implementer making <= 0 an invalid value, rather than a "use the default" value.

A comment on the struct should specify expected behavior for not-positive values.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah my intention was to have these default to zero if unset and handle default values at the driver level (per Miko's suggestion earlier in this review) I think thats a better way to handle it than trying to come up with some default at the package level.

For example if I am an arm driver I see an incoming options struct with zero values, I know then that they were unspecified since zero would result in no motion. Or I could make the bizarre implementation choice of allowing a user to specify a zero speed. But either way it is up to the module author here, and this code is just a passthrough. That track with your expecations?

@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 Nov 5, 2024
components/arm/client.go Outdated Show resolved Hide resolved
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.

Two changes to prevent nil errors, otherwise looks good

@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 Nov 5, 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

@raybjork raybjork merged commit 5c10f4e into viamrobotics:main Nov 5, 2024
18 checks passed
hexbabe pushed a commit to hexbabe/sean-rdk that referenced this pull request Nov 6, 2024
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