-
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-8542 expose plans generated from builtin motion service without executing them #4287
Conversation
Warning your change may break code samples. If your change modifies any of the following functions please contact @viamrobotics/fleet-management. Thanks!
|
services/motion/motion.go
Outdated
// The external environment to be considered for the duration of the move | ||
WorldState referenceframe.WorldState | ||
// Constraints which need to be satisfied during the movement | ||
Constraints motionplan.Constraints |
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.
Previously we were accepting pointers for all of the above, but this gets a little weird when you put it into a struct since the default if unset becomes a nil. Technically keeping them as pointers wouldnt be a regression because it was always possible to pass nils into the function, so I could see the argument for minimizing change by going back to making them pointers.
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.
IMO pointers are better.
Imagine the case where a Destination is not provided. If this is a pointer, then as you say, it is nil; easy to check. If it is a PoseInFrame, then an uninitialized Destination is a real PoseInFrame with a nil underlying Pose, and an empty string for parent frame. This is much more difficult to check for, and for some structs may have overlap with actual valid, meaningful inputs.
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.
Cool I'll revert back to this then. I think it will make the code easier to read too. I take it based on your lack of other comments that you're cool with the structifying and the general direction of the PR?
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.
As far as it pertains to Move
yes.
I think we'll want the DoCommand API to be much more fully featured than what you have wireframed.
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.
Yeah I agree. Do you have ideas of what you want to see in it now? I will do my best to include
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.
We will need things like being able to request motion from motionplan
whose goal is a joint configuration, rather than a pose.
We will need to be able to request a motion that starts from an arbitrary set of joint positions, rather than the current ones.
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.
Oh right thats a good callout thanks
"go.viam.com/rdk/spatialmath" | ||
) | ||
|
||
// ToProto converts a MoveReq to a pb.MoveRequest | ||
// the name argument should correspond to the name of the motion service the request will be used with. | ||
func (r MoveReq) ToProto(name string) (*pb.MoveRequest, error) { |
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 didn't add tests for these functions but can if we think thats a good idea
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.
🚀
} | ||
|
||
func (ms *builtIn) plan(ctx context.Context, req motion.MoveReq) (motionplan.Plan, error) { | ||
if req.Destination == 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.
We should probably generally validate all contents of the MoveRequest
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.
We are already, the only components of the MoveReq that are not allowed to be nil are the Destination and the componentName which are already being checked
}) | ||
} | ||
|
||
func (ms *builtIn) execute(ctx context.Context, trajectory motionplan.Trajectory) error { |
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 way this is done is fine for this PR/POC, but it is increasingly worrying to me that we have such sharply diverging paths between this and how MoveOnMap/Globe are done, especially considering that the primitives are identical for all of them.
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.
Yeah I agree we've built up a lot of tech debt here. I suspect a long term solution involves decimating this service into multiple motion models. Otherwise we would need to abstract common interfaces to work across both stacks
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.
Otherwise we would need to abstract common interfaces to work across both stacks
I think this is the way. We've got a pretty solid system with the motion state package, we just need to make the update to its API to plug in to the different bits to get the functionality we want.
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 for a prototype
Availability
Quality
Performance
The above data was generated by running scenes defined in the
|
This PR enables us to plan and execute separately using motion/builtin.DoCommand(). The major changes here involve
DoPlan
,DoExecute