Skip to content

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

Merged
merged 15 commits into from
Jul 11, 2025

Conversation

raybjork
Copy link
Member

@raybjork raybjork commented Jul 1, 2025

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 and framesystem.go. The changes should make sense after reading these

@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Jul 1, 2025
Copy link
Contributor

github-actions bot commented Jul 1, 2025

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 Jul 7, 2025
@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 Jul 8, 2025
@raybjork raybjork changed the title RSDK-10936 RSDK-10936 introduce RobotFrameSystem interface Jul 8, 2025
@raybjork raybjork requested review from cheukt and biotinker July 8, 2025 18:48
@raybjork raybjork marked this pull request as ready for review July 8, 2025 18:52
@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 Jul 8, 2025
@raybjork raybjork requested a review from biotinker July 8, 2025 20:59
// frameSystem, err := fsService.FrameSystem(context.Background(), nil)
type Service interface {
resource.Resource
type RobotFrameSystem interface {
Copy link
Member

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?

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'm not sure. Going to defer to @cheukt on this

Copy link
Member

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

Copy link
Member Author

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?

Copy link
Member

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

Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member Author

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

Copy link
Member

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?

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 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

}

// CurrentInputs will get the inputs of all provided dependencies.
func CurrentInputs(ctx context.Context, components []resource.Resource) (referenceframe.FrameSystemInputs, error) {
Copy link
Member

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.

Copy link
Member Author

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

Copy link
Member

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 resources 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!)

Copy link
Member Author

@raybjork raybjork Jul 9, 2025

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)

Copy link
Member

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.

Copy link
Member

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?

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'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

Copy link
Member

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

Copy link
Member

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?

Copy link
Member

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

Copy link
Member

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

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

@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 Jul 10, 2025
@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 Jul 10, 2025
@viambot viambot removed the safe to test This pull request is marked safe to test from a trusted zone label Jul 10, 2025
@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 Jul 10, 2025
@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 Jul 10, 2025
@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 Jul 10, 2025
@raybjork raybjork requested review from biotinker and cheukt July 10, 2025 21:10
@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 Jul 10, 2025
@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 Jul 10, 2025
@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 Jul 11, 2025
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 9ed5605 into viamrobotics:main Jul 11, 2025
18 checks passed
@raybjork raybjork deleted the RSDK-10936 branch July 11, 2025 18:29
hexbabe pushed a commit to hexbabe/sean-rdk that referenced this pull request Jul 29, 2025
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