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

Fix framesystem config diffs #1695

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions robot/framesystem/framesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,19 +228,26 @@ func (svc *frameSystemService) updateLocalParts(ctx context.Context) error {
if c.Frame.Parent == "" {
return errors.Errorf("parent field in frame config for part %q is empty", c.Name)
}
if c.Frame.ID == "" {
c.Frame.ID = c.Name
cfgCopy := &referenceframe.LinkConfig{
ID: c.Frame.ID,
Translation: c.Frame.Translation,
Orientation: c.Frame.Orientation,
Geometry: c.Frame.Geometry,
Comment on lines +234 to +235
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 any chance these will ever get modified? Because they're also pointers, so you're still pointing to the structs in the original config here. If so, then a deep copy may be needed.

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, except inside this very function. The only thing we do with the struct is ParseConfig, which resolves all the pointer config objects into new structs.

Parent: c.Frame.Parent,
}
if cfgCopy.ID == "" {
cfgCopy.ID = c.Name
}
seen[c.Name] = true
model, err := extractModelFrameJSON(svc.r, c.ResourceName())
if err != nil && !errors.Is(err, referenceframe.ErrNoModelInformation) {
return err
}
lif, err := c.Frame.ParseConfig()
lif, err := cfgCopy.ParseConfig()
if err != nil {
return err
}
parts[c.Frame.ID] = &referenceframe.FrameSystemPart{FrameConfig: lif, ModelFrame: model}
parts[cfgCopy.ID] = &referenceframe.FrameSystemPart{FrameConfig: lif, ModelFrame: model}
}
svc.localParts = framesystemparts.PartMapToPartSlice(parts)
return nil
Expand Down