-
Notifications
You must be signed in to change notification settings - Fork 123
RSDK-10936 introduce RobotFrameSystem interface #5101
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
Conversation
Warning your change may break code samples. If your change modifies any of the following functions please contact @viamrobotics/fleet-management. Thanks!
|
// frameSystem, err := fsService.FrameSystem(context.Background(), nil) | ||
type Service interface { | ||
resource.Resource | ||
type RobotFrameSystem interface { |
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.
Is there a reason not to just have this be a resource
?
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'm not sure. Going to defer to @cheukt on this
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.
let's make this a resource too
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.
On closer inspection this is not possible. By adding theResource
interface we give the FrameSystemService a Reconfigure
method, which is also present in the Robot
interface, so this causes problems.
Is there a reason I'm not seeing you would like to make this a resource?
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.
it should be a resource because we'll be treating it like a resource in order for modular framesystem to work. but it should be ok as long as the underlying frameSystemService struct implements those methods, which it seems to do. we can hash out anything that doesn't work when we try to implement a modular framesystem
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.
Another way to solve the problem would be, for robot
to not also be a frame system service.
The reason for doing so I assume is for it to be a zero output change and not break a bunch of existing robot clients?
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.
Well the methods are on the robot client itself, I think it does make sense for them to continue to be on the interface
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.
framesystem.Service
is the resource, this is just the interface defining the functions that are common to both this and the robot
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 guess, what's the final form of this? How will a module get at the framesystem?
I'm assuming we're going to split the API and make a FrameSystemClient?
When that happens, that then would probably be the time to make it a resource. Can we add a TODO?
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 this is work that Netcode is going to pick up after I get this initial change in. I'm not too sure on the details of how they will do it tbh. I don't think a TODO is necessary for work that is imminently scheduled
robot/framesystem/framesystem.go
Outdated
} | ||
|
||
// CurrentInputs will get the inputs of all provided dependencies. | ||
func CurrentInputs(ctx context.Context, components []resource.Resource) (referenceframe.FrameSystemInputs, 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.
This feels more difficult to use than what existed before, especially absent some helper that actually returns the list of resources.
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.
You aren't wrong. CurrentInputs is not an API method though and I want there to be a 1:1 correspondence between API and interface here. If you have a better suggestion I'm open to it
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 think this needs to be in the API for the FS service.
The motivation behind the creation of this service, is "so the framesystem can be used on modules". What we have here is indeed a service that will provide a FrameSystem
object to a module, but as a module cannot at present actually create an enumeration of resource
s on the robot without a Robot
client, in terms of actual utility we're just running in place here.
The framesystem is useless without the inputs with which to call it. The inputs cannot be created without a robot client, or else manually making sure that the module calling this has a dependency on every single other robot component (don't add a new one or rename an old one and forget to update the dependency list!)
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 disagree. Inputs are not a concept in proto (yet) and I want to avoid biting that off. I don't think its that bad to have this be a helper function. At the end of the day anybody who has a resource client can call the associated InputEnabled
methods on the resource anyway. All this was doing was providing a weird backdoor where you could somehow know about resources that you might not even have a dependency on in the first place. (i.e you write a motion service that doesnt depend on every arm (this isn't a strawman, this was useful for the DC demo) you would get back information about something that should be unknown to you)
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 mean, by returning the whole framesystem, we're already telling resources about other resources they don't directly depend on.
By requiring CurrentInputs to take a list of resources, we're basically saying that in order to know where things are, you need to be able to control them. That is, in order to get read access, you must have write access.
We're creating a situation here where a module using a framesystem, goes from "impossible", to "difficult, tedious, fragile and error-prone". The difference between "difficult, tedious, fragile and error-prone" and "easy" here is the creation of the data structure used as input to the frame system.
Calling CurrentInputs should IMO not be massively more difficult than calling NewFromService. I don't think the dis-inclusion of Inputs in proto until now is a huge problem, since this would be something specific to robots/frame system services, not something that components would have to concern themselves 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.
Oh; in that case, how is a module expected to access it? Supplying the module with the robot's own API key etc is intended to remain the "correct" way of doing things?
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'm not completely sure about that. Something having to do with it being passed by default to module constructors. Netcode will own this part of the work and @cheukt can weigh in 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.
the module will be passed the framesystem resources by default in the dependencies map
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 module will be passed the framesystem resources
To clarify; you're saying that the framesystem resource will be passed to all modules by default, or that a module receiving a framesystem will automatically be passed all resources in the frame system?
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 former - the framesystem resource will be passed to all modules by default
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.
generally looks fine to me
// frameSystem, err := fsService.FrameSystem(context.Background(), nil) | ||
type Service interface { | ||
resource.Resource | ||
type RobotFrameSystem interface { |
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.
let's make this a resource too
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
This PR implements the changes needed to implement viamrobotics/api#713 . As a part of this the FrameSystemService interface is changing so that it 1:1 matches the available methods on the robot proto. The intention here is that this is a zero output change so if you see something that looks like it goes beyond a refactor it is probably wrong
I recommend starting this review by looking at
robot.go
andframesystem.go
. The changes should make sense after reading these